Exemplo n.º 1
0
        private async Task InitTextDetector(System.Net.DownloadProgressChangedEventHandler onDownloadProgressChanged = null)
        {
            if (_textDetector == null)
            {
                FileDownloadManager manager = new FileDownloadManager();

                manager.AddFile(
                    "https://github.com/emgucv/models/raw/master/scene_text/DB_TD500_resnet50.onnx",
                    _modelFolderName,
                    "7B83A5E7AFBBD9D70313C902D188FF328656510DBF57D66A711E07DFDB81DF20");

                manager.OnDownloadProgressChanged += onDownloadProgressChanged;
                await manager.Download();

                if (manager.AllFilesDownloaded)
                {
                    _textDetector = new TextDetectionModel_DB(manager.Files[0].LocalFile);
                    _textDetector.BinaryThreshold  = 0.3f;
                    _textDetector.PolygonThreshold = 0.5f;
                    _textDetector.MaxCandidates    = 200;
                    _textDetector.UnclipRatio      = 2.0;
                    _textDetector.SetInputScale(1.0 / 255.0);
                    _textDetector.SetInputSize(new Size(736, 736));
                    _textDetector.SetInputMean(new MCvScalar(122.67891434, 116.66876762, 104.00698793));


                    /*
                     * if (Emgu.CV.Cuda.CudaInvoke.HasCuda)
                     * {
                     *  _vehicleAttrRecognizer.SetPreferableBackend(Emgu.CV.Dnn.Backend.Cuda);
                     *  _vehicleAttrRecognizer.SetPreferableTarget(Emgu.CV.Dnn.Target.Cuda);
                     * }*/
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Release the memory associated with this scene text detector.
        /// </summary>
        protected override void DisposeObject()
        {
            if (_textDetector != null)
            {
                _textDetector.Dispose();
                _textDetector = null;
            }

            if (_ocr != null)
            {
                _ocr.Dispose();
                _ocr = null;
            }

            if (_freetype != null)
            {
                _freetype.Dispose();
                _freetype = null;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Clear and reset the model. Required Init function to be called again before calling ProcessAndRender.
        /// </summary>
        public void Clear()
        {
            if (_textDetector != null)
            {
                _textDetector.Dispose();
                _textDetector = null;
            }

            if (_ocr != null)
            {
                _ocr.Dispose();
                _ocr = null;
            }

            if (_freetype != null)
            {
                _freetype.Dispose();
                _freetype = null;
            }
        }