简体   繁体   中英

opencv “vector iterators incompatible”

I am using opencv 2.2 and VC++(2008) to track an object, while using goodFeaturesToTrack in the program ' vector iterators incompatible ' error occurs

vector<Point2f> points;
goodFeaturesToTrack(mat,points,10, 0.01, 10, Mat(), 3, 0, 0.04);

Is there any work around for this?

Try the following instead.

std::vector<cv::Point2f> points;
cv::Mat pointmat(points);
cv::Mat tempmat = Mat(mat.rows,mat.cols, cv::CV_32FC1);
goodFeaturesToTrack(mat,pointmat, tempmat,10, 0.01, 10, Mat(), 3, 0, 0.04);

goodFeaturesToTrack takes an additional argument of tempimage as per the documentation . Its first 3 arguments are of type CvArr, which a std::vector<cv::Point2f> isn't , hence difference in std::vector iterators error message.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM