I\'m currently trying to detect whether a level crossing barrier has been deployed on an image using HoughLines in OpenCV. I thought my code would
Edit: See lordache's answer which is Java specific.
Useful reading: How are two-element vector represented in a OpenCV Mat in Java?
Check this tutorial and look for the section "Standard Hough Line Transform".
lines should not be a cv::Mat, but a std::vector that later on you can visualize with a code like the one showed in the link:
for( size_t i = 0; i < lines.size(); i++ )
{
float rho = lines[i][0], theta = lines[i][1];
Point pt1, pt2;
double a = cos(theta), b = sin(theta);
double x0 = a*rho, y0 = b*rho;
pt1.x = cvRound(x0 + 1000*(-b));
pt1.y = cvRound(y0 + 1000*(a));
pt2.x = cvRound(x0 - 1000*(-b));
pt2.y = cvRound(y0 - 1000*(a));
line( cdst, pt1, pt2, Scalar(0,0,255), 3, CV_AA);
}