# I have problem with javacv of intersection of line using hough.

well, I need to find the intersection of two lines, I'm using javacv .. and found a code that does this in C, right here: http://opencv-code.com/tutorials/automatic-perspective-correction-for- quadrilateral-objects /

Would anyone tell me how to do it in javacv?

/ / Needed for visualization only
for (int i = 0; i <lines.size (); i + +)
{
v = cv :: Vec4i lines [i];
lines [i]  = 0;
lines [i]  = ((float) v  - v ) / (v  - V ) *-v  + v ;
lines [i]  = src.cols;
lines [i]  = ((float) v  - v ) / (v  - V ) * (src.cols - v ) + v  ;
}

cv :: Point2f computeIntersect (cv :: Vec4i the cv :: Vec4i b)
{
int x1 = a , y1 = a , x2 = in , y2 = a ;
x3 int = b , y3 = b  x4 = b , y4 = b ;

if (float d = ((float) (x1-x2) * (y3-y4)) - ((y2-y1) * (x3-x4)))
{
cv :: Point2f pt;
pt.x = ((x1 * y2 - y1 * x2) * (x3-x4) - (x2-x1) * (x3 * y4 - y3 * x4)) / d;
pt.y = ((x1 * y2 - y1 * x2) * (y4-y3) - (y1-y2) * (x3 * y4 - y3 * x4)) / d;
return pt;
}
else
CV :: Point2f return (-1, -1);
}

...

std :: vector <cv::Point2f> corners;
for (int i = 0; i <lines.size (); i + +)
{
for (int j = i +1 j <lines.size () j + +)
{
cv :: Point2f computeIntersect pt = (lines [i], lines [j]);
if (pt.x> = 0 && pt.y> = 0)
corners.push_back (pt);
}
}

edit retag close merge delete