0
votes

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*"

1
You're mixing interfaces. IplImage is from the old cv interface while Mat is part of the new interface. Stick with one or the other. - rayryeng
The tutorial used C, so I need to keep programming in C? or do I need to keep using IplImage, if that is so then how do I use the methods (cv::cvtColor()) with IplImages? - Matthew
You'll need to find the C equivalents to do so. Check here: docs.opencv.org/modules/imgproc/doc/… - Look at the C definition instead. - rayryeng

1 Answers

0
votes

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.