赞
踩
.NET Core 3.1 SDK (v3.1.416) - Windows x64
scorer = new YoloScorer<YoloCocoP5Model>("Assets/Weights/yolov5s.onnx");
private void button1_Click(object sender, EventArgs e) { var image = Image.FromFile(@"Assets/test3.jpg"); DateTime T_start = DateTime.Now; List<YoloPrediction> predictions = scorer.Predict(image); var graphics = Graphics.FromImage(image); foreach (var prediction in predictions) // iterate predictions to draw results { double score = Math.Round(prediction.Score, 2); graphics.DrawRectangles(new Pen(prediction.Label.Color, 1), new[] { prediction.Rectangle }); var (x, y) = (prediction.Rectangle.X - 3, prediction.Rectangle.Y - 23); graphics.DrawString($"{prediction.Label.Name} ({score})", new Font("Arial", 16, GraphicsUnit.Pixel), new SolidBrush(prediction.Label.Color), new PointF(x, y)); } image.Save("Assets/result.jpg"); this.pictureBox1.Image = image; DateTime T_end = DateTime.Now; TimeSpan T_esp = T_end - T_start; this.label1.Text = T_esp.TotalMilliseconds.ToString(); }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。