Пример #1
0
        private void button4_Click(object sender, EventArgs e)
        {
            if (filepath1 == null || filepath1 == "")
            {
                return;
            }
            viewlabel();
            var image   = File.ReadAllBytes(filepath1);
            var options = new Dictionary <string, object> {
                { "top_num", 3 },
                { "baike_num", 5 }
            };
            // 带参数调用车辆识别
            JObject       result     = client.CarDetect(image, options);
            var           resultlist = (JArray)(result["result"]);
            StringBuilder sb         = new StringBuilder("");

            foreach (var chars in resultlist)  //循环获取值
            {
                JObject jo = (JObject)chars;
                sb.Append("名字:" + Convert.ToString(jo["name"]) + "\n年限" + Convert.ToString(jo["year"]) + "\n");
                sb.Append("置信度:" + Convert.ToString(jo["score"]) + "\n\n\n");
            }
            richTextBox2.Text = sb.ToString();
            Status            = false;
            hidelabel();
        }
Пример #2
0
        private void CatDect()
        {
            MemoryStream ms = new MemoryStream();

            imgCar.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
            string base64 = Convert.ToBase64String(StreamToBytes(ms));  //ImgToBase64String(open.FileName);
            var    result = imageClassify.CarDetect(StreamToBytes(ms)); //Convert.FromBase64String(base64));

            txtCarResult.Text = result.ToString();
        }
Пример #3
0
        public static string DishDetect()
        {
            var     image  = File.ReadAllBytes("D:\\Code\\Android\\MsWeb\\MsWeb\\images\\car\\car1.jpg");
            JObject result = new JObject();
            // 调用车辆识别
            var options = new Dictionary <string, object>
            {
                { "top_num", 3 }
            };

            // 带参数调用车辆识别
            result = client.CarDetect(image, options);
            return(result.ToString());
        }
Пример #4
0
        public static JObject CarDetectDemo(byte[] image)
        {
            try
            {
                // 调用通用物体识别,可能会抛出网络等异常,请使用try/catch捕获
                //return _imageClient.CarDetect(image);
                // 如果有可选参数
                var options = new Dictionary <string, object> {
                    { "top_num", 3 },
                    { "baike_num", 5 }
                };
                // 带参数调用车辆识别

                return(_imageClient.CarDetect(image, options));
            }
            catch (AipException exp)
            {
                MessageBox.Show(exp.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(null);
        }