• 大小: 1.5MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-11-04
  • 语言: C/C++
  • 标签: 三维重建  VC++  

资源简介

三维重建的VC++代码,需已知两个相机的投影矩阵来计算基本矩阵F OPENCV+OPENGL

资源截图

代码片段和文件信息

#include “stdafx.h“
#include“cv.h“
#include“cxcore.h“
#include“highgui.h“
#include“glut.h“
#include“function.h“
#include
#include
using namespace std;

#pragma comment(lib“cxcore“)
#pragma comment(lib“cv“)
#pragma comment(lib“highgui“)

static int mouse_xmouse_y;
static double rotate_x=0rotate_y=0temp_x=0temp_y=0;
vector>points_2d_vec;
vectorcolors;
void init();
void display();
void reshape(int wint h);
void mouse(int buttonint stateint xint y);
void mouse_move(int xint y);
int main(int argcchar**argv)
{
IplImage*img1=0;
IplImage*img2=0;
if((img1=cvLoadImage(“match_image/1_l.bmp“1))=0)
{
cout<<“fail to load file!!!“< return -1;
}
if((img2=cvLoadImage(“match_image/1_r.bmp“1))=0)
{
cout<<“fail to load file!!!“< return -1;
}
int ij;
double M1[3][4]M2[3][4]F[3][3];
for(i=0;i<3;i++)
{
for(j=0;j<4;j++)
{
M1[i]=0.0;
            M2[i]=0.0;
if(i<3)
F[i]=0.0;
}
}
cout<<“read M1M2“< read_M(M1.M2);
cout<<“Find F matrix“< find_F(FM1M2);
IplImage*gray1=cvCreateImage(cvGetSize(img1)81);
IplImage*gray2=cvCreateImage(cvGetSize(img1)81);
IplImage*temp1=cvCreateImage(cvGetSize(img1)IPL_DEPTH_SIGN|161);
IplImage*temp2=cvCreateImage(cvGetSize(img1)IPL_DEPTH_SIGN|161);
IplImage*img1_contour=cvCreateImage(cvGetSize(img1)81);
IplImage*img2_contour=cvCreateImage(cvGetSize(img1)81);
CvMemStorage*contour_st1=cvCreateMemStorage(0);
CvSeq*contour2=cvCreateSeq(CV_8Usizeof(CvSeq)sizeof(CvPoint)contour_st2);
cout<<“image process“< cvCvtColor(img1gray1CV_BGR2GRAY);
cvEqualizeHist(gray1gray1);
cvCanny(gray1gray10.110.0);
cvCvtColor(img2gray2CV_BGR2GRAY);
cvEqualizeHist(gray2gray2);
cvCanny(gray2gray20.110.0);
cvFindContour(gray1contour_st1&contour1sizeof(CvContour)CV_RETR_LISTCV_link_RUNS);
cvFindContour(gray2contour_st2&contour2sizeof(CvContour)CV_RETR_LISTCV_link_RUNS);
for(;contour2;contour2=contour2->h_next)
{
cvDrawContours(img2_contourcontour2cvScalar(255.0255.0255.0)cvScalar(255.0255.0255.0)0);
}
cvDilate(gray2gray2NULL2);
double p1[2]p2[2]p[3];
cout<<“strat match“< for(;contour1;contour1=contour1->h_next)
{
double color[3]={0.00.00.0};
cvDrawContours(img1_contourcontour1cvScalar(255.0255.0255.0)cvScalar(255.0255.0255.0)0);
vctorpoints_3d;
for(i=0;itotal;i++)
{
p1[0]=((CvPoint*)cvGetSeqElem(contour1i))->x;
p1[1]=((CvPoint*)cvGetSeqElem(contour1i))->y;
if(! match(p1p2img1img2Fcolorimg2_contour))
continue;
cvCircleAA(img2_contourcvPoint(p2[0]p2[1])1255);
point_reconstruct(M1M2p1p2p);
points_3d.push_back(p[0]);
points_3d.push_back(p[1]);
points_3d.push_back(p[2]);
}
if(points_3d.size()!=0)
{
colors.push_back(color[0]/(points_3d.size()/3));
colors.push_back(color[1]/(points_3d

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       5185  2009-07-29 20:22  3drebuild\3drebuild.cpp

     文件       4192  2009-07-29 20:22  3drebuild\3drebuild.dsp

     文件        524  2009-07-29 15:23  3drebuild\3drebuild.dsw

     文件      33792  2009-07-29 20:22  3drebuild\3drebuild.ncb

     文件      48640  2009-07-29 20:22  3drebuild\3drebuild.opt

     文件      10377  2009-07-29 20:18  3drebuild\3drebuild.plg

     文件    6235472  2009-07-29 20:18  3drebuild\Debug\3drebuild.pch

     文件     197632  2009-07-29 20:18  3drebuild\Debug\vc60.idb

     文件     110592  2009-07-29 20:18  3drebuild\Debug\vc60.pdb

     目录          0  2009-07-29 20:18  3drebuild\Debug

     目录          0  2009-07-29 20:22  3drebuild

----------- ---------  ---------- -----  ----

              6646406                    11


评论

共有 条评论