using namespace std;
using namespace cv;
int main(int argc, char**argv)
{
long lframecount=0;
//load the videos
VideoCapture capture1(argv[1]);
VideoCapture capture2(argv[2]);
cout << argv[1] << endl;
cout << argv[2] << endl;
if(!capture1.isOpened()||!capture2.isOpened())
{
cout<<"cant load stereo video";
return -1;
}
Mat frame1,frame2;
capture1>> frame1;
capture2>> frame2;
long framecount1= capture1.get(CV_CAP_PROP_FRAME_COUNT);
long framecount2= capture2.get(CV_CAP_PROP_FRAME_COUNT);
namedWindow("depthmap",cv::WINDOW_NORMAL);
cv::Mat disp;
cv::Mat vdisp;
for(long i=1;i<5;i++)
{
lframecount++;
int number=lframecount;
string frame;
std::ostringstream convert;
convert<<number;
frame = convert.str();
//cout<<lframecount<<"\n";
capture1 >> frame1;
capture2 >> frame2;
cv::StereoVar stereo;
stereo.minDisp=-80;
stereo.maxDisp=80;
stereo(frame1,frame2,disp);
double min, max;
minMaxLoc(disp, &min, &max);
disp.convertTo(vdisp, CV_8U, -255.0/max, 255);
std::cout<<"framecount :"<< frame<<std::endl;
imshow("depthmap",vdisp);
waitKey(30);
write << vdisp;
//waitKey(30);
//if(waitKey(0))
//break;
}
write.release();
cv::destroyAllWindows();
return 0;
}
这是我的代码。我在图像中得到很多噪音。我正在使用从我的相机拍摄的图像。任何人都建议我一个好方法?或者任何人都可以指出错误?使用立体声无功功能在opencv ..还有其他任何能产生更好结果的功能吗?