From 2529af9719e1c0cf49f1e0604d025a68aa80ac5a Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Mon, 23 Sep 2024 08:32:09 +0300 Subject: [PATCH] Fixed code snippets in Yolo tutorial. --- doc/tutorials/dnn/dnn_yolo/dnn_yolo.markdown | 3 +-- samples/dnn/object_detection.cpp | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/tutorials/dnn/dnn_yolo/dnn_yolo.markdown b/doc/tutorials/dnn/dnn_yolo/dnn_yolo.markdown index 708873c40d..50f98e0e71 100644 --- a/doc/tutorials/dnn/dnn_yolo/dnn_yolo.markdown +++ b/doc/tutorials/dnn/dnn_yolo/dnn_yolo.markdown @@ -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 \ No newline at end of file +@snippet samples/dnn/object_detection.cpp draw_boxes diff --git a/samples/dnn/object_detection.cpp b/samples/dnn/object_detection.cpp index d20f49a9ee..64b14c72eb 100644 --- a/samples/dnn/object_detection.cpp +++ b/samples/dnn/object_detection.cpp @@ -294,9 +294,11 @@ int main(int argc, char** argv) if (asyncNumReq) { futureOutputs.push(net.forwardAsync()); } else { + //![forward] vector outs; net.forward(outs, net.getUnconnectedOutLayersNames()); predictionsQueue.push(outs); + //![forward] } } @@ -658,6 +660,7 @@ void postprocess(Mat& frame, const vector& outs, Net& net, int backend, vec void drawPred(vector& classIds, vector& confidences, vector& 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& classIds, vector& confidences, vector& 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*)