Xavier Prudent
Xavier Prudent

Reputation: 1712

How to compile YOLOv3 with opencv?

I want to user YOLOv3 for object detection in videos on macOS 10.14.1 I hence installed opencv 4.0.1

brew install opencv

Changed the line

OPENCV=0

to

OPENCV=1

in the darknet makefile

I then specified the pkgconfig link

 export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

and recompiled

make

g++ -Iinclude/ -Isrc/ -DOPENCV `pkg-config --cflags opencv`  -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -DOPENCV -c ./src/image_opencv.cpp -o obj/image_opencv.o
Package opencv was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv.pc'
to the PKG_CONFIG_PATH environment variable
No package 'opencv' found
./src/image_opencv.cpp:5:10: fatal error: 'opencv2/opencv.hpp' file not found
#include "opencv2/opencv.hpp"

Should I understand YOLOv3 works with openCV 2.0 only?

Upvotes: 1

Views: 5920

Answers (3)

kadok
kadok

Reputation: 91

Using OpenCV 4, we need to modify the Makefile:

Modify pkg-config name from opencv to opencv4:

LDFLAGS+= `pkg-config --libs opencv4` -lstdc++
COMMON+= `pkg-config --cflags opencv4` 

Upvotes: 4

Pampapathi
Pampapathi

Reputation: 347

I have solved this by installing the opencv using following commands

> pip install opencv-python==4.1.1.26
> 
> sudo apt install libopencv-dev

Reference : https://github.com/pjreddie/darknet/issues/1886#issuecomment-548454746

Upvotes: 1

Xavier Prudent
Xavier Prudent

Reputation: 1712

I finally found out, YOLOv3 indeed needs opencv 2.0

you can find the version using

brew search opencv

and then

brew install opencv@2

the information will be displayed on how to update your links

YOLOV3 then compiles and runs as a charm.

(I will update the answer if things eventually go south...)

Upvotes: 1

Related Questions