Beispiel #1
0
        public List <Stamp> LocateStamp(string path, string destinationFolder)
        {
            Image <Gray, Byte> image  = new Image <Gray, byte>(path);
            List <Stamp>       stamps = new List <Stamp>();

            CvInvoke.MedianBlur(image, image, 5);
            //CircleF[] circles = CvInvoke.HoughCircles(image, HoughType.Gradient, 1.5, 500, 100, 100, 90, 150);
            CircleF[] circles = CvInvoke.HoughCircles(image, HoughType.Gradient, 3.15, 400, 100, 330, 40, 160);

            FileInfo fi = new FileInfo(path);

            int i = 0;

            foreach (CircleF circle in circles)
            {
                Stamp  stamp  = new DeJePecat.Stamp();
                string saveTo = Path.Combine(destinationFolder, "HoughesAlgorithm_" + fi.Name + "#" + Guid.NewGuid().ToString() + ".jpg");

                stamp.FileName = fi.Name;
                stamp.X        = (int)circle.Center.X;
                stamp.Y        = (int)circle.Center.Y;

                stamps.Add(stamp);
                int ix, iy;

                var extractedStamp = Utility.GetImageRoiFromCenter(image, (int)circle.Center.X, (int)circle.Center.Y, image.Width, image.Width, image.Height, image.Height, out ix, out iy, 150);
                extractedStamp.Save(saveTo);
                i++;
            }

            return(stamps);
        }
Beispiel #2
0
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            MouseEventArgs     me    = (MouseEventArgs)e;
            Image <Gray, Byte> image = new Image <Gray, Byte>(CurrentImageFilePath);

            int ix, iy;

            Image <Gray, Byte> cut = Utility.GetImageRoiFromCenter(image, me.X, me.Y, image.Width, ((PictureBox)sender).Width, image.Height, ((PictureBox)sender).Height, out ix, out iy, 50);

            string saveTo = Path.Combine(_destPath, Guid.NewGuid().ToString() + "_" + Path.GetFileNameWithoutExtension(CurrentImageFilePath) + "_CUT.jpg");

            cut.Save(saveTo);

            pbCut.Image = cut.Bitmap;

            Stamp stamp = new DeJePecat.Stamp();

            stamp.FileName = Path.GetFileName(CurrentImageFilePath);
            stamp.X        = ix;
            stamp.Y        = iy;

            Stamps.Add(stamp);
        }