Issue
I am trying to use Darkent with OpenCV and CUDA. I installed darknet according to these instructions:
https://pjreddie.com/darknet/install/
I installed CUDA according to these instructions:
https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html
Finally, I installed OpenCV according to these instructions:
http://www.linuxfromscratch.org/blfs/view/svn/general/opencv.html
I then added the following lines to the end of my bashrc:
export PATH=$PATH:/usr/local/cuda-11.1/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-11.1/lib64:/usr/include/opencv4
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig:/usr/include/opencv4
I was then having trouble with darknet finding the opencv library, so I added an opencv.pc file at /usr/local/lib/pkgconfig, with the following content:
prefix=/usr
exec_prefix=${prefix}
libdir=${prefix}/lib/x86_64-linux-gnu
includedir_new=${prefix}/include/opencv4
Name: OpenCV
Description: Open Source Computer Vision Library
Version: 4.5.0
Libs: -L${libdir} -lopencv_dnn -lopencv_ml -lopencv_objdetect -lopencv_shape -lopencv_stitching -lopencv_superres -lopencv_videostab -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_video -lopencv_photo -lopencv_imgproc -lopencv_flann -lopencv_core
Libs.private: -ldl -lm -lpthread -lrt
Cflags: -I${includedir_new}
Next, I modified the Makefile in the darknet directory such that GPU=1, and OPENCV=1. I ran make
, but am encountering the error:
./src/image_opencv.cpp:12:1: error: ‘IplImage’ does not name a type
12 | IplImage *image_to_ipl(image im)
| ^~~~~~~~
compilation terminated due to -Wfatal-errors.
Any help would be greatly appreciated. I am running ubuntu 20.04, kernel 5.4.0-53-generic.
Solution
It seems there are some missing header lines in file /src/image_opencv.cpp
, add these lines at the beginning than make it again.
#include "opencv2/core/core_c.h"
#include "opencv2/videoio/legacy/constants_c.h"
#include "opencv2/highgui/highgui_c.h"
Additionally, you have to change the line IplImage ipl = m
to IplImage ipl = cvIplImage(m);
in the same file.
Answered By - AbdelAziz AbdelLatef