If the call to ReprojectImageTo3D()
succeeded (points != null
), you should be able to access the individual point values by calling points[index].x
, points[index].y
and points[index].z
respectively, where index
is a valid point index.
Return the X, Y and Z values of reprojectImageTo3D method in C# using emgu cv
Question
I am currently writing a stereo vision program in C# using the Emgu cv framework. The idea is to track a ball within a frame and display its actual distance from the cameras. The tasks I have completed so far are as follows:
1) I have the camera calibration operating with corners of the chessboard being marked by an array of coloured lines and circles.
2) I have added code in order to undistort each image so as to get accurate matches when the disparity map is created.
3) I have the disparity map displayed using stereo block matching and reprojection of image points using the reprojectImageTo3D() method in Emgu Cv
4) I have the ball being tracked in each cameras frame and the x and y coordinates of the balls centre being identified
The issue I am having at the moment however is how do I display the X, Y and Z values of the disparity map contained within the reprojectImageTo3D method? This variable is a type MCvPoint3D32f array which is part of the Emgu Cv class. I have tried the usual ways of retrieving a value from an point array with no success. Below is my method containing this code:
private void Computer3DPointsFromStereoPair(Image<Gray, Byte> left, Image<Gray, Byte> right, out Image<Gray, short> disparityMap, out MCvPoint3D32f[] points)
{
Size size = left.Size;
disparityMap = new Image<Gray, short>(size);
//thread safe calibration values
using (StereoSGBM stereoSolver = new StereoSGBM(minDisparities, numDisparities, SAD, P1, P2, disp12MaxDiff, PreFilterCap, UniquenessRation, Speckle, SpeckleRange, fullDP))
//using (StereoBM stereoSolver = new StereoBM(Emgu.CV.CvEnum.Stereo_BM_TYPE.BASIC, 0))
{
stereoSolver.FindStereoCorrespondence(left, right, disparityMap);
points = PointCollection.ReprojectImageTo3D(disparityMap, Q);
}
}
Thanks in advance
Regards
Steve
Solution