yieniggu
yieniggu

Reputation: 404

Problem with yolo compilation when attempting to use webcam

I installed the yolov3 darknet and it works fine. The problem comes when I try to use the demo for webcam.

After changing the Makefila to OPENCV=1 and recompiling, I'm getting this output:

./src/image_opencv.cpp:12:1: error: ‘IplImage’ does not name a type; did you mean ‘image’?
 IplImage *image_to_ipl(image im)
 ^~~~~~~~
 image
compilation terminated due to -Wfatal-errors.
Makefile:86: recipe for target 'obj/image_opencv.o' failed
make: *** [obj/image_opencv.o] Error 1

I have installed OpenCV 4.1.2 as this command's output throws:

pkg-config --modversion opencv
4.1.2

However, in order for this to work I had to rename the opencv4.pc file on /usr/local/lib/pkfgconfig to opencv.pc

Aditionally, this is the output from

pkg-config --cflags opencv
-I/usr/local/include/opencv4/opencv -I/usr/local/include/opencv4

Any help would be much appreciated, thanks in advance!

Upvotes: 1

Views: 794

Answers (2)

kadok
kadok

Reputation: 91

In file src/image_opencv.cpp:

Add the include mentioned by @switchsyj

#include "opencv2/imgproc/imgproc_c.h"

Change the IplImage var declaration in mat_to_image function:

image mat_to_image(Mat m)
{
    //IplImage ipl = m;
    IplImage ipl = cvIplImage(m);
    image im = ipl_to_image(&ipl);
    rgbgr_image(im);
    return im;
}

And remove all the CV_ prefix from OPENCV constants in the following functions.

void *open_video_stream(const char *f, int c, int w, int h, int fps)
{
    VideoCapture *cap;
    if(f) cap = new VideoCapture(f);
    else cap = new VideoCapture(c);
    if(!cap->isOpened()) return 0;
    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);
    return (void *) cap;
}


void make_window(char *name, int w, int h, int fullscreen)
{
    namedWindow(name, WINDOW_NORMAL); 
    if (fullscreen) {
        setWindowProperty(name, WND_PROP_FULLSCREEN, WINDOW_FULLSCREEN);
    } else {
        resizeWindow(name, w, h);
        if(strcmp(name, "Demo") == 0) moveWindow(name, 0, 0);
    }
}

Upvotes: 2

switchsyj
switchsyj

Reputation: 63

I have solved this problem by adding:

#include "opencv2/imgproc/imgproc_c.h"

to image_opencv.cpp And this is considered as a different opencv4-opencv3

Upvotes: 1

Related Questions