TAPI: fix perf test for warpers
This commit is contained in:
parent
bf4f15fb5f
commit
ddd3c062b5
@ -60,7 +60,7 @@ enum
|
|||||||
class WarperBase
|
class WarperBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit WarperBase(int type)
|
explicit WarperBase(int type, Size srcSize)
|
||||||
{
|
{
|
||||||
Ptr<WarperCreator> creator;
|
Ptr<WarperCreator> creator;
|
||||||
if (cv::ocl::useOpenCL())
|
if (cv::ocl::useOpenCL())
|
||||||
@ -83,10 +83,16 @@ public:
|
|||||||
}
|
}
|
||||||
CV_Assert(!creator.empty());
|
CV_Assert(!creator.empty());
|
||||||
|
|
||||||
warper = creator->create(2.0);
|
|
||||||
|
|
||||||
K = Mat::eye(3, 3, CV_32FC1);
|
K = Mat::eye(3, 3, CV_32FC1);
|
||||||
|
K.at<float>(0,0) = (float)srcSize.width;
|
||||||
|
K.at<float>(0,2) = (float)srcSize.width/2;
|
||||||
|
K.at<float>(1,1) = (float)srcSize.height;
|
||||||
|
K.at<float>(1,2) = (float)srcSize.height/2;
|
||||||
|
K.at<float>(2,2) = 1.0f;
|
||||||
R = Mat::eye(3, 3, CV_32FC1);
|
R = Mat::eye(3, 3, CV_32FC1);
|
||||||
|
float scale = (float)srcSize.width;
|
||||||
|
|
||||||
|
warper = creator->create(scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
Rect buildMaps(Size src_size, OutputArray xmap, OutputArray ymap) const
|
Rect buildMaps(Size src_size, OutputArray xmap, OutputArray ymap) const
|
||||||
@ -109,15 +115,25 @@ CV_ENUM(WarperType, SphericalWarperType, CylindricalWarperType, PlaneWarperType)
|
|||||||
typedef tuple<Size, WarperType> StitchingWarpersParams;
|
typedef tuple<Size, WarperType> StitchingWarpersParams;
|
||||||
typedef TestBaseWithParam<StitchingWarpersParams> StitchingWarpersFixture;
|
typedef TestBaseWithParam<StitchingWarpersParams> StitchingWarpersFixture;
|
||||||
|
|
||||||
|
static void prepareWarperSrc(InputOutputArray src, Size srcSize)
|
||||||
|
{
|
||||||
|
src.create(srcSize, CV_8UC1);
|
||||||
|
src.setTo(Scalar::all(64));
|
||||||
|
ellipse(src, Point(srcSize.width/2, srcSize.height/2), Size(srcSize.width/2, srcSize.height/2),
|
||||||
|
360, 0, 360, Scalar::all(255), 2);
|
||||||
|
ellipse(src, Point(srcSize.width/2, srcSize.height/2), Size(srcSize.width/3, srcSize.height/3),
|
||||||
|
360, 0, 360, Scalar::all(128), 2);
|
||||||
|
rectangle(src, Point(10, 10), Point(srcSize.width - 10, srcSize.height - 10), Scalar::all(128), 2);
|
||||||
|
}
|
||||||
|
|
||||||
OCL_PERF_TEST_P(StitchingWarpersFixture, StitchingWarpers_BuildMaps,
|
OCL_PERF_TEST_P(StitchingWarpersFixture, StitchingWarpers_BuildMaps,
|
||||||
::testing::Combine(OCL_TEST_SIZES, WarperType::all()))
|
::testing::Combine(OCL_TEST_SIZES, WarperType::all()))
|
||||||
{
|
{
|
||||||
const StitchingWarpersParams params = GetParam();
|
const StitchingWarpersParams params = GetParam();
|
||||||
const Size srcSize = get<0>(params);
|
const Size srcSize = get<0>(params);
|
||||||
const WarperBase warper(get<1>(params));
|
const WarperBase warper(get<1>(params), srcSize);
|
||||||
|
|
||||||
UMat src(srcSize, CV_32FC1), xmap(srcSize, CV_32FC1), ymap(srcSize, CV_32FC1);
|
UMat xmap, ymap;
|
||||||
declare.in(src, WARMUP_RNG).out(xmap, ymap);
|
|
||||||
|
|
||||||
OCL_TEST_CYCLE() warper.buildMaps(srcSize, xmap, ymap);
|
OCL_TEST_CYCLE() warper.buildMaps(srcSize, xmap, ymap);
|
||||||
|
|
||||||
@ -130,13 +146,23 @@ OCL_PERF_TEST_P(StitchingWarpersFixture, StitchingWarpers_Warp,
|
|||||||
{
|
{
|
||||||
const StitchingWarpersParams params = GetParam();
|
const StitchingWarpersParams params = GetParam();
|
||||||
const Size srcSize = get<0>(params);
|
const Size srcSize = get<0>(params);
|
||||||
const WarperBase warper(get<1>(params));
|
const WarperBase warper(get<1>(params), srcSize);
|
||||||
|
|
||||||
UMat src(srcSize, CV_32FC1), dst(srcSize, CV_32FC1);
|
UMat src, dst;
|
||||||
declare.in(src, WARMUP_RNG).out(dst);
|
prepareWarperSrc(src, srcSize);
|
||||||
|
declare.in(src, WARMUP_READ);
|
||||||
|
|
||||||
OCL_TEST_CYCLE() warper.warp(src, INTER_LINEAR, BORDER_REPLICATE, dst);
|
OCL_TEST_CYCLE() warper.warp(src, INTER_LINEAR, BORDER_REPLICATE, dst);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
namedWindow("src", WINDOW_NORMAL);
|
||||||
|
namedWindow("dst", WINDOW_NORMAL);
|
||||||
|
imshow("src", src);
|
||||||
|
imshow("dst", dst);
|
||||||
|
std::cout << dst.size() << " " << dst.size().area() << std::endl;
|
||||||
|
cv::waitKey();
|
||||||
|
#endif
|
||||||
|
|
||||||
SANITY_CHECK(dst, 1e-5);
|
SANITY_CHECK(dst, 1e-5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ namespace detail {
|
|||||||
|
|
||||||
Rect PlaneWarperOcl::buildMaps(Size src_size, InputArray K, InputArray R, InputArray T, OutputArray xmap, OutputArray ymap)
|
Rect PlaneWarperOcl::buildMaps(Size src_size, InputArray K, InputArray R, InputArray T, OutputArray xmap, OutputArray ymap)
|
||||||
{
|
{
|
||||||
projector_.setCameraParams(K, R);
|
projector_.setCameraParams(K, R, T);
|
||||||
|
|
||||||
Point dst_tl, dst_br;
|
Point dst_tl, dst_br;
|
||||||
detectResultRoi(src_size, dst_tl, dst_br);
|
detectResultRoi(src_size, dst_tl, dst_br);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user