Ask Your Question
0

OpenCv 3.0.0, how to patch

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

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

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

edit retag flag offensive close merge delete

Comments

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 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

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

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

Comments

1

Question Tools

1 follower

Stats

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

Seen: 725 times

Last updated: Jul 01 '15