Ejemplo n.º 1
0
        /// <summary>
        /// Find checkerboard in image
        /// </summary>
        /// <param name="img">Image to search pattern for</param>
        /// <param name="image_points">Detected checkerboard image points</param>
        /// <returns>True if pattern was found, false otherwise</returns>
        public override bool FindPattern(Emgu.CV.Image <Gray, byte> img, out System.Drawing.PointF[] image_points)
        {
            Emgu.CV.Image <Gray, byte> my_img = img.Copy();
            my_img._EqualizeHist();
            bool found = Emgu.CV.CameraCalibration.FindChessboardCorners(
                my_img,
                _inner_corners,
                Emgu.CV.CvEnum.CALIB_CB_TYPE.ADAPTIVE_THRESH |
                Emgu.CV.CvEnum.CALIB_CB_TYPE.FILTER_QUADS |
                Emgu.CV.CvEnum.CALIB_CB_TYPE.NORMALIZE_IMAGE,
                out image_points
                );

            if (found)
            {
                my_img.FindCornerSubPix(
                    new System.Drawing.PointF[][] { image_points },
                    new System.Drawing.Size(5, 5),
                    new System.Drawing.Size(-1, -1),
                    new MCvTermCriteria(0.001));
            }
            return(found);
        }
Ejemplo n.º 2
0
 public static PointF[] DetectCornersRB(Bitmap picture, Size patternSize)
 {
     var image = new Emgu.CV.Image<Emgu.CV.Structure.Bgr, byte>(picture);
     Emgu.CV.Image<Emgu.CV.Structure.Gray, byte> gray = new Emgu.CV.Image<Emgu.CV.Structure.Gray, byte>(new byte[image.Height, image.Width, 1]);
     for (var y = 0; y < image.Height; y++)
     {
         for (var x = 0; x < image.Width; x++)
         {
             var r = image[y, x].Red;
             var b = image[y, x].Blue;
             var g = image[y, x].Green;
             var rd = Distance(new double[] { r, b, g }, new double[] { 255, 0, 0 });
             if (rd < 200)
                 gray[y, x] = new Emgu.CV.Structure.Gray(0);
             else
                 gray[y, x] = new Emgu.CV.Structure.Gray(255);
         }
     }
     var corners = Emgu.CV.CameraCalibration.FindChessboardCorners(gray, patternSize, Emgu.CV.CvEnum.CALIB_CB_TYPE.ADAPTIVE_THRESH);
     if (corners == null)
         return null;
     var cc = new PointF[][] { corners };
     gray.FindCornerSubPix(cc, new System.Drawing.Size(11, 11), new System.Drawing.Size(-1, -1), new Emgu.CV.Structure.MCvTermCriteria(30, 0.1));
     return corners;
 }
Ejemplo n.º 3
0
 public static PointF[] DetectCornersBW(Bitmap picture, Size patternSize)
 {
     var image = new Emgu.CV.Image<Emgu.CV.Structure.Gray, byte>(picture);
     var corners = Emgu.CV.CameraCalibration.FindChessboardCorners(image, patternSize, Emgu.CV.CvEnum.CALIB_CB_TYPE.ADAPTIVE_THRESH);
     if (corners == null)
         return null;
     var cc = new PointF[][] { corners };
     image.FindCornerSubPix(cc, new System.Drawing.Size(11, 11), new System.Drawing.Size(-1, -1), new Emgu.CV.Structure.MCvTermCriteria(30, 0.1));
     return corners;
 }