public void TestStereoBMCorrespondence()
{
Image<Gray, Byte> left = new Image<Gray, byte>("left.jpg");
Image<Gray, Byte> right = new Image<Gray, byte>("right.jpg");
Image<Gray, Int16> leftDisparity = new Image<Gray, Int16>(left.Size);
Image<Gray, Int16> rightDisparity = new Image<Gray, Int16>(left.Size);
StereoBM bm = new StereoBM(Emgu.CV.CvEnum.STEREO_BM_TYPE.BASIC, 0);
Stopwatch watch = Stopwatch.StartNew();
bm.FindStereoCorrespondence(left, right, leftDisparity);
watch.Stop();
Trace.WriteLine(String.Format("Time used: {0} milliseconds", watch.ElapsedMilliseconds));
Matrix<double> q = new Matrix<double>(4, 4);
q.SetIdentity();
MCvPoint3D32f[] points = PointCollection.ReprojectImageTo3D(leftDisparity * (-16), q);
float min = (float)1.0e10, max = 0;
foreach (MCvPoint3D32f p in points)
{
if (p.z < min) min = p.z;
else if (p.z > max) max = p.z;
}
Trace.WriteLine(String.Format("Min : {0}\r\nMax : {1}", min, max));
}