2 kevinoop kevinoop 于 2016.01.28 15:59 提问

opencv 霍夫变换 求大神帮忙看看哪里错了
 #include<opencv2/opencv.hpp>
#include<opencv2/imgproc/imgproc.hpp>
using namespace cv;
using namespace std;
int main() {
    Mat src = imread("D:\\杂项\\图片素材\\2.jpg");
    Mat dst, edge;
    Canny(src, edge,50,200,3);
    cvtColor(edge, dst, CV_BGR2GRAY);
    vector<Vec2f> lines;
    HoughLines(edge, lines, 1, CV_PI / 180, 150,0,0);
    for (size_t i = 0; i < lines.size(); i++) {
        float r = lines[i][0], theta = lines[i][1];
        double x0 = r*cos(theta), y0 = r*sin(theta);
        Point ptr1, ptr2;
        ptr1.x = cvRound(x0 - 1000 * sin(theta));
        ptr1.y = cvRound(y0 + 1000 * cos(theta));
        ptr2.x = cvRound(x0 + 1000 * sin(theta));
        ptr2.y = cvRound(y0 - 1000 * cos(theta));
        line(dst, ptr1, ptr2, Scalar(55, 100, 195), 1, CV_AA);
    }
    imshow("my girl", dst);
    waitKey(0);
    return(0);
}

不知道哪里错了,求大神指教

1个回答

devmiao
devmiao   Ds   Rxr 2016.01.29 06:58
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!