Ask Your Question
0

Remapping contours (vectors of points) with maps from camera calibration (using cv::remap instead of cv::undistortPoints ?)

asked 2016-07-08 04:20:24 -0600

Major Squirrel gravatar image

Hello there,

I have some contours (multiple std::vector of cv::Point) that I get using cv::findContours and I would like to modify the values of each point (meaning remapping the contours) using both maps that I got from cv::fisheye::initUndistortRectifyMap.

Is there any way to use cv::remap with contours as inputs and outputs ? When I try to use it, I get this assertion from matrix.cpp :

OpenCV Error: Assertion failed (d == 2 && (sizes[0] == 1 || sizes[1] == 1 || sizes[0]*sizes[1] == 0)) in create, file /home/lemaker/Documents/opencv-github/modules/core/src/matrix.cpp, line 2363

I am aware of the existence of cv::fisheye::undistortPoints but it seems that cv::remap is optimized for my case (NEON support + parallel_for_) and I don't need to re-calculate the maps matrix each time (as undistortPoints seems to do it by itself), that is why cv::remap would be a good solution.

Thank you in advance for your answer, and have a good day ! :)

edit retag flag offensive close merge delete

Comments

Just an idea:

  • draw the contours in an image
  • apply the mapping on the image
  • detect the contours in the new image
Eduardo gravatar imageEduardo ( 2016-07-08 07:55:53 -0600 )edit

Sorry @Eduardo, I forgot to mention it : it takes a certain amount of time to remap the frame entirely, that is why I am looking for remapping the infos I need only. :)

Major Squirrel gravatar imageMajor Squirrel ( 2016-07-08 08:37:15 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-07-08 15:45:41 -0600

Tetragramm gravatar image

Remap warps an entire image. It therefore requires an image the size of the maps to warp.

undistortPoints is indeed the method you want. It doesn't have NEON support, but adding parallel for looks very easy. If you want to do it quickly and have OpenMP, just add #pragma omp parallel for above the final loop in the function. If you want to do it right, you can take a look at any of the other parallel functions to see how they do it, like remap.

It doesn't look that hard to add vectorization instructions either. The math and data structures involved are much less complicated than in remap.

edit flag offensive delete link more

Comments

Thanks you @Tetragramm for your answer. I will take a look into remap and undistortPoints codes on GitHub to try parallelization with it. :)

Major Squirrel gravatar imageMajor Squirrel ( 2016-07-09 05:04:56 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2016-07-08 04:20:24 -0600

Seen: 1,207 times

Last updated: Jul 08 '16