Which of types Mat or vector<Point2f> is better to use with function estimateRigidTransform()?
众所周知,我们可以将两个参数传递给函数
例如,为了实现视频稳定(抖动移除),我们可以使用以下两种方法之一:
1 2 3 4 | cv::Mat frame1 = imread("frame1.png"); cv::Mat frame2 = imread("frame2.png"); Mat M = estimateRigidTransform(frame1, frame2, 0); warpAffine(frame2, output, M, Size(640,480), INTER_NEAREST|WARP_INVERSE_MAP); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | vector <uchar> status; vector <float> err; std::vector <cv::Point2f> frame1_features, frame2_features; cv::Mat frame1 = imread("frame1.png"); cv::Mat frame2 = imread("frame2.png"); goodFeaturesToTrack(frame1 , frame1_features, 200, 0.01, 30); goodFeaturesToTrack(frame2 , frame2_features, 200, 0.01, 30); calcOpticalFlowPyrLK(frame1 , frame2, frame1_features, frame2_features, status, err); std::vector <cv::Point2f> frame1_features_ok, frame2_features_ok; for(size_t i=0; i < status.size(); i++) { if(status[i]) { frame1_features_ok.push_back(frame1_features[i]); frame2_features_ok.push_back(frame2_features[i]); } } Mat M = estimateRigidTransform(frame1_features_ok, frame2_features_ok, 0); warpAffine(frame2, output, M, Size(640,480), INTER_NEAREST|WARP_INVERSE_MAP); |
这些方法中哪一种更好用,为什么?
即
在第一种情况下,OpenCV 将在函数
这是两种方法的唯一区别。如果找到