Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

perspectiveTransform on contours?

Hi all,

I've got a contour for a flat, irregular shape with ~ten, 2D, points. I'd like to project just that contour, not the whole image, into a normal view and then find area, etc.

I know the contour is OK because drawContours has the expected result. The rotation matrix, Rot3D, works with warpPerspective on the full image (I play with the rotations for the background in a calibration step, then try to use the same rotation matrix here. It is a (3, 3, CV_32FC1) ).

I simplified everything to this code: `

vector<Point> foo = { { 0, 0 }, { 0, 1 }, { 1, 1 }, { 1, 0 } };
vector<Point> bar;
bar.resize(foo.size());
perspectiveTransform(foo, bar, Rot3D);

` which fails an assertion check on 'depth == CV32F...' in matmul.cpp, line 2115.

I don't think I have any flexibility on the rotation matrix data type...what to do?

perspectiveTransform on contours?

Hi all,

I've got a contour for a flat, irregular shape with ~ten, 2D, points. I'd like to project just that contour, not the whole image, into a normal view and then find area, etc.

I know the contour is OK because drawContours has the expected result. The rotation matrix, Rot3D, works with warpPerspective on the full image (I play with the rotations for the background in a calibration step, then try to use the same rotation matrix here. It is a (3, 3, CV_32FC1) ).

I simplified everything to this code: `

vector<Point> ////this builds a contour-like structure for testing...
vector<Point2f> foo = { { 0, 0 }, { 0, 1 }, { 1, 1 }, { 1, 0 } };
vector<Point> vector<vector<Point2f>> bar;
bar.resize(foo.size());
perspectiveTransform(foo, bar, Rot3D);
bar = { foo, foo};
//which ought to work with this...
contours1.resize(bar.size());
for (int i = 0; i < bar.size(); i++) //for each vector of points in the list...
    perspectiveTransform(bar[i], contours1[i], Rot3D);//rotate them.

` which fails an assertion check on 'depth == CV32F...' in matmul.cpp, line 2115.

I don't think I have any flexibility on the rotation matrix data type...what to do?check: image description

No clue what that means...contours1 is a vector<vector<point>> ... Douh! could that be it...

OK, findContours produces <point> (i.e., two int), perspectiveTransform requires <point2f>