Yahoo OpenCV
Community article
http://tech.groups.yahoo.com/group/OpenCV/message/33638
==============================================
cvHoughLines2 Docu Sample error Message List
Reply | Forward Message #33638 of 42818 < Prev
| Next >
The line calculation inside the #ifdef 1 pragmas is not sufficient.
I have digged around in some trigonometric issues and
here is better
solution:
for( i = 0; i <
lines->total; i++ )
{
float* line = (float*)cvGetSeqElem(lines,i);
float rho = line[0];
float theta = line[1];
double a = cos(theta), b = sin(theta), c =
tan(theta);
if( fabs(b) < 0.001 )
{
pt1.x = pt2.x = cvRound(rho);
pt1.y = 0;
pt2.y = color_dst->height;
}
else if( fabs(a) < 0.001 )
{
pt1.y = pt2.y = cvRound(rho);
pt1.x = 0;
pt2.x = color_dst->width;
}
else
{
pt1.x = 0;
pt1.y = cvRound(rho/b);
if(pt1.y < 0)
{
pt1.x = cvRound(rho / a);
pt1.y = 0;
}
if(pt1.y > color_dst->height)
{
pt1.x = cvRound((pt1.y - color_dst->height)*c);
pt1.y = color_dst->height;
}
pt2.x = color_dst->width;
pt2.y = cvRound(rho/b - color_dst->width/c);
if(pt2.y < 0)
{
pt2.x = cvRound(rho/a);
pt2.y = 0;
}
if(pt2.y > color_dst->height)
{
pt2.x = cvRound(-1.0 * ((color_dst->height
- rho/b) * c));
pt2.y = color_dst->height;
}
}
cvLine( color_dst, pt1,
pt2, CV_RGB(255,0,0), 6, 8, 0 );
}
At least I hope so...
frankoni