In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
< 3; n++) ///尺度 { int num_grid_x = (int)(this->InpWidth / this- > stride [n]; int num_grid_y = (int) (this- > inpHeight / this- > stride [n]); int area = num_grid_x * num_grid_y; this- > sigmoid (& outs [n], 3 * nout * area); for (Q = 0; Q
< 3; q++) ///anchor数 { const float anchor_w = this->Anchors [n] [Q * 2]; const float anchor_h = this- > anchors [n] [Q * 2 + 1]; float* pdata = (float*) outlets [n] .data + Q * nout * area; for (I = 0; I
< num_grid_y; i++) { for (j = 0; j < num_grid_x; j++) { float box_score = pdata[4 * area + i * num_grid_x + j]; if (box_score >This- > objThreshold) {float max_class_socre = 0, class_socre = 0; int max_class_id = 0; for (c = 0; c
< 80; c++) get max socre { class_socre = pdata[(c + 5) * area + i * num_grid_x + j]; if (class_socre >Max_class_socre) {max_class_socre = class_socre; max_class_id = c }} if (max_class_socre > this- > confThreshold) {float cx = (pdata [I * num_grid_x + j] * 2.f-0.5f + j) * this- > stride [n] / cx float cy = (pdata [area + I * num_grid_x + j] * 2.f-0.5f + I) * this- > stride [n]; / / cy float w = powf (pdata [2 * area + I * num_grid_x + j] * 2.f, 2.f) * anchor_w / w float h = powf (pdata [3 * area + I * num_grid_x + j] * 2.f, 2.f) * anchor_h; / h int left = (cx-0.5000w) * ratiow; int top = (cy-0.5shouh) * ratioh / / restore the coordinates to the original image classIds.push_back (max_class_id); confidences.push_back (max_class_socre); boxes.push_back (Rect (left, top, (int) (w*ratiow), (int) (h*ratioh) }} / / Perform non maximum suppression to eliminate redundant overlapping boxes with / / lower confidences vector indices; cv::dnn::NMSBoxes (boxes, confidences, this- > confThreshold, this- > nmsThreshold, indices); for (size_t I = 0; I
< indices.size(); ++i) { int idx = indices[i]; Rect box = boxes[idx]; this->DrawPred (classIds [idx], confidences [idx], box.x, box.y, box.x + box.width, box.y + box.height, frame);} void YOLOV5::drawPred (int classId, float conf, int left, int top, int right, int bottom, Mat & frame) {rectangle (frame, Point (left, top), Point (right, bottom), Scalar (0,0,255), 3); string label = format ("% .2f", conf) Label = this- > classes [classId] + ":" + label; int baseLine; Size labelSize = getTextSize (label, FONT_HERSHEY_SIMPLEX, 0.5,1, & baseLine); top = max (top, labelSize.height); putText (frame, label, Point (left, top), FONT_HERSHEY_SIMPLEX, 0.75, Scalar (0,255,0), 1);} void YOLOV5::sigmoid (Mat * out, int length) {float* pdata = (float*) (out- > data) Int I = 0; for (I = 0; I
< length; i++) { pdata[i] = 1.0 / (1 + expf(-pdata[i])); }}三、效果演示At this point, I believe you have a deeper understanding of "how to deploy yolov5 with Qt and OpenCV". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.