gpt4 book ai didi

opencv - HoughLinesP 与 IplImage

转载 作者:行者123 更新时间:2023-12-02 17:14:01 25 4
gpt4 key购买 nike

我正在尝试对图像应用概率霍夫变换,但出现此编译器错误:

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)

最佳答案

OpenCV documentation

. 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com