Esempio n. 1
0
        public void DownloadFileAsync(string URL, string SaveFileFullName,
                                      System.Net.DownloadProgressChangedEventHandler client_DownloadProgressChanged,
                                      AsyncCompletedEventHandler client_DownloadFileCompleted)
        {
            if (File.Exists(SaveFileFullName))
            {
                File.Delete(SaveFileFullName);
            }
            string FilePath = SaveFileFullName.Substring(0, SaveFileFullName.LastIndexOf("\\"));

            if (!Directory.Exists(FilePath))
            {
                Directory.CreateDirectory(FilePath);
            }
            using (WebClient client = new WebClient())
            {
                client.DownloadProgressChanged += client_DownloadProgressChanged;
                client.DownloadFileCompleted   += client_DownloadFileCompleted;
                client.DownloadFileAsync(new Uri(URL), SaveFileFullName);
            }
        }
Esempio n. 2
0
        public async Task Init(
            System.Net.DownloadProgressChangedEventHandler onDownloadProgressChanged = null)
#endif
        {
            if (_barcodeDetector == null)
            {
                FileDownloadManager manager = new FileDownloadManager();

                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)
                {
                    _barcodeDetector = new BarcodeDetector(
                        manager.Files[0].LocalFile,
                        manager.Files[1].LocalFile
                        );
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Download and initialize the yolo model
        /// </summary>
        /// <param name="version">The model version</param>
        /// <param name="onDownloadProgressChanged">Call back method during download</param>
        /// <returns>Asyn task</returns>
        public async Task Init(
            YoloVersion version = YoloVersion.YoloV3,
            System.Net.DownloadProgressChangedEventHandler onDownloadProgressChanged = null)
        {
            if (_yoloDetectionModel == null)
            {
                FileDownloadManager manager = new FileDownloadManager();

                if (version == YoloVersion.YoloV3Spp)
                {
                    manager.AddFile(
                        "https://pjreddie.com/media/files/yolov3-spp.weights",
                        _modelFolderName,
                        "87A1E8C85C763316F34E428F2295E1DB9ED4ABCEC59DD9544F8052F50DE327B4");
                    manager.AddFile(
                        "https://github.com/pjreddie/darknet/raw/master/cfg/yolov3-spp.cfg",
                        _modelFolderName,
                        "7A4EC2D7427340FB12059F2B0EF76D6FCFCAC132CC287CBBF0BE5E3ABAA856FD");
                }
                else if (version == YoloVersion.YoloV3)
                {
                    manager.AddFile(
                        "https://pjreddie.com/media/files/yolov3.weights",
                        _modelFolderName,
                        "523E4E69E1D015393A1B0A441CEF1D9C7659E3EB2D7E15F793F060A21B32F297");
                    manager.AddFile(
                        "https://github.com/pjreddie/darknet/raw/master/cfg/yolov3.cfg",
                        _modelFolderName,
                        "22489EA38575DFA36C67A90048E8759576416A79D32DC11E15D2217777B9A953");
                }
                else if (version == YoloVersion.YoloV3Tiny)
                {
                    manager.AddFile(
                        "https://pjreddie.com/media/files/yolov3-tiny.weights",
                        _modelFolderName,
                        "DCCEA06F59B781EC1234DDF8D1E94B9519A97F4245748A7D4DB75D5B7080A42C");
                    manager.AddFile(
                        "https://github.com/pjreddie/darknet/raw/master/cfg/yolov3-tiny.cfg",
                        _modelFolderName,
                        "84EB7A675EF87C906019FF5A6E0EFFE275D175ADB75100DCB47F0727917DC2C7");
                }

                manager.AddFile("https://github.com/pjreddie/darknet/raw/master/data/coco.names",
                                _modelFolderName,
                                "634A1132EB33F8091D60F2C346ABABE8B905AE08387037AED883953B7329AF84");

                if (onDownloadProgressChanged != null)
                {
                    manager.OnDownloadProgressChanged += onDownloadProgressChanged;
                }
                await manager.Download();

                if (manager.AllFilesDownloaded)
                {
                    _yoloDetectionModel = new DetectionModel(manager.Files[0].LocalFile, manager.Files[1].LocalFile);
                    _yoloDetectionModel.SetInputSize(new Size(416, 416));
                    _yoloDetectionModel.SetInputScale(0.00392);
                    _yoloDetectionModel.SetInputMean(new MCvScalar());

                    _labels = File.ReadAllLines(manager.Files[2].LocalFile);
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Download and initialize the WeChatQRCode model
        /// </summary>
        /// <param name="onDownloadProgressChanged">Call back method during download</param>
        /// <returns>Asyn task</returns>
#if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE || UNITY_WEBGL
        public IEnumerator Init(
            System.Net.DownloadProgressChangedEventHandler onDownloadProgressChanged = null)
Esempio n. 5
0
        public async Task Init(
            YoloVersion version = YoloVersion.YoloV4,
            System.Net.DownloadProgressChangedEventHandler onDownloadProgressChanged = null)
#endif
        {
            if (_yoloDetectionModel == null)
            {
                FileDownloadManager manager = new FileDownloadManager();

                bool version3 = false;
                bool version4 = false;
                if (version == YoloVersion.YoloV3Spp)
                {
                    manager.AddFile(
                        "https://pjreddie.com/media/files/yolov3-spp.weights",
                        _modelFolderName,
                        "87A1E8C85C763316F34E428F2295E1DB9ED4ABCEC59DD9544F8052F50DE327B4");
                    manager.AddFile(
                        "https://github.com/pjreddie/darknet/raw/master/cfg/yolov3-spp.cfg",
                        _modelFolderName,
                        "7A4EC2D7427340FB12059F2B0EF76D6FCFCAC132CC287CBBF0BE5E3ABAA856FD");
                    version3 = true;
                }
                else if (version == YoloVersion.YoloV3)
                {
                    manager.AddFile(
                        "https://pjreddie.com/media/files/yolov3.weights",
                        _modelFolderName,
                        "523E4E69E1D015393A1B0A441CEF1D9C7659E3EB2D7E15F793F060A21B32F297");
                    manager.AddFile(
                        "https://github.com/pjreddie/darknet/raw/master/cfg/yolov3.cfg",
                        _modelFolderName,
                        "22489EA38575DFA36C67A90048E8759576416A79D32DC11E15D2217777B9A953");
                    version3 = true;
                }
                else if (version == YoloVersion.YoloV3Tiny)
                {
                    manager.AddFile(
                        "https://pjreddie.com/media/files/yolov3-tiny.weights",
                        _modelFolderName,
                        "DCCEA06F59B781EC1234DDF8D1E94B9519A97F4245748A7D4DB75D5B7080A42C");
                    manager.AddFile(
                        "https://github.com/pjreddie/darknet/raw/master/cfg/yolov3-tiny.cfg",
                        _modelFolderName,
                        "84EB7A675EF87C906019FF5A6E0EFFE275D175ADB75100DCB47F0727917DC2C7");
                    version3 = true;
                }
                else if (version == YoloVersion.YoloV4)
                {
                    manager.AddFile(
                        "https://github.com/aj-ames/YOLOv4-OpenCV-CUDA-DNN/raw/dd58dba457fff98e483e0f67113e0be1f17f2120/models/yolov4.weights",
                        _modelFolderName,
                        "8463FDE6EE7130A947A73104CE73C6FA88618A9D9ECD4A65D0B38F07E17EC4E4");
                    manager.AddFile(
                        "https://github.com/aj-ames/YOLOv4-OpenCV-CUDA-DNN/raw/dd58dba457fff98e483e0f67113e0be1f17f2120/models/yolov4.cfg",
                        _modelFolderName,
                        "A15524EC710005ADD4EB672140CF15CBFE46DEA0561F1AEA90CB1140B466073E");
                    version4 = true;
                }
                else if (version == YoloVersion.YoloV4Tiny)
                {
                    manager.AddFile(
                        "https://github.com/aj-ames/YOLOv4-OpenCV-CUDA-DNN/raw/dd58dba457fff98e483e0f67113e0be1f17f2120/models/yolov4-tiny.weights",
                        _modelFolderName,
                        "CF9FBFD0F6D4869B35762F56100F50ED05268084078805F0E7989EFE5BB8CA87");
                    manager.AddFile(
                        "https://github.com/aj-ames/YOLOv4-OpenCV-CUDA-DNN/raw/dd58dba457fff98e483e0f67113e0be1f17f2120/models/yolov4-tiny.cfg",
                        _modelFolderName,
                        "6CBF5ECE15235F66112E0BEDEBB324F37199B31AEE385B7E18F0BBFB536B258E");
                    version4 = true;
                }

                if (version3)
                {
                    manager.AddFile("https://github.com/pjreddie/darknet/raw/master/data/coco.names",
                                    _modelFolderName,
                                    "634A1132EB33F8091D60F2C346ABABE8B905AE08387037AED883953B7329AF84");
                }
                if (version4)
                {
                    manager.AddFile("https://github.com/aj-ames/YOLOv4-OpenCV-CUDA-DNN/raw/dd58dba457fff98e483e0f67113e0be1f17f2120/models/coco.names",
                                    _modelFolderName,
                                    "634A1132EB33F8091D60F2C346ABABE8B905AE08387037AED883953B7329AF84");
                }

                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)
                {
                    _yoloDetectionModel = new DetectionModel(manager.Files[0].LocalFile, manager.Files[1].LocalFile);
                    _yoloDetectionModel.SetInputSize(new Size(416, 416));
                    _yoloDetectionModel.SetInputScale(0.00392);
                    _yoloDetectionModel.SetInputMean(new MCvScalar());

                    _labels = File.ReadAllLines(manager.Files[2].LocalFile);
                }
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Download and initialize the yolo model
        /// </summary>
        /// <param name="version">The model version</param>
        /// <param name="onDownloadProgressChanged">Call back method during download</param>
        /// <returns>Asyn task</returns>
#if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE || UNITY_WEBGL
        public IEnumerator Init(
            YoloVersion version = YoloVersion.YoloV4,
            System.Net.DownloadProgressChangedEventHandler onDownloadProgressChanged = null)
Esempio n. 7
0
 public static bool DownloadFile(string url, string fullPathWhereToSave, System.Net.DownloadProgressChangedEventHandler downloadProgress, AsyncCompletedEventHandler downloadComplete)
 {
     return(new CbqDownloader(url, fullPathWhereToSave).StartDownload(0, downloadProgress, downloadComplete));
 }