Runtime Opencv HighGui Error- "HIGHGUI ERROR: V4L/V4L2: VIDIOC_S_CROP". Opencv cross compiled. Host=64bit Ubuntu 12.04. Target=ARM-Cortex-A9

om9 picture om9 · Apr 29, 2013 · Viewed 25k times · Source

I am a beginner at OpenCV and trying my best to get a simple application running on an embedded platform. I cross-compiled OpenCV 2.4.4 and built it WITH_GTK=ON, WITH_UNICAP=ON, WITH_V4L=ON as needed for camera and GUI support. The following sample code cross-compiles on host:

#include <opencv/cv.h>
#include <opencv/highgui.h>
using namespace cv; 
int main(int, char**)
{
    VideoCapture cap(0); // open the default camera
    if (!cap.isOpened()) // check if we succeeded
        return -1;

    Mat edges;
    namedWindow("edges", 1);
    for (;;) {
        Mat frame;
        cap >> frame;   // get a new frame from camera
        cvtColor(frame, edges, CV_BGR2GRAY);
        GaussianBlur(edges, edges, Size(7, 7), 1.5, 1.5);
        Canny(edges, edges, 0, 30, 3);
        imshow("edges", edges);
        if (waitKey(30) >= 0)
            break;
    }
    return 0;
}

Compiling this way for static linking:

arm-linux-gnueabi-g++ -mcpu=cortex-a9 -mfpu=neon -static opencv_camshow.cpp -o exe -I/home/om/OpenCV-2.4.4/platforms/linux/build_soft/install/include -L/home/om/OpenCV-2.4.4/platforms/linux/build_soft/install/lib -L/home/om/OpenCV-2.4.4/platforms/linux/build_soft/3rdparty/lib -lopencv_calib3d -lopencv_features2d -lopencv_flann -lopencv_imgproc -lopencv_core -lopencv_contrib -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_flann -lopencv_photo -lopencv_videostab -pthread -lm -lrt -lzlib -static

Here is the problem. When I try to run the executable file 'exe' on the target, I get this runtime error:

HIGHGUI ERROR: V4L/V4L2: VIDIOC_S_CROP OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvNamedWindow, file /home/om/OpenCV-2.4.4/modules/highgui/src/window.cpp, line 652

terminate called after throwing an instance of 'cv::Exception'

what(): /home/om/OpenCV-2.4.4/modules/highgui/src/window.cpp:652: error: (-2) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function cvNamedWindow

I re-installed libgtk2.0-dev, pkg-config exists & re-compiled OpenCV , but this hasn't helped. Please let me know if someone knows how to overcome this issue. Thanks in advance. ~Om

More info: I figured out what is causing this problem but not yet fixed it...

From my understanding the problem lies in the cmake scripts of opencv. It does not acknowledge existence of GTK and hence cross compiles with no gtk support. This after making sure that the arm-based gtk library is present in the toolchain's lib folder and its path exported to system paths.

Answer

Varun Kumar picture Varun Kumar · Sep 18, 2014

After doing the cmake statement Verify whether the output of cmake includes the following text: V4L/V4L2: Using libv4l.

If it is not there, then install v4l2ucp, v4l-utils and libv4l-dev from synaptic package manager. Then cmake and build again.

This worked for me but I was using OpenCV with python bindings on Ubuntu 12.04.