1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 15:23:05 +04:00

Fixed code snippets in Yolo tutorial.

This commit is contained in:
Alexander Smorkalov
2024-09-23 08:32:09 +03:00
parent e823493af1
commit 2529af9719
2 changed files with 5 additions and 2 deletions
+1 -2
View File
@@ -232,7 +232,6 @@ module this is also quite easy to achieve. Below we will outline the sample impl
@snippet samples/dnn/object_detection.cpp preprocess_params
@snippet samples/dnn/object_detection.cpp preprocess_call
@snippet samples/dnn/object_detection.cpp preprocess_call_func
- Inference:
@@ -248,4 +247,4 @@ that NMS step is not included into onnx graph. Sample uses OpenCV function for i
- Draw predicted boxes
@snippet samples/dnn/object_detection.cpp draw_boxes
@snippet samples/dnn/object_detection.cpp draw_boxes
+4
View File
@@ -294,9 +294,11 @@ int main(int argc, char** argv)
if (asyncNumReq) {
futureOutputs.push(net.forwardAsync());
} else {
//![forward]
vector<Mat> outs;
net.forward(outs, net.getUnconnectedOutLayersNames());
predictionsQueue.push(outs);
//![forward]
}
}
@@ -658,6 +660,7 @@ void postprocess(Mat& frame, const vector<Mat>& outs, Net& net, int backend, vec
void drawPred(vector<int>& classIds, vector<float>& confidences, vector<Rect>& boxes, Mat& frame, FontFace& sans, int stdSize, int stdWeight, int stdImgSize, int stdThickness)
{
//![draw_boxes]
int imgWidth = max(frame.rows, frame.cols);
int size = (stdSize*imgWidth)/stdImgSize;
int weight = (stdWeight*imgWidth)/stdImgSize;
@@ -687,6 +690,7 @@ void drawPred(vector<int>& classIds, vector<float>& confidences, vector<Rect>& b
Point(left + labelSize.width, top), boxColor, FILLED);
putText(frame, label, Point(left, top-size/4), getTextColor(boxColor), sans, size, weight);
}
//![draw_boxes]
}
void callback(int pos, void*)