Ask Your Question

Revision history [back]

OpenCv 3.0.0, how to patch

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: opencv-3.0.0/modules/videoio/include/opencv2/videoio/videoio_c.h opencv-3.0.0/modules/videoio/src/cap.cpp opencv-3.0.0/modules/videoio/src/precomp.hpp opencv-3.0.0/modules/videoio/src/cap_libv4l.cpp

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: opencv-3.0.0/modules/videoio/include/opencv2/videoio/videoio_c.h

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);


opencv-3.0.0/modules/videoio/src/cap.cpp

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(); }


opencv-3.0.0/modules/videoio/src/precomp.hpp

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


opencv-3.0.0/modules/videoio/src/cap_libv4l.cpp

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; }

OpenCv 3.0.0, how to patch

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: opencv-3.0.0/modules/videoio/include/opencv2/videoio/videoio_c.h opencv-3.0.0/modules/videoio/src/cap.cpp opencv-3.0.0/modules/videoio/src/precomp.hpp are:

opencv-3.0.0/modules/videoio/include/opencv2/videoio/videoio_c.h

opencv-3.0.0/modules/videoio/src/cap.cpp

opencv-3.0.0/modules/videoio/src/precomp.hpp

opencv-3.0.0/modules/videoio/src/cap_libv4l.cpp

The error is: 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: is:

opencv-3.0.0/modules/videoio/include/opencv2/videoio/videoio_c.h

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);


opencv-3.0.0/modules/videoio/src/cap.cpp

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(); }


opencv-3.0.0/modules/videoio/src/precomp.hpp

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


opencv-3.0.0/modules/videoio/src/cap_libv4l.cpp

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; }