Esempio n. 1
0
        public void TestMSER()
        {
            MSERDetector keyPointDetector    = new MSERDetector();
            SIFT         descriptorGenerator = new SIFT();

            //ParamDef[] parameters = keyPointDetector.GetParams();
            TestFeature2DTracker(keyPointDetector, descriptorGenerator);
        }
Esempio n. 2
0
        public void TestMSER()
        {
            MSERDetector             keyPointDetector    = new MSERDetector();
            BriefDescriptorExtractor descriptorGenerator = new BriefDescriptorExtractor(32);

            //ParamDef[] parameters = keyPointDetector.GetParams();
            TestFeature2DTracker(keyPointDetector, descriptorGenerator);
        }
Esempio n. 3
0
        public MSER()
        {
            var mserDetector = new MSERDetector();

            _deltaProperty = new IntegerProperty("Delta", 1, 100, 1)
            {
                Value = mserDetector.Delta
            };
            _maxAreaProperty = new IntegerProperty("MaxArea", 10, 288000, 250)
            {
                Value = mserDetector.MaxArea
            };
            _minAreaProperty = new IntegerProperty("MinArea", 1, 16000, 100)
            {
                Value = mserDetector.MinArea
            };
            _maxVariationProperty = new FloatProperty("MaxVariation", 0, 1, (decimal)0.01f, 2)
            {
                Value = mserDetector.MaxVariation
            };
            _minDiversityProperty = new FloatProperty("MinDiversity", 0, 1, (decimal)0.01f, 2)
            {
                Value = mserDetector.MinDiversity
            };
            _maxEvolutionProperty = new IntegerProperty("MaxEvolution", 0, 1000, 1)
            {
                Value = mserDetector.MaxEvolution
            };
            _areaThresholdProperty = new FloatProperty("AreaThreshold", 0, 5, (decimal)0.01f, 2)
            {
                Value = (float)mserDetector.AreaThreshold
            };
            _minMarginProperty = new FloatProperty("MinMargin", 0, 1, (decimal)0.001f, 3)
            {
                Value = (float)mserDetector.MinMargin
            };
            _edgeBlurSizeProperty = new IntegerProperty("EdgeBlurSize", 0, 100, 1)
            {
                Value = mserDetector.EdgeBlurSize
            };
            AddProperty(_deltaProperty);
            AddProperty(_maxAreaProperty);
            AddProperty(_minAreaProperty);
            AddProperty(_maxVariationProperty);
            AddProperty(_minDiversityProperty);
            AddProperty(_maxEvolutionProperty);
            AddProperty(_areaThresholdProperty);
            AddProperty(_minMarginProperty);
            AddProperty(_edgeBlurSizeProperty);

            _input  = new InputPin("Image", PinMediaType.Image);
            _output = new OutputPin("Contours", PinMediaType.ContoursArray);
            AddPin(_input);
            AddPin(_output);
        }
        public void MSER()
        {
            var sourceBitmap = Samples.sample13;

            var w = sourceBitmap.Width;
            var h = sourceBitmap.Height;

            using var src = new UMat();

            using var srcMat = sourceBitmap.ToMat();
            srcMat.CopyTo(src);

            using var gray = new UMat();

            CvInvoke.CvtColor(src, gray, ColorConversion.Bgra2Gray);

            using var detector = new MSERDetector(
                      minArea: 5, maxArea: 80, edgeBlurSize: 5);
            using var msers  = new VectorOfVectorOfPoint();
            using var bboxes = new VectorOfRect();

            detector.DetectRegions(gray, msers, bboxes);

            var sw = new Stopwatch();

            sw.Start();

            var n = 100;

            for (var i = 0; i < n; i++)
            {
                detector.DetectRegions(gray, msers, bboxes);
            }

            sw.Stop();

            Console.WriteLine($"{(int)(sw.Elapsed.TotalMicroseconds() / n)} us");

            var result = new byte[w * h];

            foreach (var mser in msers.ToArrayOfArray())
            {
                foreach (var point in mser)
                {
                    result[point.Y * w + point.X] = 255;
                }
            }
            foreach (var bbox in bboxes.ToArray())
            {
            }


            Run("samples/sample13.png");
            //result.RunAs(w, h, 1, "mser.png");
        }
Esempio n. 5
0
        private void btnMSER_Click(object sender, EventArgs e)
        {
            var temproot = RootImg.Clone();
            var tempimg1 = WorkingImg.Clone();
            Image <Bgr, byte> colorimg   = tempimg1.Convert <Bgr, byte>();
            Image <Bgr, byte> tempOriImg = temproot.Convert <Bgr, byte>();
            var f2d = new MSERDetector();

            var keypoint = f2d.Detect(WorkingImg);

            foreach (var point in keypoint)
            {
                System.Drawing.Rectangle rect = new Rectangle();
                rect.X      = (int)point.Point.X;
                rect.Y      = (int)point.Point.Y;
                rect.Width  = (int)point.Size;
                rect.Height = (int)point.Size;
                tempOriImg.Draw(rect, new Bgr(60, 200, 10), 2);
            }

            rtxLog.AppendText("btnMSER_Click" + Environment.NewLine);
            RegistHisroty(tempOriImg);
        }
Esempio n. 6
0
        public override void Process()
        {
            FireProcessingStateChanged(ProcessingState.Started);
            var image    = (IImage)_input.GetData();
            var detector = new MSERDetector
                           (
                _deltaProperty.Value,
                _maxAreaProperty.Value,
                _minAreaProperty.Value,
                _maxVariationProperty.Value,
                _minDiversityProperty.Value,
                _maxEvolutionProperty.Value,
                _areaThresholdProperty.Value,
                _minMarginProperty.Value,
                _edgeBlurSizeProperty.Value
                           );

            using (var storage = new MemStorage())
                detector.ExtractContours(image, null, storage);
            detector.Dispose();
            image.Dispose();

            FireProcessingStateChanged(ProcessingState.Finished);
        }
 public static extern void cvExtractMSER(
     IntPtr img,
     IntPtr mask,
     ref IntPtr contours,
     IntPtr storage,
     MSERDetector parameters);