Im working in JavaCV
and im trying to detect rectangle skewed by perspective and fix the image to right perspective using 4 corners of a rectangle.
I have this code:
CvSeq corners_seq = new CvSeq();
int count = 0;
for (int i = 0; i < table_lines.length; i++)
{
for (int j = i + 1; j < table_lines.length; j++)
{
CvPoint pt = HelperClass.ComputeIntersection(table_lines[i][0],table_lines[i][1], table_lines[j][0],table_lines[j][1]);
if (pt.x() >= 0 && pt.y() >= 0)
{
corners_seq.put(pt);
}
}
}
CvMemStorage corners_storage = cvCreateMemStorage(0);
CvSeq corners = cvApproxPoly(corners_seq, corners_seq.header_size(), corners_storage, CV_POLY_APPROX_DP, 8, 0);
And at cvApproxPoly i get error from native method:
Exception in thread "main" java.lang.RuntimeException: ..\..\..\src\opencv\modules\imgproc\src\utils.cpp:54: error: (-5) Input array is not a valid matrix at com.googlecode.javacv.cpp.opencv_imgproc.cvApproxPoly(Native Method)
What am i doing wrong? As i understand it, the input argument is Pointer
to CvSeq