The correct sequence of functions for 3D stereo (triangulatePoints)

Hello,

I try to get a 3D point from 2 stereo cameras. Both cameras are already properly calibrated with a 3erd party program. I confuse with the sequence of functions that I need to call to get a 3D point. I dig the internet and find a lot of different examples but seems all their for the old version of Open CV.

So I should use-
cv::undistortPoints
cv::stereoRectify ← ??? shuld I use this or not
cv::triangulatePoints

Maybe you have a good example on C# or C++?

In order to get a 3D point from a calibrated stereo pair you first need an image correspondence - that is, the image location in pixels in both images that arises from the same 3D feature. If you have image correspondences then you can call traingulatePoints to get your 3D positions.

Depending on how you are determining correspondences you might call undistortPoints or stereoRectify. For example if a user is selecting the points manually (using a mouse to click the location of the feature in each image) you would need to either undistort the images that the user interacts with, or undistort the points after they select them.

If you are trying to find the correspondences by first finding something “interesting” in one image and then searching for the same feature in the other image, you might want to use stereoRectify first. The purpose of calling stereoRectify is to process the images so the epipolar lines are parallel and (usually) horizontal in the two images. This way you can search for the correspondence along a single scan line of the rectified image, which is much easier/faster than searching on an arbitrary line in image space.

Thank you very much for your explanation! it helps a lot!