private async Task InitVehicleAttributesRecognizer(System.Net.DownloadProgressChangedEventHandler onDownloadProgressChanged = null) { if (_vehicleAttrRecognizer == null) { FileDownloadManager manager = new FileDownloadManager(); manager.AddFile( "https://download.01.org/opencv/2020/openvinotoolkit/2020.4/open_model_zoo/models_bin/3/vehicle-attributes-recognition-barrier-0042/FP32/vehicle-attributes-recognition-barrier-0042.xml", _modelFolderName); manager.AddFile( "https://download.01.org/opencv/2020/openvinotoolkit/2020.4/open_model_zoo/models_bin/3/vehicle-attributes-recognition-barrier-0042/FP32/vehicle-attributes-recognition-barrier-0042.bin", _modelFolderName); manager.OnDownloadProgressChanged += onDownloadProgressChanged; await manager.Download(); _vehicleAttrRecognizer = DnnInvoke.ReadNetFromModelOptimizer(manager.Files[0].LocalFile, manager.Files[1].LocalFile); /* * if (Emgu.CV.Cuda.CudaInvoke.HasCuda) * { * _vehicleAttrRecognizer.SetPreferableBackend(Emgu.CV.Dnn.Backend.Cuda); * _vehicleAttrRecognizer.SetPreferableTarget(Emgu.CV.Dnn.Target.Cuda); * }*/ } }
private async Task InitLicensePlateDetector(Dnn.Backend preferredBackend, Dnn.Target preferredTarget, System.Net.DownloadProgressChangedEventHandler onDownloadProgressChanged = null) { if (_vehicleLicensePlateDetectionModel == null) { FileDownloadManager manager = new FileDownloadManager(); manager.AddFile( "https://storage.openvinotoolkit.org/repositories/open_model_zoo/2021.2/models_bin/3/vehicle-license-plate-detection-barrier-0106/FP32/vehicle-license-plate-detection-barrier-0106.xml", _modelFolderName); manager.AddFile( "https://storage.openvinotoolkit.org/repositories/open_model_zoo/2021.2/models_bin/3/vehicle-license-plate-detection-barrier-0106/FP32/vehicle-license-plate-detection-barrier-0106.bin", _modelFolderName); manager.OnDownloadProgressChanged += onDownloadProgressChanged; await manager.Download(); _vehicleLicensePlateDetectionModel = new DetectionModel(manager.Files[1].LocalFile, manager.Files[0].LocalFile); _vehicleLicensePlateDetectionModel.SetInputSize(new Size(300, 300)); _vehicleLicensePlateDetectionModel.SetInputMean(new MCvScalar()); _vehicleLicensePlateDetectionModel.SetInputScale(1.0); _vehicleLicensePlateDetectionModel.SetInputSwapRB(false); _vehicleLicensePlateDetectionModel.SetInputCrop(false); _vehicleLicensePlateDetectionModel.SetPreferableBackend(preferredBackend); _vehicleLicensePlateDetectionModel.SetPreferableTarget(preferredTarget); } }
InitTesseract(String lang, OcrEngineMode mode, System.Net.DownloadProgressChangedEventHandler onDownloadProgressChanged = null) { if (_ocr == null) { FileDownloadManager manager = new FileDownloadManager(); manager.AddFile(Emgu.CV.OCR.Tesseract.GetLangFileUrl(lang), _modelFolderName); manager.AddFile(Emgu.CV.OCR.Tesseract.GetLangFileUrl("osd"), _modelFolderName); //script orientation detection if (onDownloadProgressChanged != null) { manager.OnDownloadProgressChanged += onDownloadProgressChanged; } #if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE || UNITY_WEBGL yield return(manager.Download()); #else await manager.Download(); #endif if (manager.AllFilesDownloaded) { _lang = lang; _mode = mode; FileInfo fi = new FileInfo(manager.Files[0].LocalFile); _ocr = new Tesseract(fi.DirectoryName, _lang, _mode); } } }
/// <summary> /// Download and initialize the DNN face detector /// </summary> /// <param name="onDownloadProgressChanged">Callback when download progress has been changed</param> /// <returns>Async task</returns> public async Task Init(System.Net.DownloadProgressChangedEventHandler onDownloadProgressChanged = null) { if (_faceDetectorNet == null) { FileDownloadManager manager = new FileDownloadManager(); manager.AddFile( "https://github.com/opencv/opencv_3rdparty/raw/dnn_samples_face_detector_20170830/res10_300x300_ssd_iter_140000.caffemodel", _modelFolderName, "2A56A11A57A4A295956B0660B4A3D76BBDCA2206C4961CEA8EFE7D95C7CB2F2D"); manager.AddFile( "https://raw.githubusercontent.com/opencv/opencv/4.0.1/samples/dnn/face_detector/deploy.prototxt", _modelFolderName, "F62621CAC923D6F37BD669298C428BB7EE72233B5F8C3389BB893E35EBBCF795"); if (onDownloadProgressChanged != null) { manager.OnDownloadProgressChanged += onDownloadProgressChanged; } await manager.Download(); if (manager.AllFilesDownloaded) { _faceDetectorNet = DnnInvoke.ReadNetFromCaffe(manager.Files[1].LocalFile, manager.Files[0].LocalFile); if (Emgu.CV.Cuda.CudaInvoke.HasCuda) { _faceDetectorNet.SetPreferableBackend(Emgu.CV.Dnn.Backend.Cuda); _faceDetectorNet.SetPreferableTarget(Emgu.CV.Dnn.Target.Cuda); } } } }
private async Task InitLicensePlateDetector(System.Net.DownloadProgressChangedEventHandler onDownloadProgressChanged = null) { if (_vehicleLicensePlateDetector == null) { FileDownloadManager manager = new FileDownloadManager(); manager.AddFile( "https://storage.openvinotoolkit.org/repositories/open_model_zoo/2021.2/models_bin/3/vehicle-license-plate-detection-barrier-0106/FP32/vehicle-license-plate-detection-barrier-0106.xml", _modelFolderName); manager.AddFile( "https://storage.openvinotoolkit.org/repositories/open_model_zoo/2021.2/models_bin/3/vehicle-license-plate-detection-barrier-0106/FP32/vehicle-license-plate-detection-barrier-0106.bin", _modelFolderName); manager.OnDownloadProgressChanged += onDownloadProgressChanged; await manager.Download(); _vehicleLicensePlateDetector = DnnInvoke.ReadNetFromModelOptimizer(manager.Files[0].LocalFile, manager.Files[1].LocalFile); /* * if (Emgu.CV.Cuda.CudaInvoke.HasCuda) * { * _vehicleLicensePlateDetector.SetPreferableBackend(Emgu.CV.Dnn.Backend.Cuda); * _vehicleLicensePlateDetector.SetPreferableTarget(Emgu.CV.Dnn.Target.Cuda); * }*/ } }
Init( DownloadableFile modelFile = null, DownloadableFile labelFile = null, IDelegate optDelegate = null) { if (!Imported) { _downloadManager.Clear(); _downloadManager.AddFile(modelFile); _downloadManager.AddFile(labelFile); #if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE yield return(_downloadManager.Download()); #else await _downloadManager.Download(); #endif if (_downloadManager.AllFilesDownloaded) { ImportGraph(optDelegate); } else { System.Diagnostics.Trace.WriteLine("Failed to download all files"); } } }
public async Task Init(System.Net.DownloadProgressChangedEventHandler onDownloadProgressChanged = null) { if (_faceDetector == null) { FileDownloadManager manager = new FileDownloadManager(); manager.AddFile( "https://github.com/opencv/opencv_3rdparty/raw/dnn_samples_face_detector_20170830/res10_300x300_ssd_iter_140000.caffemodel", _modelFolderName); manager.AddFile( "https://raw.githubusercontent.com/opencv/opencv/4.0.1/samples/dnn/face_detector/deploy.prototxt", _modelFolderName); if (onDownloadProgressChanged != null) { manager.OnDownloadProgressChanged += onDownloadProgressChanged; } await manager.Download(); _faceDetector = DnnInvoke.ReadNetFromCaffe(manager.Files[1].LocalFile, manager.Files[0].LocalFile); if (Emgu.CV.Cuda.CudaInvoke.HasCuda) { _faceDetector.SetPreferableBackend(Emgu.CV.Dnn.Backend.Cuda); _faceDetector.SetPreferableTarget(Emgu.CV.Dnn.Target.Cuda); } } }
private async Task InitVehicleAttributesRecognizer(System.Net.DownloadProgressChangedEventHandler onDownloadProgressChanged = null) { if (_vehicleAttrRecognizer == null) { FileDownloadManager manager = new FileDownloadManager(); manager.AddFile( "https://storage.openvinotoolkit.org/repositories/open_model_zoo/2021.2/models_bin/3/vehicle-attributes-recognition-barrier-0042/FP32/vehicle-attributes-recognition-barrier-0042.xml", _modelFolderName, "9D1E877B153699CAF4547D08BFF7FE268F65B663441A42B929924B8D95DACDBB"); manager.AddFile( "https://storage.openvinotoolkit.org/repositories/open_model_zoo/2021.2/models_bin/3/vehicle-attributes-recognition-barrier-0042/FP32/vehicle-attributes-recognition-barrier-0042.bin", _modelFolderName, "492520E55F452223E767D54227D6EF6B60B0C1752DD7B9D747BE65D57B685A0E"); manager.OnDownloadProgressChanged += onDownloadProgressChanged; await manager.Download(); _vehicleAttrRecognizer = DnnInvoke.ReadNetFromModelOptimizer(manager.Files[0].LocalFile, manager.Files[1].LocalFile); /* * if (Emgu.CV.Cuda.CudaInvoke.HasCuda) * { * _vehicleAttrRecognizer.SetPreferableBackend(Emgu.CV.Dnn.Backend.Cuda); * _vehicleAttrRecognizer.SetPreferableTarget(Emgu.CV.Dnn.Target.Cuda); * }*/ } }
public async Task Init(System.Net.DownloadProgressChangedEventHandler onDownloadProgressChanged = null) #endif { _blobFile = new DownloadableFile( "https://github.com/emgucv/models/raw/master/DepthAI/mobilenet-ssd/mobilenet-ssd.blob.sh14cmx14NCE1", _modelFolderName, "952C8AA1759CAB442D82781579EE4B9BA828CBED8AB9AD3C94D5222AA45DCA6E"); _blobConfigFile = new DownloadableFile( "https://github.com/emgucv/models/raw/master/DepthAI/mobilenet-ssd/mobilenet-ssd.json", _modelFolderName, "606A965DDF539857D3477AED659A69948D8B310A20B38C3B794F2369ECC685FE"); if (_manager == null) { _manager = new FileDownloadManager(); } else { _manager.Clear(); } _manager.AddFile(_blobFile); _manager.AddFile(_blobConfigFile); if (onDownloadProgressChanged != null) { _manager.OnDownloadProgressChanged += onDownloadProgressChanged; } #if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE || UNITY_WEBGL yield return(_manager.Download()); #else await _manager.Download(); #endif }
private async Task InitVehicleAttributesRecognizer(Dnn.Backend preferredBackend, Dnn.Target preferredTarget, System.Net.DownloadProgressChangedEventHandler onDownloadProgressChanged = null) { if (_vehicleAttrRecognizerModel == null) { FileDownloadManager manager = new FileDownloadManager(); manager.AddFile( "https://storage.openvinotoolkit.org/repositories/open_model_zoo/2021.2/models_bin/3/vehicle-attributes-recognition-barrier-0042/FP32/vehicle-attributes-recognition-barrier-0042.xml", _modelFolderName, "9D1E877B153699CAF4547D08BFF7FE268F65B663441A42B929924B8D95DACDBB"); manager.AddFile( "https://storage.openvinotoolkit.org/repositories/open_model_zoo/2021.2/models_bin/3/vehicle-attributes-recognition-barrier-0042/FP32/vehicle-attributes-recognition-barrier-0042.bin", _modelFolderName, "492520E55F452223E767D54227D6EF6B60B0C1752DD7B9D747BE65D57B685A0E"); manager.OnDownloadProgressChanged += onDownloadProgressChanged; await manager.Download(); //_vehicleAttrRecognizer = // DnnInvoke.ReadNetFromModelOptimizer(manager.Files[0].LocalFile, manager.Files[1].LocalFile); _vehicleAttrRecognizerModel = new Model(manager.Files[1].LocalFile, manager.Files[0].LocalFile); _vehicleAttrRecognizerModel.SetInputSize(new Size(72, 72)); _vehicleAttrRecognizerModel.SetInputMean(new MCvScalar()); _vehicleAttrRecognizerModel.SetInputCrop(false); _vehicleAttrRecognizerModel.SetInputSwapRB(false); _vehicleAttrRecognizerModel.SetInputScale(1.0); _vehicleAttrRecognizerModel.SetPreferableBackend(preferredBackend); _vehicleAttrRecognizerModel.SetPreferableTarget(preferredTarget); } }
private async Task InitOCR(System.Net.DownloadProgressChangedEventHandler onDownloadProgressChanged = null) { if (_ocr == null) { FileDownloadManager manager = new FileDownloadManager(); manager.AddFile( "https://storage.openvinotoolkit.org/repositories/open_model_zoo/2021.2/models_bin/3/license-plate-recognition-barrier-0001/FP32/license-plate-recognition-barrier-0001.xml", _modelFolderName, "B5B649B9566F5CF352554ACFFD44207F4AECEE1DA767F4B69F46060A102623FA"); manager.AddFile( "https://storage.openvinotoolkit.org/repositories/open_model_zoo/2021.2/models_bin/3/license-plate-recognition-barrier-0001/FP32/license-plate-recognition-barrier-0001.bin", _modelFolderName, "685934518A930CC55D023A53AC2D5E47BBE81B80828354D8318DE6DC3AD5CFBA"); if (onDownloadProgressChanged != null) { manager.OnDownloadProgressChanged += onDownloadProgressChanged; } await manager.Download(); _ocr = DnnInvoke.ReadNetFromModelOptimizer(manager.Files[0].LocalFile, manager.Files[1].LocalFile); /* * if (Emgu.CV.Cuda.CudaInvoke.HasCuda) * { * _ocr.SetPreferableBackend(Emgu.CV.Dnn.Backend.Cuda); * _ocr.SetPreferableTarget(Emgu.CV.Dnn.Target.Cuda); * }*/ } }
Init(DownloadableFile modelFile = null, DownloadableFile labelFile = null ) { if (_session == null) { _downloadManager.Clear(); String defaultLocalSubfolder = "MaskRcnn"; if (modelFile == null) { modelFile = new DownloadableFile( "https://emgu-public.s3.amazonaws.com/mask_rcnn_inception_v2_coco_saved_model/mask_rcnn_inception_v2_coco_saved_model.zip", defaultLocalSubfolder, "4F043142473125E3758BCF9042AFF6F14C0C04A5D2273F20D1831A337176DAAC" ); } if (labelFile == null) { labelFile = new DownloadableFile( "https://emgu-public.s3.amazonaws.com/mask_rcnn_inception_v2_coco_saved_model/coco-labels-paper.txt", defaultLocalSubfolder, "8925173E1B0AABFAEFDA27DE2BB908233BB8FB6E7582323D72988E4BE15A5F0B" ); } _downloadManager.AddFile(modelFile); _downloadManager.AddFile(labelFile); #if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE yield return(_downloadManager.Download()); #else await _downloadManager.Download(); #endif if (_downloadManager.AllFilesDownloaded) { System.IO.FileInfo localZipFile = new System.IO.FileInfo(_downloadManager.Files[0].LocalFile); _savedModelDir = System.IO.Path.Combine(localZipFile.DirectoryName, "SavedModel"); if (!System.IO.Directory.Exists(_savedModelDir)) { System.IO.Directory.CreateDirectory(_savedModelDir); System.IO.Compression.ZipFile.ExtractToDirectory( localZipFile.FullName, _savedModelDir); } CreateSession(); } else { System.Diagnostics.Trace.WriteLine("Failed to download files"); } } }
private async Task InitOCR(Dnn.Backend preferredBackend, Dnn.Target preferredTarget, System.Net.DownloadProgressChangedEventHandler onDownloadProgressChanged = null) #endif { if (_ocr == null) { FileDownloadManager manager = new FileDownloadManager(); manager.AddFile( "https://storage.openvinotoolkit.org/repositories/open_model_zoo/2021.2/models_bin/3/license-plate-recognition-barrier-0001/FP32/license-plate-recognition-barrier-0001.xml", _modelFolderName, "B5B649B9566F5CF352554ACFFD44207F4AECEE1DA767F4B69F46060A102623FA"); manager.AddFile( "https://storage.openvinotoolkit.org/repositories/open_model_zoo/2021.2/models_bin/3/license-plate-recognition-barrier-0001/FP32/license-plate-recognition-barrier-0001.bin", _modelFolderName, "685934518A930CC55D023A53AC2D5E47BBE81B80828354D8318DE6DC3AD5CFBA"); if (onDownloadProgressChanged != null) { manager.OnDownloadProgressChanged += onDownloadProgressChanged; } #if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE || UNITY_WEBGL yield return(manager.Download()); #else await manager.Download(); #endif _ocr = DnnInvoke.ReadNetFromModelOptimizer(manager.Files[0].LocalFile, manager.Files[1].LocalFile); using (Mat seqInd = new Mat( new Size(1, 88), DepthType.Cv32F, 1)) { if (seqInd.Depth == DepthType.Cv32F) { float[] seqIndValues = new float[seqInd.Width * seqInd.Height]; for (int j = 1; j < seqIndValues.Length; j++) { seqIndValues[j] = 1.0f; } seqIndValues[0] = 0.0f; seqInd.SetTo(seqIndValues); } _ocr.SetInput(seqInd, "seq_ind"); } _ocr.SetPreferableBackend(preferredBackend); _ocr.SetPreferableTarget(preferredTarget); } }
public FaceDetectionPage() : base() { var button = this.GetButton(); button.Text = "Perform Face Detection"; button.Clicked += OnButtonClicked; OnImagesLoaded += async(sender, image) => { if (image == null || image[0] == null) { return; } SetMessage("Please wait..."); //SetImage(image[0]); SetImage(null); FileDownloadManager downloadManager = new FileDownloadManager(); String url = "https://github.com/opencv/opencv/raw/4.2.0/data/haarcascades/"; downloadManager.AddFile(url + "/haarcascade_frontalface_default.xml", "haarcascade"); downloadManager.AddFile(url + "/haarcascade_eye.xml", "haarcascade"); downloadManager.OnDownloadProgressChanged += DownloadManager_OnDownloadProgressChanged; await downloadManager.Download(); String faceFile = downloadManager.Files[0].LocalFile; String eyeFile = downloadManager.Files[1].LocalFile; long time; List <Rectangle> faces = new List <Rectangle>(); List <Rectangle> eyes = new List <Rectangle>(); using (UMat img = image[0].GetUMat(AccessType.ReadWrite)) DetectFace.Detect(img, faceFile, eyeFile, faces, eyes, out time); //Draw the faces in red foreach (Rectangle rect in faces) { CvInvoke.Rectangle(image[0], rect, new MCvScalar(0, 0, 255), 2); } //Draw the eyes in blue foreach (Rectangle rect in eyes) { CvInvoke.Rectangle(image[0], rect, new MCvScalar(255, 0, 0), 2); } String computeDevice = CvInvoke.UseOpenCL ? "OpenCL: " + Ocl.Device.Default.Name : "CPU"; SetMessage(String.Format("Detected with {1} in {0} milliseconds.", time, computeDevice)); SetImage(image[0]); }; }
/// <summary> /// Download and initialize the Mask Rcnn model /// </summary> /// <param name="onDownloadProgressChanged">Call back method during download</param> /// <returns>Asyn task</returns> public async Task Init( System.Net.DownloadProgressChangedEventHandler onDownloadProgressChanged = null) { if (_maskRcnnDetector == null) { FileDownloadManager manager = new FileDownloadManager(); manager.AddFile( "https://github.com/emgucv/models/raw/master/mask_rcnn_inception_v2_coco_2018_01_28/frozen_inference_graph.pb", _modelFolderName, "AC9B51CDE227B24D20030042E6C1E29AF75668F509E51AA84ED686787CCCC309"); manager.AddFile( "https://github.com/opencv/opencv_extra/raw/4.1.0/testdata/dnn/mask_rcnn_inception_v2_coco_2018_01_28.pbtxt", _modelFolderName, "090923144D81B2E442093F965BE27ECCDA11CE5F781EAF1C7EC76932CE99641E"); manager.AddFile( "https://github.com/emgucv/models/raw/master/mask_rcnn_inception_v2_coco_2018_01_28/coco-labels-paper.txt", _modelFolderName, "8925173E1B0AABFAEFDA27DE2BB908233BB8FB6E7582323D72988E4BE15A5F0B"); if (onDownloadProgressChanged != null) { manager.OnDownloadProgressChanged += onDownloadProgressChanged; } await manager.Download(); if (manager.AllFilesDownloaded) { _maskRcnnDetector = Emgu.CV.Dnn.DnnInvoke.ReadNetFromTensorflow(manager.Files[0].LocalFile, manager.Files[1].LocalFile); _labels = File.ReadAllLines(manager.Files[2].LocalFile); //prefer cuda backend if available foreach (BackendTargetPair p in DnnInvoke.AvailableBackends) { if (p.Backend == Dnn.Backend.Cuda && p.Target == Target.Cuda) { _maskRcnnDetector.SetPreferableBackend(Dnn.Backend.Cuda); _maskRcnnDetector.SetPreferableTarget(Target.Cuda); break; } } _colors = new MCvScalar[_labels.Length]; Random r = new Random(12345); for (int i = 0; i < _colors.Length; i++) { _colors[i] = new MCvScalar(r.Next(256), r.Next(256), r.Next(256)); } } } }
Init(DownloadableFile modelFile = null, DownloadableFile labelFile = null, String inputName = null, String outputName = null ) { if (_graph == null) { _inputName = inputName == null ? "input" : inputName; _outputName = outputName == null ? "output" : outputName; _downloadManager.Clear(); String defaultLocalSubfolder = "Inception"; if (modelFile == null) { modelFile = new DownloadableFile( "https://github.com/emgucv/models/raw/master/inception/tensorflow_inception_graph.pb", defaultLocalSubfolder, "A39B08B826C9D5A5532FF424C03A3A11A202967544E389ACA4B06C2BD8AEF63F" ); } if (labelFile == null) { labelFile = new DownloadableFile( "https://github.com/emgucv/models/raw/master/inception/imagenet_comp_graph_label_strings.txt", defaultLocalSubfolder, "DA2A31ECFE9F212AE8DD07379B11A74CB2D7A110EBA12C5FC8C862A65B8E6606" ); } _downloadManager.AddFile(modelFile); _downloadManager.AddFile(labelFile); #if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE yield return(_downloadManager.Download()); #else await _downloadManager.Download(); #endif if (_downloadManager.AllFilesDownloaded) { ImportGraph(); } else { System.Diagnostics.Trace.WriteLine("Failed to download files"); } } }
public async Task Init( System.Net.DownloadProgressChangedEventHandler onDownloadProgressChanged = null) #endif { if (_weChatQRCodeDetectionModel == null) { FileDownloadManager manager = new FileDownloadManager(); manager.AddFile( "https://github.com/WeChatCV/opencv_3rdparty/raw/wechat_qrcode/detect.prototxt", _modelFolderName, "E8ACFC395CAF443A47F15686A9B9207B36CB8F7E6CEB8FBAF6466665E68A9466"); manager.AddFile( "https://github.com/WeChatCV/opencv_3rdparty/raw/wechat_qrcode/detect.caffemodel", _modelFolderName, "CC49B8C9BABAF45F3037610FE499DF38C8819EBDA29E90CA9F2E33270F6EF809"); manager.AddFile( "https://github.com/WeChatCV/opencv_3rdparty/raw/wechat_qrcode/sr.prototxt", _modelFolderName, "8AE41ACBA97E8B4A8E741EE350481E49B8E01D787193F470A4C95EE1C02D5B61"); manager.AddFile( "https://github.com/WeChatCV/opencv_3rdparty/raw/wechat_qrcode/sr.caffemodel", _modelFolderName, "E5D36889D8E6EF2F1C1F515F807CEC03979320AC81792CD8FB927C31FD658AE3"); if (onDownloadProgressChanged != null) { manager.OnDownloadProgressChanged += onDownloadProgressChanged; } #if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE || UNITY_WEBGL yield return(manager.Download()); #else await manager.Download(); #endif if (manager.AllFilesDownloaded) { _weChatQRCodeDetectionModel = new WeChatQRCode( manager.Files[0].LocalFile, manager.Files[1].LocalFile, manager.Files[2].LocalFile, manager.Files[3].LocalFile ); } } }
private async Task InitTesseract(String lang, OcrEngineMode mode) { if (_ocr == null) { FileDownloadManager manager = new FileDownloadManager(); manager.AddFile(Emgu.CV.OCR.Tesseract.GetLangFileUrl(lang), _modelFolderName); manager.AddFile(Emgu.CV.OCR.Tesseract.GetLangFileUrl("osd"), _modelFolderName); //script orientation detection manager.OnDownloadProgressChanged += DownloadManager_OnDownloadProgressChanged; await manager.Download(); FileInfo fi = new FileInfo(manager.Files[0].LocalFile); _ocr = new Tesseract(fi.DirectoryName, lang, mode); } }
Init(String[] modelFiles = null, String downloadUrl = null, String localModelFolder = "MaskRcnn") { if (_graph == null) { _downloadManager.Clear(); String url = downloadUrl == null ? "https://github.com/emgucv/models/raw/master/mask_rcnn_inception_v2_coco_2018_01_28/" : downloadUrl; String[] fileNames = modelFiles == null ? new string[] { "frozen_inference_graph.pb", "coco-labels-paper.txt" } : modelFiles; for (int i = 0; i < fileNames.Length; i++) { _downloadManager.AddFile(url + fileNames[i], localModelFolder); } #if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE yield return(_downloadManager.Download()); #else await _downloadManager.Download(); ImportGraph(); #endif } }
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); * }*/ } } }
Init(String[] modelFiles = null, String downloadUrl = null, String inputName = null, String outputName = null, String localModelFolder = "Inception" ) { _inputName = inputName == null ? "input" : inputName; _outputName = outputName == null ? "output" : outputName; _downloadManager.Clear(); String url = downloadUrl == null ? "https://github.com/emgucv/models/raw/master/inception/" : downloadUrl; String[] fileNames = modelFiles == null ? new string[] { "tensorflow_inception_graph.pb", "imagenet_comp_graph_label_strings.txt" } : modelFiles; for (int i = 0; i < fileNames.Length; i++) { _downloadManager.AddFile(url + fileNames[i], localModelFolder); } #if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE yield return(_downloadManager.Download()); #else await _downloadManager.Download(); #endif ImportGraph(); }
Init( DownloadableFile modelFile = null) { if (_graph == null) { String defaultLocalSubfolder = "Stylize"; if (modelFile == null) { modelFile = new DownloadableFile( "https://github.com/emgucv/models/raw/master/stylize_v1/stylize_quantized.pb", defaultLocalSubfolder, "6753E2BFE7AA1D9FCFE01D8235E848C8201E54C6590423893C8124971E7C7DB0" ); } _downloadManager.Clear(); _downloadManager.AddFile(modelFile); #if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE yield return(_downloadManager.Download()); #else await _downloadManager.Download(); #endif if (_downloadManager.AllFilesDownloaded) { ImportGraph(); } else { System.Diagnostics.Trace.WriteLine("Failed to download files"); } } }
/// <summary> /// Download and initialize the facial landmark detector /// </summary> /// <param name="onDownloadProgressChanged">Callback when download progress has been changed</param> /// <returns>Async task</returns> public async Task Init(System.Net.DownloadProgressChangedEventHandler onDownloadProgressChanged = null) { if (_facemark == null) { FileDownloadManager manager = new FileDownloadManager(); manager.AddFile( "https://raw.githubusercontent.com/kurnianggoro/GSOC2017/master/data/lbfmodel.yaml", "facemark", "70DD8B1657C42D1595D6BD13D97D932877B3BED54A95D3C4733A0F740D1FD66B"); if (onDownloadProgressChanged != null) { manager.OnDownloadProgressChanged += onDownloadProgressChanged; } await manager.Download(); if (manager.AllFilesDownloaded) { using (FacemarkLBFParams facemarkParam = new CV.Face.FacemarkLBFParams()) { _facemark = new FacemarkLBF(facemarkParam); _facemark.LoadModel(manager.Files[0].LocalFile); } } } }
public async Task Init(System.Net.DownloadProgressChangedEventHandler onDownloadProgressChanged = null) #endif { if (_faceDetectionModel == null) { FileDownloadManager manager = new FileDownloadManager(); manager.AddFile( "https://github.com/opencv/opencv_3rdparty/raw/dnn_samples_face_detector_20170830/res10_300x300_ssd_iter_140000.caffemodel", _modelFolderName, "2A56A11A57A4A295956B0660B4A3D76BBDCA2206C4961CEA8EFE7D95C7CB2F2D"); manager.AddFile( "https://raw.githubusercontent.com/opencv/opencv/4.0.1/samples/dnn/face_detector/deploy.prototxt", _modelFolderName, "F62621CAC923D6F37BD669298C428BB7EE72233B5F8C3389BB893E35EBBCF795"); if (onDownloadProgressChanged != null) { manager.OnDownloadProgressChanged += onDownloadProgressChanged; } #if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE || UNITY_WEBGL yield return(manager.Download()); #else await manager.Download(); #endif if (manager.AllFilesDownloaded) { _faceDetectionModel = new DetectionModel(manager.Files[0].LocalFile, manager.Files[1].LocalFile); _faceDetectionModel.SetInputMean(new MCvScalar(104, 177, 123)); _faceDetectionModel.SetInputSize(new Size(300, 300)); _faceDetectionModel.SetInputSwapRB(false); _faceDetectionModel.SetInputScale(1.0); _faceDetectionModel.SetInputCrop(false); #if !(UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE || UNITY_WEBGL) if (Emgu.CV.Cuda.CudaInvoke.HasCuda) { _faceDetectionModel.SetPreferableBackend(Emgu.CV.Dnn.Backend.Cuda); _faceDetectionModel.SetPreferableTarget(Emgu.CV.Dnn.Target.Cuda); } #endif } } }
Init( DownloadableFile modelFile = null, DownloadableFile labelFile = null, String localModelFolder = "Multibox") { if (_graph == null) { //String defaultLocalSubfolder = "Multibox"; if (modelFile == null) { modelFile = new DownloadableFile( "https://github.com/emgucv/models/raw/master/mobile_multibox_v1a/multibox_model.pb", localModelFolder, "D1466DF5497E722E4A49E3839F667F07C579DD4C049258018E5F8EE9E01943A7" ); } if (labelFile == null) { labelFile = new DownloadableFile( "https://github.com/emgucv/models/raw/master/mobile_multibox_v1a/multibox_location_priors.txt", localModelFolder, "8742979FBAAAAB73CDDE4FAB55126AD78C6D9F84F310D8D51566BDF3F48F1E65" ); } _downloadManager.Clear(); _downloadManager.AddFile(modelFile); _downloadManager.AddFile(labelFile); #if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE yield return(_downloadManager.Download()); #else await _downloadManager.Download(); #endif if (_downloadManager.AllFilesDownloaded) { ImportGraph(); } else { System.Diagnostics.Trace.WriteLine("Failed to download files"); } } }
public void Init(String[] modelFiles = null, String downloadUrl = null) { _downloadManager.Clear(); String url = downloadUrl == null ? "https://github.com/emgucv/models/raw/master/stylize_v1/" : downloadUrl; String[] fileNames = modelFiles == null ? new string[] { "stylize_quantized.pb" } : modelFiles; for (int i = 0; i < fileNames.Length; i++) _downloadManager.AddFile(url + fileNames[i]); _downloadManager.Download(); }
private async Task InitTextRecognizer(System.Net.DownloadProgressChangedEventHandler onDownloadProgressChanged = null) #endif { if (_ocr == null) { FileDownloadManager manager = new FileDownloadManager(); manager.AddFile( "https://github.com/emgucv/models/raw/master/scene_text/crnn_cs_CN.onnx", _modelFolderName, "C760BF82D684B87DFABB288E6C0F92D41A8CD6C1780661CA2C3CD10C2065A9BA"); manager.AddFile( "https://github.com/emgucv/models/raw/master/scene_text/alphabet_3944.txt", _modelFolderName, "8027C9832D86764FECCD9BDD8974829C86994617E5787F178ED97DB2BDA1481A"); manager.OnDownloadProgressChanged += onDownloadProgressChanged; #if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE || UNITY_WEBGL yield return(manager.Download()); #else await manager.Download(); #endif if (manager.AllFilesDownloaded) { _ocr = new TextRecognitionModel(manager.Files[0].LocalFile); _ocr.DecodeType = "CTC-greedy"; String[] vocab = File.ReadAllLines(manager.Files[1].LocalFile); _ocr.Vocabulary = vocab; _ocr.SetInputScale(1.0 / 127.5); _ocr.SetInputMean(new MCvScalar(127.5, 127.5, 127.5)); _ocr.SetInputSize(new Size(100, 32)); /* * if (Emgu.CV.Cuda.CudaInvoke.HasCuda) * { * _vehicleAttrRecognizer.SetPreferableBackend(Emgu.CV.Dnn.Backend.Cuda); * _vehicleAttrRecognizer.SetPreferableTarget(Emgu.CV.Dnn.Target.Cuda); * }*/ } } }
Init( DownloadableFile modelFile = null, DownloadableFile labelFile = null) { _downloadManager.Clear(); String defaultLocalSubfolder = "Inception"; if (modelFile == null) { modelFile = new DownloadableFile( "https://github.com/emgucv/models/raw/master/inception_flower_retrain/optimized_graph.tflite", defaultLocalSubfolder, "9E4F5BF63CC7975EB17ECA1398C3046AC39451F462976750258CE7072BB0ECCD" ); } if (labelFile == null) { labelFile = new DownloadableFile( "https://github.com/emgucv/models/raw/master/inception_flower_retrain/output_labels.txt", defaultLocalSubfolder, "298454B11DBEE503F0303367F3714D449855071DF9ECAC16AB0A01A0A7377DB6" ); } _downloadManager.AddFile(modelFile); _downloadManager.AddFile(labelFile); #if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE yield return(_downloadManager.Download()); #else await _downloadManager.Download(); #endif if (_downloadManager.AllFilesDownloaded) { ImportGraph(); } else { System.Diagnostics.Trace.WriteLine("Failed to download all files"); } }
private async Task InitDetector() { if (_faceCascadeClassifier == null && _eyeCascadeClassifier == null) { FileDownloadManager downloadManager = new FileDownloadManager(); String url = "https://github.com/opencv/opencv/raw/4.2.0/data/haarcascades/"; downloadManager.AddFile(url + "/haarcascade_frontalface_default.xml", "haarcascade"); downloadManager.AddFile(url + "/haarcascade_eye.xml", "haarcascade"); downloadManager.OnDownloadProgressChanged += DownloadManager_OnDownloadProgressChanged; await downloadManager.Download(); String faceFile = downloadManager.Files[0].LocalFile; String eyeFile = downloadManager.Files[1].LocalFile; _faceCascadeClassifier = new CascadeClassifier(faceFile); _eyeCascadeClassifier = new CascadeClassifier(eyeFile); } }
/// <summary> /// Download and initialize the face and eye cascade classifier detection model /// </summary> /// <param name="onDownloadProgressChanged">Call back method during download</param> /// <returns>Asyn task</returns> public async Task Init(DownloadProgressChangedEventHandler onDownloadProgressChanged = null, Object initOptions = null) { if (_faceCascadeClassifier == null || _eyeCascadeClassifier == null) { FileDownloadManager downloadManager = new FileDownloadManager(); String url = "https://github.com/opencv/opencv/raw/4.2.0/data/haarcascades/"; downloadManager.AddFile(url + "/haarcascade_frontalface_default.xml", "haarcascade"); downloadManager.AddFile(url + "/haarcascade_eye.xml", "haarcascade"); downloadManager.OnDownloadProgressChanged += onDownloadProgressChanged; await downloadManager.Download(); String faceFile = downloadManager.Files[0].LocalFile; String eyeFile = downloadManager.Files[1].LocalFile; _faceCascadeClassifier = new CascadeClassifier(faceFile); _eyeCascadeClassifier = new CascadeClassifier(eyeFile); } }