Example #1
0
      static void Main(string[] args)
      {
         MCvPoint3D32f[] _points;
         Mat _left = CvInvoke.Imread("imL.png", ImreadModes.Color);
         Mat _right = CvInvoke.Imread("imR.png", ImreadModes.Color);
         Mat disparityMap = new Mat();

         Stopwatch watch = Stopwatch.StartNew();
         UMat leftGray = new UMat();
         UMat rightGray = new UMat();
         CvInvoke.CvtColor(_left, leftGray, ColorConversion.Bgr2Gray);
         CvInvoke.CvtColor(_right, rightGray, ColorConversion.Bgr2Gray);
         Mat points = new Mat();
         Computer3DPointsFromStereoPair(leftGray, rightGray, disparityMap, points);
         watch.Stop();
         long disparityComputationTime = watch.ElapsedMilliseconds;

         Mat pointsArray = points.Reshape(points.NumberOfChannels, points.Rows*points.Cols);
         Mat colorArray = _left.Reshape(_left.NumberOfChannels, _left.Rows*_left.Cols);
         Mat colorArrayFloat = new Mat();
         colorArray.ConvertTo(colorArrayFloat, DepthType.Cv32F);
         WCloud cloud = new WCloud(pointsArray, colorArray);

         Emgu.CV.Viz3d v = new Emgu.CV.Viz3d("Simple stereo reconstruction");
         WText wtext = new WText("3d point cloud", new System.Drawing.Point(20, 20), 20, new MCvScalar(255, 255, 255));
         WCoordinateSystem wCoordinate = new WCoordinateSystem(1.0);
         v.ShowWidget("text", wtext);
         //v.ShowWidget("coordinate", wCoordinate);
         v.ShowWidget("cloud", cloud);
         v.Spin();
      }
Example #2
0
        /// <summary>
        /// Indicates whether the current object is equal to another object of the same type.
        /// </summary>
        /// <param name="other">An object to compare with this object.</param>
        /// <returns>
        /// true if the current object is equal to the <paramref name="other" /> parameter; otherwise, false.
        /// </returns>
        public bool Equals(UMat other)
        {
            if (!(Size.Equals(other.Size) && NumberOfChannels == other.NumberOfChannels && Depth == other.Depth))
            {
                return(false);
            }

            using (Mat cmpResult = new Mat())
            {
                CvInvoke.Compare(this, other, cmpResult, CmpType.NotEqual);
                using (Mat reshaped = cmpResult.Reshape(1))
                    return(CvInvoke.CountNonZero(reshaped) == 0);
            }
        }