双目视觉测量的,极线匹配

24 篇文章 0 订阅
5 篇文章 0 订阅

基于OpenCV的立体匹配与极线几何测试,VC6+OpenCV+MDI框架,匹配用SIFT,基础矩阵算法可选,默认为RANSAC。

鼠标在左或右图单击,在另一图上则画出对应的极线,蓝色表示。

当年的日志:

完成cpp版的sift移植.
2:16 2006-5-26

贴一点代码:

[cpp]  view plain copy
  1. void CMyEpilineView::OnLButtonDown(UINT nFlags, CPoint point)   
  2. {  
  3.     // TODO: Add your message handler code here and/or call default  
  4.     CMainFrame *pFrame = (CMainFrame *)AfxGetApp()->m_pMainWnd;    
  5.       
  6.   
  7.     CMyEpilineView *another;//先判断是否为左或右视图  
  8.     if(this==pFrame->m_leftView)  
  9.         another=pFrame->m_rightView;  
  10.     else if(this==pFrame->m_rightView)  
  11.         another=pFrame->m_leftView;  
  12.     else  
  13.         return;  
  14.   
  15.     if (!pFrame->m_fundamental_matrix) // 当没计算基础矩阵时  
  16.         return;  
  17.   
  18.     cvCircle(this->GetDocument()->m_image, cvPoint(point.x,point.y), 2, CV_RGB(0,0,255), 1,8,0);  
  19.     this->Invalidate(TRUE);  
  20.   
  21.     CvMat* points1 = cvCreateMat(2,3,CV_32F);//1个点不行!最少为3,虽然只用1个点  
  22.     cvmSet(points1,0,0, point.x );  
  23.     cvmSet(points1,1,0, point.y );  
  24.   
  25.     CvMat *correspondent_lines= cvCreateMat(3,3,CV_32F);//最少为3  
  26.   
  27.     if(this==pFrame->m_leftView)  
  28.         cvComputeCorrespondEpilines(points1,1,pFrame->m_fundamental_matrix,correspondent_lines);  
  29.     else if(this==pFrame->m_rightView)  
  30.         cvComputeCorrespondEpilines(points1,2,pFrame->m_fundamental_matrix,correspondent_lines);  
  31.     else  
  32.         return;  
  33.     //float a = correspondent_lines->data.ptr[j]+.000001;  
  34.     //float b = (correspondent_lines->data.ptr+correspondent_lines->step)[j]+.000001;   
  35.     //float c = (correspondent_lines->data.ptr+correspondent_lines->step*2)[j];  
  36.     float a = cvmGet(correspondent_lines, 0, 0 );  
  37.     float b = cvmGet(correspondent_lines, 1, 0 );  
  38.     float c = cvmGet(correspondent_lines, 2, 0 );  
  39.       
  40.     cvReleaseMat(&points1);  
  41.     cvReleaseMat(&correspondent_lines);  
  42.     cvLine( another->GetDocument()->m_image, cvPoint( 0, (int)-c/b ),   
  43.         cvPoint(another->GetDocument()->m_image->width,(int)(-c-a*another->GetDocument()->m_image->width)/b), CV_RGB(0,0,255),1,8,0 );  
  44.     //cvCircle(image2, cvPoint( (int)cvmGet(points2,0,i),(int)cvmGet(points2,1,i) ), 2, CV_RGB(255,0,0), 1,8,0);  
  45.     //printf("epiline:(0,%d)-->(%d,0)\n",(int)-c/b,(int)-c/a);  
  46.     //printf("%f,%f,%f\n",a,b,c);  
  47.     another->Invalidate();  
  48. //  cvNamedWindow("click epiline",1);  
  49. //  cvShowImage("click epiline",another->GetDocument()->m_image);  
  50. //  cvWaitKey(0);  
  51.     CScrollView::OnLButtonDown(nFlags, point);  
  52. }  


上图:


上图:

  • 0
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值