rico@deadsecuritylab:~/Desktop/darknet$ 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: No such file or directory
5 | #include "opencv2/opencv.hpp"
| ^~~~~~~~
compilation terminated.
make: * [Makefile:86: obj/image_opencv.o] Error 1
I"m having this issue as well
which opencv version are you using?
4.1.0
SOmeone suggested maybe theres a opencv version for C and another for python? IS that possible?
I use Opencv 4.0.0 I had that problem with 4.1.1. Newer versions on Opencv have bugs.
Follow this guys directions, but instead of master, use 4.0.0.
This is assuming you are using Ubuntu as your OS.
Hello friends, I have solved my problem in Ubuntu only by additionally installing the extra opencv package with the following command
sudo apt install libopencv-dev
let me know if it works for you
I tried using 4.0.0 and 3.4.7, same error.
If you have another version installed, uninstall the version you have and follow these steps:
Remember to have pip installed in ubuntu. I tried this on Ubuntu 18.04 - 64 Bits
pip install opencv-python == 4.1.1.26
and later
sudo apt install libopencv-dev
Hello friends, I have solved my problem in Ubuntu only by additionally installing the extra opencv package with the following command
sudo apt install libopencv-devlet me know if it works for you
this was a big saver for me!! thank you
Hello friends, I have solved my problem in Ubuntu only by additionally installing the extra opencv package with the following command
sudo apt install libopencv-devlet me know if it works for you
This was the solution for me. Thank you!
Im having the same issue , i installed libopencv-dev but still having make error
Hello friends, I have solved my problem in Ubuntu only by additionally installing the extra opencv package with the following command
sudo apt install libopencv-devlet me know if it works for you
@kevinjosue2326
I tried these instructions after installing jdk on my mac
it throws me this error:
Unable to locate an executable at "/Library/Java/JavaVirtualMachines/jdk-14.0.1.jdk/Contents/Home/bin/apt" (-1)
I am trying to run YOLO on my webcam. When I changed OPENCV = 1 in the Makefile and I am facing the same issue as @Ricftrw .
I am new to this, so kindly help me
@kesav-r , you have managed to solve your problem. if not let me know, to help you I would like to know what version of ubuntu you are using and if you are using Yolo in standard version or GPU version.??
Hello friends, I have solved my problem in Ubuntu only by additionally installing the extra opencv package with the following command
sudo apt install libopencv-dev
let me know if it works for you@kevinjosue2326
I tried these instructions after installing jdk on my mac
it throws me this error:Unable to locate an executable at "/Library/Java/JavaVirtualMachines/jdk-14.0.1.jdk/Contents/Home/bin/apt" (-1)
I am trying to run YOLO on my webcam. When I changed OPENCV = 1 in the Makefile and I am facing the same issue as @Ricftrw .
I am new to this, so kindly help me
Hey I have the same issue did you find out any solution?
Just inside of Makefile
change
ifeq ($(OPENCV), 1)
COMMON+= -DOPENCV
CFLAGS+= -DOPENCV
LDFLAGS+= `pkg-config --libs opencv` -lstdc++
COMMON+= `pkg-config --cflags opencv`
endif
to
ifeq ($(OPENCV), 1)
COMMON+= -DOPENCV
CFLAGS+= -DOPENCV
LDFLAGS+= `pkg-config --libs opencv4` -lstdc++
COMMON+= `pkg-config --cflags opencv4`
endif
after that you'll have this problem: ./src/image_opencv.cpp:12:1: error: ‘IplImage’ does not name a type; did you mean ‘image’?
but you can solve it using the solution https://github.com/pjreddie/darknet/issues/1347#issuecomment-472530377
in file ./src/image_opencv.cpp
add these two functions
Mat image_to_mat(image im)
{
image copy = copy_image(im);
constrain_image(copy);
if(im.c == 3) rgbgr_image(copy);
Mat m(cv::Size(im.w,im.h), CV_8UC(im.c));
int x,y,c;
int step = m.step;
for(y = 0; y < im.h; ++y){
for(x = 0; x < im.w; ++x){
for(c= 0; c < im.c; ++c){
float val = im.data[c*im.h*im.w + y*im.w + x];
m.data[y*step + x*im.c + c] = (unsigned char)(val*255);
}
}
}
free_image(copy);
return m;
}
image mat_to_image(Mat m)
{
int h = m.rows;
int w = m.cols;
int c = m.channels();
image im = make_image(w, h, c);
unsigned char *data = (unsigned char *)m.data;
int step = m.step;
int i, j, k;
for(i = 0; i < h; ++i){
for(k= 0; k < c; ++k){
for(j = 0; j < w; ++j){
im.data[k*w*h + i*w + j] = data[i*step + j*c + k]/255.;
}
}
}
rgbgr_image(im);
return im;
}
AFTER THAT REMOVE THESE THREE FUNCTIONS
/*
IplImage *image_to_ipl(image im)
{
int x,y,c;
IplImage *disp = cvCreateImage(cvSize(im.w,im.h), IPL_DEPTH_8U, im.c);
int step = disp->widthStep;
for(y = 0; y < im.h; ++y){
for(x = 0; x < im.w; ++x){
for(c= 0; c < im.c; ++c){
float val = im.data[c*im.h*im.w + y*im.w + x];
disp->imageData[y*step + x*im.c + c] = (unsigned char)(val*255);
}
}
}
return disp;
}
image ipl_to_image(IplImage* src)
{
int h = src->height;
int w = src->width;
int c = src->nChannels;
image im = make_image(w, h, c);
unsigned char *data = (unsigned char *)src->imageData;
int step = src->widthStep;
int i, j, k;
for(i = 0; i < h; ++i){
for(k= 0; k < c; ++k){
for(j = 0; j < w; ++j){
im.data[k*w*h + i*w + j] = data[i*step + j*c + k]/255.;
}
}
}
return im;
}
Mat image_to_mat(image im)
{
image copy = copy_image(im);
constrain_image(copy);
if(im.c == 3) rgbgr_image(copy);
IplImage *ipl = image_to_ipl(copy);
Mat m = cvarrToMat(ipl, true);
cvReleaseImage(&ipl);
free_image(copy);
return m;
}
image mat_to_image(Mat m)
{
IplImage ipl = m;
image im = ipl_to_image(&ipl);
rgbgr_image(im);
return im;
}*/
and remove all CV_ from opencv flags, for example:
if(w) cap->set(CV_CAP_PROP_FRAME_WIDTH, w);
if(h) cap->set(CV_CAP_PROP_FRAME_HEIGHT, w);
if(fps) cap->set(CV_CAP_PROP_FPS, w);
to
if(w) cap->set(CAP_PROP_FRAME_WIDTH, w);
if(h) cap->set(CAP_PROP_FRAME_HEIGHT, w);
if(fps) cap->set(CAP_PROP_FPS, w);
Hello friends, I have solved my problem in Ubuntu only by additionally installing the extra opencv package with the following command
sudo apt install libopencv-devlet me know if it works for you
It's very useful ,thanks
Hello friends, I have solved my problem in Ubuntu only by additionally installing the extra OpenCV package with the following command
sudo apt install libopencv-devlet me know if it works for you
I tried this but i am still getting the same issue. My OpenCV version is 4.2.0 and I have sent my PKG_CONFIG_PATH=/usr/include/opencv4/opencv2 which contains opencv.hpp. What should i do? should i change the path variable to /usr/local/lib which contains opencv.pc which i created as suggested here https://prateekvjoshi.com/2013/10/18/package-opencv-not-found-lets-find-it/
libopencv-dev is already to the newest version (4.2.0+dfsg-2).
@kesav-r , you have managed to solve your problem. if not let me know, to help you I would like to know what version of ubuntu you are using and if you are using Yolo in standard version or GPU version.??
A different user here, i was using Ubuntu 20.04 LTS however it is a VM
I am having the same issue and none of the solutions worked for me.
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
./src/image_opencv.cpp:5:10: fatal error: opencv2/opencv.hpp: No such file or directory
5 | #include "opencv2/opencv.hpp"
| ^~~~~~~~
compilation terminated.
make: * [Makefile:86: obj/image_opencv.o] Error 1
If you have another version installed, uninstall the version you have and follow these steps:
Remember to have pip installed in ubuntu. I tried this on Ubuntu 18.04 - 64 Bits
pip install opencv-python == 4.1.1.26and later
sudo apt install libopencv-dev
be useful for me
Just inside of Makefile
change
ifeq ($(OPENCV), 1) COMMON+= -DOPENCV CFLAGS+= -DOPENCV LDFLAGS+= `pkg-config --libs opencv` -lstdc++ COMMON+= `pkg-config --cflags opencv` endifto
ifeq ($(OPENCV), 1) COMMON+= -DOPENCV CFLAGS+= -DOPENCV LDFLAGS+= `pkg-config --libs opencv4` -lstdc++ COMMON+= `pkg-config --cflags opencv4` endifafter that you'll have this problem: ./src/image_opencv.cpp:12:1: error: ‘IplImage’ does not name a type; did you mean ‘image’?
but you can solve it using the solution #1347 (comment)
in file ./src/image_opencv.cpp
add these two functions
Mat image_to_mat(image im) { image copy = copy_image(im); constrain_image(copy); if(im.c == 3) rgbgr_image(copy); Mat m(cv::Size(im.w,im.h), CV_8UC(im.c)); int x,y,c; int step = m.step; for(y = 0; y < im.h; ++y){ for(x = 0; x < im.w; ++x){ for(c= 0; c < im.c; ++c){ float val = im.data[c*im.h*im.w + y*im.w + x]; m.data[y*step + x*im.c + c] = (unsigned char)(val*255); } } } free_image(copy); return m; } image mat_to_image(Mat m) { int h = m.rows; int w = m.cols; int c = m.channels(); image im = make_image(w, h, c); unsigned char *data = (unsigned char *)m.data; int step = m.step; int i, j, k; for(i = 0; i < h; ++i){ for(k= 0; k < c; ++k){ for(j = 0; j < w; ++j){ im.data[k*w*h + i*w + j] = data[i*step + j*c + k]/255.; } } } rgbgr_image(im); return im; }AFTER THAT REMOVE THESE THREE FUNCTIONS
/* IplImage *image_to_ipl(image im) { int x,y,c; IplImage *disp = cvCreateImage(cvSize(im.w,im.h), IPL_DEPTH_8U, im.c); int step = disp->widthStep; for(y = 0; y < im.h; ++y){ for(x = 0; x < im.w; ++x){ for(c= 0; c < im.c; ++c){ float val = im.data[c*im.h*im.w + y*im.w + x]; disp->imageData[y*step + x*im.c + c] = (unsigned char)(val*255); } } } return disp; } image ipl_to_image(IplImage* src) { int h = src->height; int w = src->width; int c = src->nChannels; image im = make_image(w, h, c); unsigned char *data = (unsigned char *)src->imageData; int step = src->widthStep; int i, j, k; for(i = 0; i < h; ++i){ for(k= 0; k < c; ++k){ for(j = 0; j < w; ++j){ im.data[k*w*h + i*w + j] = data[i*step + j*c + k]/255.; } } } return im; } Mat image_to_mat(image im) { image copy = copy_image(im); constrain_image(copy); if(im.c == 3) rgbgr_image(copy); IplImage *ipl = image_to_ipl(copy); Mat m = cvarrToMat(ipl, true); cvReleaseImage(&ipl); free_image(copy); return m; } image mat_to_image(Mat m) { IplImage ipl = m; image im = ipl_to_image(&ipl); rgbgr_image(im); return im; }*/and remove all CV_ from opencv flags, for example:
if(w) cap->set(CV_CAP_PROP_FRAME_WIDTH, w); if(h) cap->set(CV_CAP_PROP_FRAME_HEIGHT, w); if(fps) cap->set(CV_CAP_PROP_FPS, w);to
if(w) cap->set(CAP_PROP_FRAME_WIDTH, w); if(h) cap->set(CAP_PROP_FRAME_HEIGHT, w); if(fps) cap->set(CAP_PROP_FPS, w);
This one solved my problem.
On Ubuntu 20.04, CUDA 10.1
I have changed following things in the Mkefile.
from
LDFLAGS+= `pkg-config --libs opencv` -lstdc++
COMMON+= `pkg-config --cflags opencv`
to
LDFLAGS+= `pkg-config --libs opencv4` -lstdc++
COMMON+= `pkg-config --cflags opencv4`
Just inside of Makefile
changeifeq ($(OPENCV), 1) COMMON+= -DOPENCV CFLAGS+= -DOPENCV LDFLAGS+= `pkg-config --libs opencv` -lstdc++ COMMON+= `pkg-config --cflags opencv` endifto
ifeq ($(OPENCV), 1) COMMON+= -DOPENCV CFLAGS+= -DOPENCV LDFLAGS+= `pkg-config --libs opencv4` -lstdc++ COMMON+= `pkg-config --cflags opencv4` endifafter that you'll have this problem: ./src/image_opencv.cpp:12:1: error: ‘IplImage’ does not name a type; did you mean ‘image’?
but you can solve it using the solution #1347 (comment)
in file ./src/image_opencv.cpp
add these two functionsMat image_to_mat(image im) { image copy = copy_image(im); constrain_image(copy); if(im.c == 3) rgbgr_image(copy); Mat m(cv::Size(im.w,im.h), CV_8UC(im.c)); int x,y,c; int step = m.step; for(y = 0; y < im.h; ++y){ for(x = 0; x < im.w; ++x){ for(c= 0; c < im.c; ++c){ float val = im.data[c*im.h*im.w + y*im.w + x]; m.data[y*step + x*im.c + c] = (unsigned char)(val*255); } } } free_image(copy); return m; } image mat_to_image(Mat m) { int h = m.rows; int w = m.cols; int c = m.channels(); image im = make_image(w, h, c); unsigned char *data = (unsigned char *)m.data; int step = m.step; int i, j, k; for(i = 0; i < h; ++i){ for(k= 0; k < c; ++k){ for(j = 0; j < w; ++j){ im.data[k*w*h + i*w + j] = data[i*step + j*c + k]/255.; } } } rgbgr_image(im); return im; }AFTER THAT REMOVE THESE THREE FUNCTIONS
/* IplImage *image_to_ipl(image im) { int x,y,c; IplImage *disp = cvCreateImage(cvSize(im.w,im.h), IPL_DEPTH_8U, im.c); int step = disp->widthStep; for(y = 0; y < im.h; ++y){ for(x = 0; x < im.w; ++x){ for(c= 0; c < im.c; ++c){ float val = im.data[c*im.h*im.w + y*im.w + x]; disp->imageData[y*step + x*im.c + c] = (unsigned char)(val*255); } } } return disp; } image ipl_to_image(IplImage* src) { int h = src->height; int w = src->width; int c = src->nChannels; image im = make_image(w, h, c); unsigned char *data = (unsigned char *)src->imageData; int step = src->widthStep; int i, j, k; for(i = 0; i < h; ++i){ for(k= 0; k < c; ++k){ for(j = 0; j < w; ++j){ im.data[k*w*h + i*w + j] = data[i*step + j*c + k]/255.; } } } return im; } Mat image_to_mat(image im) { image copy = copy_image(im); constrain_image(copy); if(im.c == 3) rgbgr_image(copy); IplImage *ipl = image_to_ipl(copy); Mat m = cvarrToMat(ipl, true); cvReleaseImage(&ipl); free_image(copy); return m; } image mat_to_image(Mat m) { IplImage ipl = m; image im = ipl_to_image(&ipl); rgbgr_image(im); return im; }*/and remove all CV_ from opencv flags, for example:
if(w) cap->set(CV_CAP_PROP_FRAME_WIDTH, w); if(h) cap->set(CV_CAP_PROP_FRAME_HEIGHT, w); if(fps) cap->set(CV_CAP_PROP_FPS, w);to
if(w) cap->set(CAP_PROP_FRAME_WIDTH, w); if(h) cap->set(CAP_PROP_FRAME_HEIGHT, w); if(fps) cap->set(CAP_PROP_FPS, w);This one solved my problem.
On Ubuntu 20.04, CUDA 10.1I have changed following things in the Mkefile.
from
LDFLAGS+= `pkg-config --libs opencv` -lstdc++ COMMON+= `pkg-config --cflags opencv`
to
LDFLAGS+= `pkg-config --libs opencv4` -lstdc++ COMMON+= `pkg-config --cflags opencv4`
Can I also add
setWindowProperty(name, CV_WND_PROP_FULLSCREEN, CV_WINDOW_FULLSCREEN);
needs changing to
setWindowProperty(name, WND_PROP_FULLSCREEN, WINDOW_FULLSCREEN);
if anyone else finds this is also an error.
Most helpful comment
Hello friends, I have solved my problem in Ubuntu only by additionally installing the extra opencv package with the following command
sudo apt install libopencv-devlet me know if it works for you