简体   繁体   English

OpenCV立体声匹配

[英]OpenCV Stereo Matching

I'm a newbie to OpenCV. 我是OpenCV的新手。 I'm working on a stereo project using 2 webcams. 我正在使用2个网络摄像头进行立体声项目。 I can display the webcam captures into left and right videos. 我可以将网络摄像头捕获显示在左右视频中。 I want to do the following: When I click on any point on the left frame, I want to find the matching point on the right image (Kinda project the point on the second view using Block Matching or any other algorithm). 我想要执行以下操作:当我单击左框架上的任何点时,我想在右图像上找到匹配点(Kinda使用块匹配或任何其他算法投影第二个视图上的点)。 So I can calculate the disparity. 所以我可以计算出差距。 How can I do this? 我怎样才能做到这一点? Thanks in advance. 提前致谢。

OpenCV's StereoVar object would probably be a good starting point. OpenCV的StereoVar对象可能是一个很好的起点。

You can create a StereoVar object like this: 您可以像这样创建一个StereoVar对象:

StereoVar myStereoVar(int levels, double pyrScale,
                                int nIt, int minDisp, int maxDisp,
                                int poly_n, double poly_sigma, float fi,
                                float lambda, int penalization, int cycle,
                                int flags);

then match pairs of images like this: 然后像这样匹配图像对:

// disp will hold correspondences for each pixel in your pair of images.
myStereoVar(InputArray left, InputArray right, OutputArray disp); 

You might have to transform your cv::Mat into an InputArray , but this should be pretty simple. 您可能必须将cv::Mat转换为InputArray ,但这应该非常简单。

As for clicking on the pixels to see the correspondence, I bet it's possible, but let's worry about this after getting correspondence computation up and running. 至于点击像素来查看对应关系,我敢打赌它是可能的,但是在让对应计算启动并运行之后让我们担心这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM