opencv/doc
Abduragim Shtanchaev a8d1373919
Merge pull request #25794 from Abdurrahheem:ash/yolov10-support
Add sample support of YOLOv9 and YOLOv10 in OpenCV #25794

This PR adds sample support of  [`YOLOv9`](https://github.com/WongKinYiu/yolov9) and [`YOLOv10`](https://github.com/THU-MIG/yolov10/tree/main)) in OpenCV. Models for this test are located in this [PR](https://github.com/opencv/opencv_extra/pull/1186). 

**Running YOLOv10 using OpenCV.** 
1. In oder to run `YOLOv10` one needs to cut off postporcessing with dynamic shapes from torch and then convert it to ONNX. If someone is looking for ready solution, there is [this forked branch](https://github.com/Abdurrahheem/yolov10/tree/ash/opencv-export) from official YOLOv10.  Particularty follow this proceduce. 

```bash
git clone git@github.com:Abdurrahheem/yolov10.git
conda create -n yolov10 python=3.9
conda activate yolov10
pip install -r requirements.txt
python export_opencv.py --model=<model-name> --imgsz=<input-img-size>
```
By default `model="yolov10s"` and `imgsz=(480,640)`. This will generate file `yolov10s.onnx`, which can be use for inference in OpenCV

2. For inference part on OpenCV.  one can use `yolo_detector.cpp` [sample](https://github.com/opencv/opencv/blob/4.x/samples/dnn/yolo_detector.cpp). If you have followed above exporting procedure, then you can use following command to run the model. 

``` bash
build opencv from source 
cd build 
./bin/example_dnn_yolo_detector --model=<path-to-yolov10s.onnx-file> --yolo=yolov10 --width=640 --height=480 --input=<path-to-image> --scale=0.003921568627 --padvalue=114
```
If you do not specify `--input` argument, OpenCV will grab first camera that is avaliable on your platform. 
For more deatils on how to run the `yolo_detector.cpp` file see this [guide](https://docs.opencv.org/4.x/da/d9d/tutorial_dnn_yolo.html#autotoc_md443) 


**Running YOLOv9 using OpenCV**

1. Export model following [official guide](https://github.com/WongKinYiu/yolov9)of the YOLOv9 repository. Particularly you can do following for converting.

```bash
git clone https://github.com/WongKinYiu/yolov9.git
cd yolov9
conda create -n yolov9 python=3.9
conda activate yolov9
pip install -r requirements.txt
wget https://github.com/WongKinYiu/yolov9/releases/download/v0.1/yolov9-t-converted.pt
python export.py --weights=./yolov9-t-converted.pt --include=onnx --img-size=(480,640) 
```

This will generate <yolov9-t-converted.onnx> file.

2.  Inference on OpenCV.

```bash
build opencv from source 
cd build 
./bin/example_dnn_yolo_detector --model=<path-to-yolov9-t-converted.onnx> --yolo=yolov9 --width=640 --height=480 --scale=0.003921568627 --padvalue=114 --path=<path-to-image>
```

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [x] There is a reference to the original bug report and related work
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [x] The feature is well documented and sample code can be built with the project CMake
2024-07-02 18:26:34 +03:00
..
images Assorted documentation fixes 2019-08-31 01:50:11 +03:00
js_tutorials Fixing code example on 2024-04-09 16:06:08 -03:00
pattern_tools Svgfig library update to version 1.0.1 as it uses BSD-3 license. 2024-06-18 11:13:32 +03:00
py_tutorials Replace use of "eval()" with "getattr()". 2024-06-22 17:53:47 +02:00
tools Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2021-04-15 20:50:26 +00:00
tutorials Merge pull request #25794 from Abdurrahheem:ash/yolov10-support 2024-07-02 18:26:34 +03:00
acircles_pattern.png Update chessboard pattern image to remove squares overlap. Update also asymmetric pattern image. 2018-03-15 13:22:56 +01:00
bodybg.png Some documentation customization 2014-12-26 19:17:18 +03:00
charuco_board_pattern.png Merge pull request #23363 from vovka643:4.x_generate_charuco 2023-05-19 20:25:59 +03:00
CMakeLists.txt doc: fix formulas in JavaDoc broken after Doxygen upgrade 2024-03-11 23:47:23 +03:00
disabled_doc_warnings.txt Doxygen documentation: BiB references and fixes 2014-12-01 15:50:55 +03:00
Doxyfile.in doc: disabled inheritance graphs 2024-05-03 22:09:33 +03:00
DoxygenLayout.xml docs: move detail section of group to the top of the page 2024-02-19 08:13:22 +00:00
faq.markdown Migrated FAQ page to Github Wiki 2020-04-08 13:55:44 +03:00
footer.html Merge pull request #10621 from mshabunin:disable-docs 2018-01-18 16:37:19 +03:00
header.html Merge pull request #10621 from mshabunin:disable-docs 2018-01-18 16:37:19 +03:00
LICENSE_BSD.txt Merge pull request #18073 from vpisarev:apache2_license 2020-08-17 11:49:11 +00:00
LICENSE_CHANGE_NOTICE.txt Merge pull request #24521 from dkurt:fix_broken_urls 2023-11-11 09:06:10 +03:00
mymath.js doc: fix formulas in JavaDoc broken after Doxygen upgrade 2024-03-11 23:47:23 +03:00
mymath.sty Use camera intrinsic matrix everywhere. Add cameramatrix, distcoeffs and distcoeffsfisheye macros to avoid copy/paste errors. 2020-08-24 05:39:23 +02:00
opencv-logo2.png Updated the OpenCV logo 2020-07-28 18:31:21 +03:00
opencv-logo-small.png Updated the OpenCV logo 2020-07-28 18:31:21 +03:00
opencv-logo-white.png Updated the OpenCV logo 2020-07-28 18:31:21 +03:00
opencv-logo.md Added a note about OpenCV logo 2020-08-21 11:18:40 +03:00
opencv-logo.png Updated the OpenCV logo 2020-07-28 18:31:21 +03:00
opencv.bib Update usac tutorial. 2023-11-08 12:53:20 +03:00
opencv.ico Updated the OpenCV logo 2020-07-28 18:31:21 +03:00
opencv.jpg
pattern.png Update chessboard pattern image to remove squares overlap. Update also asymmetric pattern image. 2018-03-15 13:22:56 +01:00
root.markdown.in Merge pull request #9466 from huningxin:js 2017-09-25 16:52:07 +03:00
stylesheet.css Merge pull request #18195 from mshabunin:linux-tutorial 2020-10-07 21:35:06 +00:00
tutorial-utils.js doc: fix toggle buttons in some tutorials 2024-03-15 01:16:12 +03:00