1、环境

Make sure you have already on your system:

  • Any modern Linux OS (tested on Ubuntu 20.04)
  • OpenCV 4.5.4+
  • Python 3.7+ (only if you are intended to run the python program)
  • GCC 9.0+ (only if you are intended to run the C++ program)

IMPORTANT!!! Note that OpenCV versions prior to 4.5.4 will not work at all.

2、Running the python script

git clone https://github.com/doleron/yolov5-opencv-cpp-python.git
cd yolov5-opencv-cpp-python
python python/yolo.py 

如果你的机器/OpenCV安装有CUDA功能,你可以尝试使用GPU运行:

git clone https://github.com/doleron/yolov5-opencv-cpp-python.git
cd yolov5-opencv-cpp-python
python python/yolo.py cuda

问题:

linux OpenCV(4.4.0) /tmp/pip-build-z1z9fpzr/opencv-python/opencv/modules/highgui/

 If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvShowImage'

解决办法:


pip3 install opencv-contrib-python

 

3、Running the C++ program

git clone https://github.com/doleron/yolov5-opencv-cpp-python.git
cd yolov5-opencv-cpp-python
g++ -O3 cpp/yolo.cpp -o yolo_example `pkg-config --cflags --libs opencv4`
./yolo_example
Or using CUDA if available:

git clone https://github.com/doleron/yolov5-opencv-cpp-python.git
cd yolov5-opencv-cpp-python
g++ -O3 cpp/yolo.cpp -o yolo_example `pkg-config --cflags --libs opencv4`
./yolo_example cuda

Logo

更多推荐