FindStereoCorrespondence() публичный Метод

Computes disparity map for the input rectified stereo pair.
Invalid pixels (for which disparity can not be computed) are set to (state->minDisparity-1)*16
public FindStereoCorrespondence ( Byte>.Image left, Byte>.Image right, Int16>.Image disparity ) : void
left Byte>.Image The left single-channel, 8-bit image
right Byte>.Image The right image of the same size and the same type
disparity Int16>.Image The output single-channel 16-bit signed disparity map of the same size as input images. Its elements will be the computed disparities, multiplied by 16 and rounded to integer's
Результат void
Пример #1
0
        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));
        }
Пример #2
0
        private void ProcessImage(Bitmap image)
        {
            // Call the function to apply filtering and enhancement to the captured frame before processing for blobs
            Bitmap CombinedImage = FilterImage(image);

            // Create the processed L and R images for blob processing
            Bitmap ProcessedL = filterL.Apply(CombinedImage);
            Bitmap ProcessedR = filterR.Apply(CombinedImage);

            // Free the memory from the filtered combined image
            CombinedImage.Dispose();

            // Create final L and R images based on source
            Bitmap imageL = filterL.Apply(image);
            Bitmap imageR = filterR.Apply(image);

            // Eventually when done testing/tinkering/and generally toying with different techniques we need to eliminate the L and R images and only keep the overlay.

            // Process the disparity map
            StereoBM bm = new StereoBM(Emgu.CV.CvEnum.STEREO_BM_TYPE.BASIC, 0);
            disparity = new Image<Gray, float>(xMax / 2, yMax);
            bm.FindStereoCorrespondence(new Image<Gray, Byte>(ProcessedL), new Image<Gray, Byte>(ProcessedR), disparity);
            //CvInvoke.cvConvertScale(disparity, disparity, 16, 0);
            //CvInvoke.cvNormalize(disparity, disparity, 0, 255, Emgu.CV.CvEnum.NORM_TYPE.CV_MINMAX,IntPtr.Zero);
            pictureBoxD.Image = disparity.ToBitmap(320, 240);

            // Process the left
            pictureBoxL.Image = ProcessBlobs(imageL, ProcessedL, Input.Left);

            // Process the right
            pictureBoxR.Image = ProcessBlobs(imageR, ProcessedR, Input.Right);

            // Process the combined data
            pictureBoxC.Image = ProcessFingerData();

            disparity.Dispose();        // Free memory no longer needed
            ProcessedL.Dispose();       // Free memory no longer needed
            ProcessedR.Dispose();       // Free memory no longer needed
            imageL.Dispose();           // Free memory no longer needed
            imageR.Dispose();           // Free memory no longer needed
        }