OpenCV and standard containers in C++ 11

asked 2015-12-23 08:38:37 -0500

Humam Helfawi gravatar image

I have noticed that OpenCV methods that deal with sequence of points accept either cv::InputArray or const* of the point type. e.g. (cv::Point* const) When you have your points in std::array, you may depend on the const* input of the OpenCV method and call my_array.data() in order to get a pointer of the type. However, you will have to deal with the cv::Point to cv::Point2f and vice-versa problem. Furthermore, it is not really the right way.

I thought that the solution could be found in cv::InputArray where I will find iterator-based solution or at least overloads for C++ standard containers. I read its documentation and I found that it takes either std::vector or cv::Mat and some other Gpu data types.

The question is : Why OpenCV does not provide Iterator-based functions? Should I use the Mat Container instead everywhere?

Example:

std::array<cv::Point,4> my_points,my_points2;
//fill my_points,my_points2
cv::fillConvexPoly(img, my_points.data(), 4, cv::Scalar::all(255));//this works
auto homography_matrix = cv::getPerspectiveTransform(my_points.data(), my_points2.data()); //no work
edit retag flag offensive close merge delete