Reputation: 580
Hi i've been trying to recognize hand signatures(numbers) using OpenCV.i am encountering a problem where 1 and 2 show the same number of convexity defects. One way i thought i could rectify this was by drawing a Minbounding rectangle..and find the ratio of the area of the convex hull to that of the bounding rectangle. However im not aware how to do this.
vector<vector<Point>> hull;
The index of the hull i am interested in is say k;
How do i draw a rotated rectangle for this convex hull?
Upvotes: 0
Views: 1002
Reputation: 41765
// Assuming
// vector<vector<Point>> hull;
// Mat3b frame;
if((k >= 0) && (k < hull.size()) && (!hull[k].empty()))
{
RotatedRect rotated = minAreaRect(hull[k]);
Point2f rect_points[4];
rotated.points( rect_points );
for( int j = 0; j < 4; j++ ) {
line( frame, rect_points[j], rect_points[(j+1)%4], Scalar(255,0,0), 1, 8 );
}
}
Upvotes: 1