I'm a newbie to OpenCV. I'm working on a stereo project using 2 webcams. 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). 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.
You can create a StereoVar
object like this:
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.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.