1.打開視覺計(jì)數(shù)包裝機(jī)圖像
OpenFileDialog openFile = new OpenFileDialog();
openFile.Filter = "jpg圖片|*.JPG|png圖片|*.PNG|jpeg圖片|*.JPEG";
openFile.Title = "打開圖像文件";
if (openFile.ShowDialog() == DialogResult.OK)
{
sw.Restart();
string mage = openFile.FileName;
imagein = Cv2.ImRead(mage);
imageout = yolov3_model(imagein);
pictureBox1.Image = imageout.ToBitmap();
label2.Text = "取圖" + sw.ElapsedMilliseconds.ToString("f2") + "ms";
}
}2.識別數(shù)量處理圖像
private Mat yo_model(Mat imgSrc)
{
Mat org = new Mat();
org = imgSrc;
const float threshold = 0.5f;
const float nmsThreshold = 0.3f;
var cfg = Path.Combine(Location1, Cfg);
var model = Path.Combine(Location1, Weight);
var net = CvDnn.ReadNetFromDarknet(cfg, model);
var blob = CvDnn.BlobFromImage(org, 1.0 / 255, new OpenCvSharp.Size(416, 416), new Scalar(), true, false);
net.SetInput(blob);
var outNames = net.GetUnconnectedOutLayersNames();
var outs = outNames.Select(_ => new Mat()).ToArray();
net.Forward(outs, outNames);
org = GetResult(outs, org, threshold, nmsThreshold);
GC.Collect();
return org;
繼續(xù)閱讀
點(diǎn)贊
登錄收藏 http://chaorenpin.cn/yolov%e8%ae%a1%e6%95%b0%e6%a3%80%e6%b5%8b%e6%ba%90%e7%a0%81%e4%b8%8b%e8%bd%bd/
復(fù)制鏈接
復(fù)制鏈接
我的微信
這是我的微信掃一掃
我的微信
微信號已復(fù)制
我的微信公眾號
我的微信公眾號掃一掃
我的公眾號
公眾號已復(fù)制
評論