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

匿名 (未验证) 提交于 2019-12-03 02:06:01

问题:

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  #include  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.

回答1:

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.



回答2:

In order to cross compile you need to tell pkg-config to lookup the proper path (by default this will be your host config/.pc files!)

From pkg-config website

  • searching directories listed in $PKG_CONFIG_PATH
  • when $PKG_CONFIG_LIBDIR is specified, it will override the compiled in default directory (e.g. /usr/lib/pkgconfig) and the PKG_CONFIG_PATH. Note that when specifying PKG_CONFIG_LIBDIR, pkg-config will completely ignore the content in PKG_CONFIG_PATH, even if the documentation states different things.


回答3:

Opencv highgui error

Have to reinstall opencv using cmake

git clone https://github.com/Itseez/opencv.git cd ~/opencv  mkdir release  cd release  cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_IPP=OFF .. make -j4 sudo  make install export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python2.7/site-packages


易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!