public static IComputerVision CreateVisionClass(VisionAPIType type, AnalyzeOptions opt)
        {
            IComputerVision res = null;

            switch (type)
            {
            case VisionAPIType.AzureVisionAnalyze: res = new AzureVisionAnalyze(opt); break;

            case VisionAPIType.BaiduAnimalAnalyze: res = new BaiduVisionAnalyze(opt); break;

            case VisionAPIType.BaiduEasyDL: res = new BaiduEazyDL(opt); break;
            }

            return(res);
        }
Пример #2
0
        private async void BaiduAnalyzeImage(string path)
        {
            var watch = System.Diagnostics.Stopwatch.StartNew();

            BaiduVisionAnalyze ana = new BaiduVisionAnalyze();

            ana.Key  = "vKHUR4T6BMeO3yTVwW3nR1NN";
            ana.SKey = "u8A17o87RD7Q35lU8qQKjxrDs1bguBrD";


            Task <BaiduAnalyzeResult> resTask = ana.UploadAndAnalyzeImage(path);
            BaiduAnalyzeResult        res     = await resTask;

            //watch end
            watch.Stop();
            var elapsedMs = watch.ElapsedMilliseconds;

            //write result
            this.richTextBox1.Text  = $"is animal:{res.IsAnimal()}\n";
            this.richTextBox1.Text += $"run with {imageListView1.SelectedItems[0].FileName}\n";
            this.richTextBox1.Text += $"used {elapsedMs} ms\n";
            this.richTextBox1.Text += VisCommonClass.JsonPrettyPrint(JsonConvert.SerializeObject(res));
            MessageBox.Show($"cost {elapsedMs}ms");
        }