Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV std::vector< cv::Point2f > to cv::Mat

Tags:

c++

opencv

I am developing an application in OpenCV, and on Windows the following code is valid, and compiles / works:

/* Calculate the transformation points */
std::vector<cv::Point2f> img1;
std::vector<cv::Point2f> img2;
for( int i = 0; i < good_matches.size(); i++ ) {
    img1.push_back( keypoints_imageOne[ good_matches[i].queryIdx ].pt );
    img2.push_back( keypoints_imageTwo[ good_matches[i].trainIdx ].pt );
}

/* Generate the homogonous matrix from the transformation points */
cv::Mat H = cv::findHomography(img1, img2, CV_RANSAC);

However, when I switch to either my Mac or Linux box, I get an error saying that there is no function prototype for the arguments (as the function prototype requires cv::Mat in place of the std::vector< cv::Point2f >)

So my question is, how can / should I cast from std::vector < cv::Point2f > to cv::Mat or how should I go about doing this otherwise?

like image 835
chrisburke.io Avatar asked Nov 10 '11 16:11

chrisburke.io


1 Answers

It seems that you have an older version of OpenCV on Linux. The possibility to use vectors as input to openCV functions is added to ver 2.3, I think.

So, happy update!

like image 195
Sam Avatar answered Sep 22 '22 01:09

Sam