Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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

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 sample my 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);

if(!stream.isOpened())
{
    cout<<"ERROR: cannot open camera";
    return -1;
}

while(true)
{
    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)
    {
        break;
    }

}

return 0;
}

reference to this link

http://docs.opencv.org/doc/tutorials/imgproc/imgtrans/hough_lines/hough_lines.html#hough-lines

Thanks in advance.

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

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 my 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);

if(!stream.isOpened())
{
    cout<<"ERROR: cannot open camera";
    return -1;
}

while(true)
{
    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)
    {
        break;
    }

}

return 0;
}

reference to this link

http://docs.opencv.org/doc/tutorials/imgproc/imgtrans/hough_lines/hough_lines.html#hough-lines

Thanks in advance.