我正在尝试对图像应用概率霍夫变换,但出现此编译器错误:
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 );
HLP() 的第一个参数是 InputArray 图像: – 8 位,单 channel 二进制源图像。该功能可以修改图像。我想,我对这里的指针处理感到困惑。
此外,如果我更改第一个参数:
HoughLinesP(*imageD, lines, 1, CV_PI/180, PHTdThresh, PHTdmin, PHTdmax );
比它编译但在运行时我在上面的行中得到核心欺骗: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)
最佳答案
. You can assume that instead of InputArray/OutputArray you can always use Mat, std::vector<>, Matx<>, Vec<> or Scalar
您不能将 IplImage 作为 InputArray 传递。您可以使用
Mat(const IplImage* img, bool copyData=false);
解决此问题。构造函数。您调用HoughLinesP()
应该: HoughLinesP(Mat(imageD), lines, 1, CV_PI/180, PHTdThresh, PHTdmin, PHTdmax );
关于opencv - HoughLinesP 与 IplImage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20075245/