void CMFCApplication2Dlg: : OnBnClickedBm ()
{
//TODO: add the control notification handler code
IplImage * img1=cvLoadImage ((LPSTR) (LPCTSTR) strFileName1, 0).
IplImage * img2=cvLoadImage ((LPSTR) (LPCTSTR) strFileName2, 0).
CV: : StereoSGBM SGBM;
Int SADWindowSize=9;
SGBM. PreFilterCap=63;
SGBM. SADWindowSize=SADWindowSize & gt; 0? SADWindowSize: 3;
Int cn=img1 - & gt; NChannels;
Int numberOfDisparities=64;
SGBM. P1 cn=8 * * SGBM. SADWindowSize * SGBM SADWindowSize;
SGBM. P2 cn=32 * * SGBM. SADWindowSize * SGBM SADWindowSize;
SGBM. MinDisparity=0;
SGBM. NumberOfDisparities=numberOfDisparities;
SGBM. UniquenessRatio=10;
SGBM. SpeckleWindowSize=100;
SGBM. SpeckleRange=32;
SGBM. Disp12MaxDiff=1;
Mat disp disp8;
Int64 t=getTickCount ();
SGBM (img1 (Mat), img2 (Mat), disp);
T=getTickCount () - t;
Cout<" Time elapsed: "& lt;Disp. ConvertTo (disp8 CV_8U, 255/(numberOfDisparities * 16.));
NamedWindow (" left ", 1);
CvShowImage (" left ", img1);
NamedWindow (" right ", 1);
CvShowImage (" right ", img2);
NamedWindow (" disparity ", 1);
Imshow (" disparity ", disp8);
waitKey();
Imwrite (" sgbm_disparity. PNG, "disp8);
CvDestroyAllWindows ();
}
StrFileName1, 2 is read in two images, original intention is to want to get read two images shown in the figure, and then do parallax
CodePudding user response:
String does not recommend such (LPSTR) (LPCTSTR), there are problems under the UNICODEFile open load should determine whether success
The code is not long, set breakpoints in commissioning
CodePudding user response:
IplImage * img1=cvLoadImage ((LPTSTR) (LPCTSTR) strFileName1, 0).
With LPTSTR, then step through tracking
CodePudding user response:
Step in the Debug mode order execution, please take a look