cvGetMat中无法识别或不支持的数组类型 [英] Unrecognized or unsupported array type in cvGetMat

查看:2931
本文介绍了cvGetMat中无法识别或不支持的数组类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里搜索了一下,但没有人似乎有同样的错误,我试图在树莓pi上创建一个颜色检测摄像机,我使用



https://github.com/robidouille/robidouille/tree/master/raspicam_cv



,但现在我有

  IplImage * image = raspiCamCvQueryFrame(capture); 
cv :: cvtColor(cv :: Mat(image),x,cv :: COLOR_BGR2HSV);

它会编译,但运行时会给出



函数cvGetMat中无法识别或不支持的数组类型



没有cv :: Mat(image)因为



从IplImage *类型的表达式初始化类型为cv :: InputArray的引用

解决方案

p>

以下代码将显示窗口中的网络摄像头的提要,程序将终止当按下'q'时:(

  #includeopencv2 / highgui / highgui.hpp

int main int argc,const char ** argv){
cv :: VideoCapture capture;
cv :: Mat image;

//除非你需要从多个设备获取图像,
//使用'-1'将自动选择网络摄像头。
capture.open(-1);
if(capture.isOpened()){
cv :: namedWindow(WebCam,cv :: WINDOW_AUTOSIZE);
while(1){
capture.read(image);
cv :: imshow(WebCam,image);
int c = cv :: waitKey(10);
if((char)c =='q'){
break;
}
}
}

capture.release();

return 0;我在Ubuntu 14.04上测试了这个代码,并编译成这样: p>

  $ clang ++ -o cvtest cvtest.cpp -lopencv_core -lopencv_highgui 






如果您想继续使用 IplImage 和C接口,那么我不能帮助你。


I searched around a bit on here but nobody seems to have the same error, I am trying to create a color detection camera on the raspberry pi, I used

https://github.com/robidouille/robidouille/tree/master/raspicam_cv

for the tutorial and got it working, but now when I have

IplImage* image = raspiCamCvQueryFrame(capture);
cv::cvtColor(cv::Mat(image), x, cv::COLOR_BGR2HSV);

it will compile, but when run it gives

Unrecognized or unsupported array type in function cvGetMat

Without the cv::Mat(image) I can't compile because of

Invalid initialization of reference of type "cv::InputArray" from expression of type "IplImage*"

解决方案

As mentioned in the comments, it's better to use the new C++ interface.

The following code will show the feed from a webcam in a window, the program will terminate when 'q' is pressed: (source)

#include "opencv2/highgui/highgui.hpp"

int main(int argc, const char** argv) {
    cv::VideoCapture capture;
    cv::Mat image;

    // Unless you need to get images from multiple devices,
    // using '-1' will automatically select the webcam.
    capture.open(-1);
    if (capture.isOpened()) {
        cv::namedWindow("WebCam", cv::WINDOW_AUTOSIZE);
        while (1) {
            capture.read(image);
            cv::imshow("WebCam", image);
            int c = cv::waitKey(10);
            if ((char)c == 'q') {
                break;
            }
        }
    }

    capture.release();

    return 0;
}

I have tested this code on Ubuntu 14.04 and compiled it like this:

$ clang++ -o cvtest cvtest.cpp -lopencv_core -lopencv_highgui


If you desperately want to continue using IplImage and the C interface, then I can't help you.

这篇关于cvGetMat中无法识别或不支持的数组类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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