I wrote this bit of code to draw block arrows on a opencv MAT image, it works but my question is, is there an easier way to rotate the image?
Is it necessary to code it in detail or is there a rotate transpose or flip method in opencv?
void Arrow( Mat img, int i )
{
int lineType = 8;
Point arrow_points[1][7];
if (i == 1) { //left
arrow_points[0][0] = Point( 90*mp, 60*mp );
arrow_points[0][1] = Point( 90*mp, 40*mp );
arrow_points[0][2] = Point( 50*mp, 40*mp );
arrow_points[0][3] = Point( 50*mp, 30*mp );
arrow_points[0][4] = Point( 10*mp, 50*mp );
arrow_points[0][5] = Point( 50*mp, 70*mp );
arrow_points[0][6] = Point( 50*mp, 60*mp );
};
if (i == 2) { //right
arrow_points[0][0] = Point( 20*mp, 60*mp );
arrow_points[0][1] = Point( 20*mp, 40*mp );
arrow_points[0][2] = Point( 60*mp, 40*mp );
arrow_points[0][3] = Point( 60*mp, 30*mp );
arrow_points[0][4] = Point( 100*mp, 50*mp );
arrow_points[0][5] = Point( 60*mp, 70*mp );
arrow_points[0][6] = Point( 60*mp, 60*mp );
};
if (i == 3) { //down
arrow_points[0][0] = Point( 60*mp, 20*mp );
arrow_points[0][1] = Point( 40*mp, 20*mp );
arrow_points[0][2] = Point( 40*mp, 60*mp );
arrow_points[0][3] = Point( 30*mp, 60*mp );
arrow_points[0][4] = Point( 50*mp, 100*mp );
arrow_points[0][5] = Point( 70*mp, 60*mp );
arrow_points[0][6] = Point( 60*mp, 60*mp );
};
const Point* ppt[1] = { arrow_points[0] };
int npt[] = { 7 };
fillPoly( img,
ppt,
npt,
1,
Scalar( 250, 0, 0 ),
lineType );
}
Rotation is an affine transformation. Check out the documentation for affine transformations:
http://docs.opencv.org/doc/tutorials/imgproc/imgtrans/warp_affine/warp_affine.html