0

我写了这段代码在opencv MAT图像上绘制块箭头,它可以工作,但我的问题是,有没有更简单的方法来旋转图像?是否需要详细编码或者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 );
}
4

1 回答 1

0

旋转是一种仿射变换。查看仿射变换的文档:

http://docs.opencv.org/doc/tutorials/imgproc/imgtrans/warp_affine/warp_affine.html

于 2012-11-04T18:14:34.213 回答