OpenCV中遇到的一些知识

OpenCV中遇到的一些知识(android版)

  1. 一般参数均为(int row, int col),注意参数顺序(刚开始经常出错)。

  2. houghLinesP中第二个参数为检测到的直线,为四通道n行一列Mat类型(4XnX1),每个通道分别存储直线左右两个端点x、y值(x1,y1,x2,y2),x1<x2。

  3. 二值化后Mat为单通道(CV_8UC1),存储0或255。

  4. java中注意Bitmap为ARGB图像(32位)。

  5. minAreaRect用法:

  其参数类型:MatOfPoint2f;(MatOfPoint与MatOfPoint2f转换方法):

	MatOfPoint2f mop2f = new MatOfPoint2f(mop.toArray());

  返回值类型:RotatedRect类型;

  • center为中心坐标,size为矩形length of each side

  • angle为矩形角度,简介:The rotation angle in a clockwise direction. When the angle is 0, 90, 180, 270 etc., the rectangle becomes an up-right rectangle.

    分析得:

       (1)angle范围[-90,0);

       (2)角度均以长边为基准:下顶点左侧为长边,则角度angle为长边与Y+轴夹角取负值;下顶点右侧为长边,则角度angle为长边与X+轴夹角取负值;

       (3)angle范围[0,180)方法:

if(rRect.size.width<rRect.size.height){//注:以下顶点为原点X轴逆时针旋转触碰到的第一条边为width
angle = 90 -rRect.angle;
}else{
angle = -rRect.angle;
}

posted on 2016-04-25 15:22  silentteen  阅读(242)  评论(0编辑  收藏  举报