# YOLOV5-OPENCV **Repository Path**: ztty888/yolov5-opencv ## Basic Information - **Project Name**: YOLOV5-OPENCV - **Description**: yolov5-v7只用onnx做推理,环境只需要opencv3.3以上,若使用cuda加速,请使用opencv4.6。输入为图片 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 2 - **Created**: 2023-02-05 - **Last Updated**: 2023-02-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # YOLOV5-OpenCV 只使用opencv的dnn模块,实现yolov5-v7目标检测 OpenCV版本使用3.3以上,若使用CUDA请安装OpenCV4.6版本 必须安装opencv-contribut + 导出onnx模型需要将opset设置成12(原来默认的是13,在opencv下面会报错,原因未知)
+ 如果是torch1.12.x的版本,需要在 检测的输入为图像 ## 1.1 查看usb摄像头 ~~~sh ls /dev/video* ~~~ + 修改主函数`src/main.cpp`的摄像头参数 ~~~c cv::VideoCapture cap(0); ~~~ ## 1.2 修改参数config.txt 一般只需要修改2个参数 + isCuda=0 # 是否使用cuda + model_path # onnx模型路径 ~~~sh # box阈值 boxThreshold=0.25 # confidence自信度 classThreshold=0.25 # nms阈值 nmsThreshold=0.5 # input尺寸 height=480 width=640 #是否打印结果 cout_flag=1 #是否使用cuda,opencv4.6版本以上才支持 isCuda=0 # onnx模型路径 model_path=../weights/yolov5s.onnx ~~~ ## 1.3 编译 ~~~ mkdir build cd build cmake .. make ~~~ ## 1.4 运行 ~~~ ./main ~~~ ## 1.5结果显示 ![](weights/2022-12-07_17-52.png)