Reputation: 1165
This question has been asked in different ways many times, many people approach this problem in different ways. Which is why I am unsure of my methodology, it would be good if someone could tell me if I am doing things correctly.
The steps that I follow are -
calibrateCamera
stereoCalibrate
stereoRectify
triangulatePoints
to get the 3D points in
homogenous coordinates.Are the steps that I'm following correct? I've been having problems with the OpenCV documentation so it took me a while to formulate the steps, digging through the documentation. People have approached this problem in OpenCV in different ways, some have even constructed the Fundamental and Essential Matrices using some of the helper functions in the OpenCV documentation, but I think the stereoCalibrate
and stereoRectify
use these helper functions themselves.
Upvotes: 0
Views: 806
Reputation: 180
As you said, everyone has their own way. The way I tried is, the first 4 steps were the same, but for calculating the 3d point I used the stereo matching algorithms that are present in OpenCV. Algorithms like StereoBM, StereoSGBM are implemented in OpenCV and it has provided an easy to use APIs.
So Once we get the disparity map from the stereo matching funciton, we can get the 3d coordinates by using reprojectImageTo3D API. It requires disparity map and Q matrix as inputs.
Upvotes: 1
Reputation: 23536
The steps are theoretically correct. You won't get any good results using them.
My advice would be to get a ready-made stereo camera (ZED or RealSense comes to mind), it already has everything you need, so you don't have to calibrate or calculate, just use their libraries and get some results. Which won't be perfect, but it will give you a good start.
Once you played enough with the stereo camera, you'll have a better understanding where the most problems are, and how to approach them.
Upvotes: 1