运行时 Opencv HighGui 错误-“HIGHGUI 错误:V4L/V4L2:VIDIOC_S_CROP".Opencv 交叉编译.主机 = 64 位 Ubuntu 12.04.目标=ARM-Cortex-A9 [英] Runtime Opencv HighGui Error- "HIGHGUI ERROR: V4L/V4L2: VIDIOC_S_CROP". Opencv cross compiled. Host=64bit Ubuntu 12.04. Target=ARM-Cortex-A9

查看:49
本文介绍了运行时 Opencv HighGui 错误-“HIGHGUI 错误:V4L/V4L2:VIDIOC_S_CROP".Opencv 交叉编译.主机 = 64 位 Ubuntu 12.04.目标=ARM-Cortex-A9的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 OpenCV 的初学者,并尽我所能在嵌入式平台上运行一个简单的应用程序.我交叉编译了 OpenCV 2.4.4 并根据相机和 GUI 支持的需要构建了 WITH_GTK=ON、WITH_UNICAP=ON、WITH_V4L=ON.以下示例代码在主机上交叉编译:

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

以这种方式编译用于静态链接:

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

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

问题来了.当我尝试在目标上运行可执行文件exe"时,出现此运行时错误:

HIGHGUI 错误:V4L/V4L2:VIDIOC_S_CROPOpenCV Error: Unspecified error(该函数没有实现.使用Windows、GTK+ 2.x或Carbon支持重建库.如果你在Ubuntu或Debian上,安装libgtk2.0-dev和pkg-config,然后重新运行cmake或配置脚本)在 cvNamedWindow,文件/home/om/OpenCV-2.4.4/modules/highgui/src/window.cpp,第 652 行

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

在抛出 'cv::Exception' 实例后调用终止

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

what():/home/om/OpenCV-2.4.4/modules/highgui/src/window.cpp:652: error: (-2) 函数没有实现.使用 Windows、GTK+ 2.x 或 Carbon 支持重建库.如果你使用的是 Ubuntu 或 Debian,请安装 libgtk2.0-dev 和 pkg-config,然后重新运行 cmake 或在函数 cvNamedWindow 中配置脚本

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

我重新安装了 libgtk2.0-dev,pkg-config 存在 &重新编译 OpenCV ,但这没有帮助.如果有人知道如何克服这个问题,请告诉我.提前致谢.~嗡

更多信息:我弄清楚是什么导致了这个问题,但还没有修复它......

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

据我了解,问题出在 opencv 的 cmake 脚本上.它不承认 GTK 的存在,因此在没有 gtk 支持的情况下交叉编译.这是在确保基于 arm 的 gtk 库存在于工具链的 lib 文件夹中并将其路径导出到系统路径之后.

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.

推荐答案

执行cmake语句后验证cmake的输出是否包含如下文字:V4L/V4L2:使用 libv4l.

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

如果不存在,则从突触包管理器安装 v4l2ucpv4l-utilslibv4l-dev.然后 cmake 并再次构建.

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

这对我有用,但我在 Ubuntu 12.04 上使用带有 python 绑定的 OpenCV.

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

这篇关于运行时 Opencv HighGui 错误-“HIGHGUI 错误:V4L/V4L2:VIDIOC_S_CROP".Opencv 交叉编译.主机 = 64 位 Ubuntu 12.04.目标=ARM-Cortex-A9的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆