Question

I'm trying to apply the probabilistic Hough transformation on an image, but I get this compiler error:

invalid initialization of reference of type ‘cv::InputArray {aka const cv::_InputArray&}’ from expression of type ‘IplImage* {aka _IplImage*}’

/opt/ros/fuerte/include/opencv2/imgproc/imgproc.hpp:482:19: error: in passing argument 1 of ‘void cv::HoughLinesP(cv::InputArray, cv::OutputArray, double, double, int, double, double)’

    IplImage *imageD, *src; //src -is read from a *.png and preprocessed  
    ...
    imgageO=imageD = cvCreateImage( cvSize(src->width,src->height), 8, 1 );
    cvCopy(src, imageO);
    ...
    HoughLinesP(imageD, lines, 1, CV_PI/180, PHTdThresh, PHTdmin, PHTdmax );

The first parameter of HLP() is InputArray image: – 8-bit, single-channel binary source image. The image may be modified by the function.

I think, I'm confused with the pointer handling here. Moreover if i change the first parameter: HoughLinesP(*imageD, lines, 1, CV_PI/180, PHTdThresh, PHTdmin, PHTdmax );

Than it compiles but in runtime i get core duped fort the line above:

OpenCV Error: Bad argument (Unknown array type) in cvarrToMat, file /tmp/buildd/ros-fuerte-opencv2-2.4.2-1precise-20130312-1308/modules/core/src/matrix.cpp, line 697 terminate called after throwing an instance of 'cv::Exception' what(): /tmp/buildd/ros-fuerte-opencv2-2.4.2-1precise-20130312-1308/modules/core/src/matrix.cpp:697: error: (-5) Unknown array type in function cvarrToMat

Aborted (core dumped)

Was it helpful?

Solution

The OpenCV documentation says

. You can assume that instead of InputArray/OutputArray you can always use Mat, std::vector<>, Matx<>, Vec<> or Scalar

You cannot pass an IplImage as an InputArray. You can work around the problem using the Mat(const IplImage* img, bool copyData=false); constructor. Your call to HoughLinesP() should be:

    HoughLinesP(Mat(imageD), lines, 1, CV_PI/180, PHTdThresh, PHTdmin, PHTdmax );
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top