資源簡介
文章名稱:3-D Point Cloud Generation from Rigid and Flexible Stereo Vision Systems
文章(英文)詳細講解了雙目視覺的一些基本原理,已經如何使用兩個普通的網絡攝像頭來實現雙目視覺,以及如何根據兩個攝像頭來計算物體深度信息。
代碼為文章中附帶的代碼
僅供參考學習

代碼片段和文件信息
#include?“StereoFunctions.h“
#include?“math.h“
int?fileNO?=?0;
//variables?for?correlation?routine?some?of?them?can?be?changed?in?analysis?mode?with
the?correlation?tools?window
int?stereoDispWindowSize?//41
stereoDispTextureThreshold?//15
stereoDispUniquenessRatio?//10
stereoPreFilterSize
stereoPreFilterCap
stereoSavePointCloudValue
stereoSaveOriginal
stereoNumDisparities;
//Correlates?pixels?from?the?left?and?right?images?results?in?a?disparity?map?which?is
stored?in?the?variable?‘disp‘
void?StereoFunctions::stereoCorrelation()
{
//Setup?for?finding?stereo?corrrespondences
CvStereoBMState?*BMState?=?cvCreateStereoBMState();
assert(BMState?!=?0);
BMState->preFilterSize=?stereoPreFilterSize;
BMState->preFilterCap=?stereoPreFilterCap;
BMState->SADWindowSize=?stereoDispWindowSize;
BMState->minDisparity=0;
BMState->numberOfDisparities=stereoNumDisparities;
BMState->textureThreshold?=?stereoDispTextureThreshold;
BMState->uniquenessRatio?=?stereoDispUniquenessRatio;
//timing?for?stereo?correspondence?can?be?assessed?by?turning?on?the?timer
/*?double?time_tot?=0;
clock_t?start?diff;
double?difference;
for(int?i=0;i<100;i++)
{
start=clock();*/
cvFindStereoCorrespondenceBM(img1r?img2r?disp?BMState);
//performs?stereo?correspondence?on?the?rectified?left?and?right?images
/*?diff?=?clock()?-?start;
difference?=?(double)diff/CLOCKS_PER_SEC;
time_tot+=difference;
}
printf(“Time?taken?%f?seconds“(double)((double)time_tot/100));*/
cvNormalize(?disp?vdisp?0?256?CV_MINMAX?);
//save?rectified?iamges?and?disparity?map?if?SHOW_SAVE_DATA?is?set?to?1
if(SHOW_SAVE_DATA){
?cvShowImage(“Disparity?Map“?vdisp);
string?dispFile;
stringstream?str?str2str3;
string?left?right;
str<<“Disparities/DisparityMap“<<“-“< dispFile=str.str();
cvSaveImage(&dispFile[0]vdisp);
str2<<“Rectified/Left“<<“-“< str3<<“Rectified/Right“<<“-“< left=str2.str();
right=str3.str();
cvSaveImage(&left[0]img1r);
cvSaveImage(&right[0]img2r);
}
cvReleaseStereoBMState(&BMState);
fileNO++;
}
//Saves?point?clouds?to?Dylan‘s?and?Dan‘s?viewer?format?as?well?as?ascii?format?for
applied?imagery?integration
//
void?StereoFunctions::stereoSavePointCloud()
{
//used?to?store?reprojected?3-D?image?using?open?cv?reprojection?routine
CvMat*?threeDimage?=?cvCreateMat(?imageSize.height
imageSize.width?CV_32FC3);
FILE?*?threeFile*?distanceFile;
//number?of?points?in?the?point?cloud?needed?for?dylans?viewer
long?pointCount=0;
double?depth=0?horiz=0?vert=0;
//vectors?to?store?3-D?points?calculated?from?reprojection
CvMat?*depthM?=?cvCreateMat(imageSize.height?imageSize.width?CV_32F)
?*horizM?=?cvCreateMat(imageSize.height?imageSize.width?CV_32F)
?*vertM?=?cvCreateMat(imageSize.height?imageSize.width?CV_32F);
//create?strings?for?point?cloud?files
stringstream?strThreeD;
stringstream?strDistance;
if(POINT_CLOUD_FMT_DYLAN)
strThreeD<<“Image-“<
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????9733??2016-05-08?21:43??StereoMain.cpp
?????文件????5488715??2016-05-08?21:37??Short_NJ_T_2009.pdf
?????文件???????2022??2016-05-08?21:44??stdafx.h
?????文件??????13942??2016-05-08?21:50??StereoFunctions.cpp
?????文件???????1209??2016-05-08?21:49??StereoFunctions.h
?????文件???????8668??2016-05-08?21:48??StereoGrabber.cpp
?????文件????????880??2016-05-08?21:45??StereoGrabber.h
-----------?---------??----------?-----??----
??????????????5525169????????????????????7
- 上一篇:極致板材開料木工行業下料軟件
- 下一篇:rar(19)
評論
共有 條評論