Ask Your Question

OpenCv 3.0.0, how to patch

asked 2015-07-01 08:04:07 -0500

updated 2015-07-01 08:05:19 -0500

A long time ago I have uploaded a patch for OpenCv, to change input of a 4 inputs capture card but none have replied to me... But this is another problem. Now I have patched OpenCv to change input channel. The compilation ends correctly but, when I tried to compile my program, I have a problem with linking.

The patched files are:





The error is:

qthvideointerface.cpp:(.text+0x8fc): undefined reference to `cvSetChannel' collect2: error: ld returned 1 exit status make: * [ComputerVisionStudio] Error 1 14:58:34: The process "/usr/bin/make" exited with code 2. Error while building/deploying project ComputerVisionStudio (kit: Desktop Qt 5.4.2 GCC 32bit) When executing step "Make" 14:58:34: Elapsed time: 00:04.

The patch is:


CVAPI(double) cvGetCaptureProperty( CvCapture* capture, int property_id );
CVAPI(int)    cvSetCaptureProperty( CvCapture* capture, int property_id, double value );

bool cvSetChannel(CvCapture* capture, int index); int cvGetChannel(CvCapture* capture);


CV_IMPL int cvSetCaptureProperty( CvCapture* capture, int id, double value )
    return capture ? capture->setProperty(id, value) : 0;

CV_IMPL int cvGetCaptureDomain( CvCapture* capture)
    return capture ? capture->getCaptureDomain() : 0;

bool cvSetChannel(CvCapture* capture, int index) { return capture->cvSetChannel(index); }

int cvGetChannel(CvCapture* capture) { return capture->cvGetChannel(); }


struct CvCapture virtual bool cvSetChannel(int) { return false; } virtual int cvGetChannel() { return -1; }


class CvCaptureCAM_V4L_CPP : CvCapture virtual bool cvSetChannel(int); virtual int cvGetChannel();

bool CvCaptureCAM_V4L_CPP::cvSetChannel(int index) { if (ioctl(captureV4L->deviceHandle, VIDIOC_S_INPUT, &index) < 0) { perror ("Unable to set channel."); } else return true; return false; }

int CvCaptureCAM_V4L_CPP::cvGetChannel() { int index; if (ioctl(captureV4L->deviceHandle, VIDIOC_G_INPUT, &index) < 0) { perror ("Unable to get channel."); } else return index; return -1; }

edit retag flag offensive close merge delete


If you want help in patching OpenCV, then please provide a PULL request. The bot testing system allows users to carefully analyze what is going wrong using the OpenCV provided unit tests. Then add the PR link right here.

StevenPuttemans gravatar imageStevenPuttemans ( 2015-07-01 08:22:57 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2015-07-01 09:24:03 -0500

Solved by including the .o files directly:

    LIBS += /home/denis/Cpp/opencv-3.0.0/modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap.cpp.o
    LIBS += /home/denis/Cpp/opencv-3.0.0/modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_libv4l.cpp.o
    LIBS += /home/denis/Cpp/opencv-3.0.0/modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_gstreamer.cpp.o
    LIBS += /home/denis/Cpp/opencv-3.0.0/modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_images.cpp.o
    LIBS += /home/denis/Cpp/opencv-3.0.0/modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_mjpeg_decoder.cpp.o
    LIBS += /home/denis/Cpp/opencv-3.0.0/modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_mjpeg_encoder.cpp.o

Is there a way to have my function in the videoio library?

edit flag offensive delete link more



Question Tools

1 follower


Asked: 2015-07-01 08:04:07 -0500

Seen: 397 times

Last updated: Jul 01 '15