How to find the x,y coordinates, and center of a line using hough line transform using a live video feed

asked 2014-02-11 08:53:31 -0500

galbert gravatar image

updated 2014-02-11 09:25:24 -0500

Hello, anyone got any ideas or tips on how to find the detected hough line transform coordinates and center if possible. I am at a lost here, is only moments/finding contours are the only solution or I don't understand much since I'm only following tutorials, stackoverflow, and other references.

here is my sample code

include "opencv2\highgui\highgui.hpp"

include "opencv2\imgproc\imgproc.hpp"

include <iostream>

include <stdio.h>

using namespace cv;

using namespace std;

Mat frame, frame_gray, edges, Dedges;

int main()
    VideoCapture stream(0);

    cout<<"ERROR: cannot open camera";
    return -1;

    stream >> frame;                                                                    
    cvtColor(frame, frame_gray, CV_RGB2GRAY);                                           
    Canny(frame_gray, edges, 50, 200, 3);                                               

    vector<Vec4i> hline;                                            
    HoughLinesP(edges, hline, 1, CV_PI/180, 150, 50, 10);
    cvtColor(edges, Dedges, CV_GRAY2RGB);                               

    for(size_t i = 0; i < hline.size(); i++)
        Vec4i D = hline[i];
        line(Dedges, Point(D[0],D[1]), Point(D[2],D[3]), Scalar(0,0,255), 3, CV_AA);
        cout<<"object detected"<<endl;

    imshow("Camera View", Dedges);
    if(waitKey(30) >= 0)


return 0;

reference to this link

Thanks in advance.

edit retag flag offensive close merge delete