Merge pull request #16841 from TolyaTalamanov:at/warp-perspective
G-API: Implement WarpPerspective * Implement WarpPerspective kernel * Fix comment to review
This commit is contained in:
committed by
GitHub
parent
b0563ce368
commit
c303aaa94d
@@ -142,8 +142,13 @@ struct BackendOutputAllocationTest : TestWithParamBase<>
|
||||
struct BackendOutputAllocationLargeSizeWithCorrectSubmatrixTest : BackendOutputAllocationTest {};
|
||||
GAPI_TEST_FIXTURE(ReInitOutTest, initNothing, <cv::Size>, 1, out_sz)
|
||||
|
||||
GAPI_TEST_FIXTURE(WarpAffineTest, initMatrixRandU, FIXTURE_API(CompareMats, double , double, int, int, cv::Scalar), 6,
|
||||
cmpF, angle, scale, flags, border_mode, border_value)
|
||||
GAPI_TEST_FIXTURE(WarpPerspectiveTest, initMatrixRandU,
|
||||
FIXTURE_API(CompareMats, double , double, int, int, cv::Scalar),
|
||||
6, cmpF, angle, scale, flags, border_mode, border_value)
|
||||
|
||||
GAPI_TEST_FIXTURE(WarpAffineTest, initMatrixRandU,
|
||||
FIXTURE_API(CompareMats, double , double, int, int, cv::Scalar),
|
||||
6, cmpF, angle, scale, flags, border_mode, border_value)
|
||||
} // opencv_test
|
||||
|
||||
#endif //OPENCV_GAPI_CORE_TESTS_HPP
|
||||
|
||||
@@ -1266,6 +1266,30 @@ TEST_P(SqrtTest, AccuracyTest)
|
||||
}
|
||||
}
|
||||
|
||||
TEST_P(WarpPerspectiveTest, AccuracyTest)
|
||||
{
|
||||
cv::Point center{in_mat1.size() / 2};
|
||||
cv::Mat xy = cv::getRotationMatrix2D(center, angle, scale);
|
||||
cv::Matx13d z (0, 0, 1);
|
||||
cv::Mat transform_mat;
|
||||
cv::vconcat(xy, z, transform_mat);
|
||||
|
||||
// G-API code //////////////////////////////////////////////////////////////
|
||||
cv::GMat in;
|
||||
auto out = cv::gapi::warpPerspective(in, transform_mat, in_mat1.size(), flags, border_mode, border_value);
|
||||
|
||||
cv::GComputation c(in, out);
|
||||
c.apply(in_mat1, out_mat_gapi, getCompileArgs());
|
||||
|
||||
// OpenCV code /////////////////////////////////////////////////////////////
|
||||
cv::warpPerspective(in_mat1, out_mat_ocv, cv::Mat(transform_mat), in_mat1.size(), flags, border_mode, border_value);
|
||||
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_P(WarpAffineTest, AccuracyTest)
|
||||
{
|
||||
cv::Point center{in_mat1.size() / 2};
|
||||
|
||||
@@ -435,6 +435,19 @@ INSTANTIATE_TEST_CASE_P(ConcatHorVecTestCPU, ConcatHorVecTest,
|
||||
Values(-1),
|
||||
Values(CORE_CPU)));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(WarpPerspectiveTestCPU, WarpPerspectiveTest,
|
||||
Combine(Values(CV_8UC1, CV_8UC3),
|
||||
Values(cv::Size(1280, 720),
|
||||
cv::Size(640, 480)),
|
||||
Values(-1),
|
||||
Values(CORE_CPU),
|
||||
Values(AbsExact().to_compare_obj()),
|
||||
Values(-50.0, 90.0),
|
||||
Values(0.6),
|
||||
Values(cv::INTER_LINEAR),
|
||||
Values(cv::BORDER_CONSTANT),
|
||||
Values(cv::Scalar())));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(WarpAffineTestCPU, WarpAffineTest,
|
||||
Combine(Values(CV_8UC1, CV_8UC3),
|
||||
Values(cv::Size(1280, 720),
|
||||
|
||||
Reference in New Issue
Block a user