Reputation: 90
I have a stereoscopic camera set up with two webcams that I am using with Matlab. I calibrate the cameras, and get the stereoParams.
Then, I want a user to be able to select a point in a picture, and get the real world point location in the image. I know for this I need the baseline, the focal length, and the pixel disparity. I have the pixel disparity, but how do I get the baseline and focal length? Can baseline be calculated from the stereoParams?
Upvotes: 1
Views: 3317
Reputation: 39389
You can use the reconstructScene function, which will give you the 3D world coordinates for every pixel with valid disparity. In this example you look up the 3D coordinates of the centroid of the detected person.
Upvotes: 0
Reputation: 11785
The "pixel" disparity is defined in rectified image coordinates. However, as your real cameras will not normally be exactly parallel and row-aligned, there is a non-identity transformation that rectifies your input camera images. Therefore you need to "undo" the rectification in order to find the pixel in the other image corresponding to a given one. The procedure is as follows:
Note that all these operations need be performed once only for each pixel, and can be cached. In other words, you can pre-compute a "rectified" 2-channel disparity map that for each pixel yields an offset from its coordinates in one image to the corresponding pixel in the other image. The map itself can be stored as an image, whose channel type depends on the disparity range - usually short integer will be enough, as it can represent offsets of +- 32K pixels.
Upvotes: 1
Reputation: 1800
I am not familiar with the Matlab stereo camera calibration functions, but in general, once you calibrate each camera, and find the fundamental matrix, you should be able to do the following:
Upvotes: 1