当使用OpenCV的findHomography函数来估计两组点之间的单应性时,从不同的图像中,即使使用RANSAC或LMEDS,由于输入点内的异常值,有时也会得到差的单应性.
// opencv java example:
Mat H = Calib3d.findHomography( src_points, dst_points, Calib3d.RANSAC, 10 );
如何判断得到的3x3单应矩阵是否可以接受?
我在Stackoverflow和Google中找到了这个问题的答案,但无法找到它.
我找到了这篇文章,但对我来说有点神秘:
我正在使用findHomography点列表并将结果发送到warpPerspective.
问题是有时结果是完全垃圾,结果图像由奇怪的灰色矩形表示.
如何检测何时findHomography向我发送不良结果?
我试图从视频中检测到车辆,我将在实时应用程序中进行,但暂时并且为了理解我正在视频上进行操作,代码如下:
void surf_detection(Mat img_1,Mat img_2); /** @function main */
int main( int argc, char** argv )
{
 int i;
 int key;
 CvCapture* capture = cvCaptureFromAVI("try2.avi");// Read the video file
 if (!capture){
     std::cout <<" Error in capture video file";
     return -1;
 }
 Mat img_template = imread("images.jpg"); // read template image
int numFrames = (int) cvGetCaptureProperty(capture,  CV_CAP_PROP_FRAME_COUNT);
IplImage* img = 0; 
for(i=0;i<numFrames;i++){
  cvGrabFrame(capture);          // capture a frame
  img=cvRetrieveFrame(capture);  // retrieve the captured frame
  surf_detection (img_template,img);
  cvShowImage("mainWin", img); 
  key=cvWaitKey(20);           
}
 return 0;
 } …我正在使用OpenCV中的仿射变换,我无法直观地理解它的工作原理,更具体地说,我如何指定地图矩阵的参数,以便获得特定的期望结果.
要设置问题,我使用的过程是第一个定义warp矩阵,然后进行转换.
在OpenCV中,有两个例程(我在Bradski&Kaehler的优秀书籍OpenCV中使用了一个例子):
cvGetAffineTransorm(srcTri, dstTri, warp_matrix);
cvWarpAffine(src, dst, warp_mat);
为了限定该经矩阵,srcTri并且dstTri定义如下:
CvPoint2D32f srcTri[3], dstTri[3];
srcTri[3] 填充如下:
srcTri[0].x = 0;
srcTri[0].y = 0;
srcTri[1].x = src->width - 1;
srcTri[1].y = 0;
srcTri[2].x = 0;
srcTri[2].y = src->height -1;
这基本上是矩阵起点的图像的左上角,右上角和左下角.这部分对我有意义.
但是,dstTri[3]正义的价值令人困惑,至少,当我改变一个点时,我没有得到我期望的结果.
例如,如果我然后使用以下内容dstTri[3]:
dstTri[0].x = 0;
dstTri[0].y = 0;
dstTri[1].x = src->width - 1;
dstTri[1].y = 0;
dstTri[2].x = 0;
dstTri[2].y = 100;
似乎src和dst点之间的唯一区别是左下角点向右移动了100个像素.直觉上,我觉得图像的底部应该向右移动100个像素,但事实并非如此.
另外,如果我使用了完全相同的值dstTri[3],我使用的srcTri[3],我认为转换会产生完全相同的图像-但事实并非如此.
显然,我不明白这里发生了什么.那么,从代表srcTri[]到dstTri[]代表的映射是什么?