detectormorph.cpp源码解读

Mat M = getRotationMatrix2D(PlateRect.center, PlateRect.angle, 1.0);  //表示旋转的中心点  表示旋转的角度  图像缩放因子      
warpAffine(frame_gray_cp, rotated, M, frame_gray_cp.size(), INTER_CUBIC);
      //Crop area around candidate plate   裁剪 plate周围的面积:从原图像中提取提取一个感兴趣的矩形区域图像
      getRectSubPix(rotated, rect_size, PlateRect.center, img_crop);

1、warpAffine函数

实现仿射变换一般会涉及到warpAffine和getRotationMatrix2D两个函数,其中warpAffine可以实现一些简单的重映射,而getRotationMatrix2D可以获得旋转矩阵。 

void cv::warpAffine     (   InputArray      src,
        OutputArray     dst,
        InputArray      M,
        Size    dsize,
        int     flags = INTER_LINEAR,
        int     borderMode = BORDER_CONSTANT,
        const Scalar &      borderValue = Scalar() 
    )

参数解释 
. src: 输入图像 
. dst: 输出图像,尺寸由dsize指定,图像类型与原图像一致 
. M: 2X3的变换矩阵 
. dsize: 指定图像输出尺寸 
. flags: 插值算法标识符,有默认值INTER_LINEAR,如果插值算法为WARP_INVERSE_MAP, warpAffine函数使用如下矩阵进行图像转换 

2、getRectSubPix函数

函数作用:

从原图像中提取提取一个感兴趣的矩形区域图像

void getRectSubPix(InputArray image, Size patchSize, Point2f center, OutputArray patch, int patchType=-1 )

参数理解:

InputArray image:输入图像

Size patchSize:获取矩形的大小

Point2f center:获取的矩形在原图像中的位置

OutputArray patch:表示输出的图像

int patchType=-1 :表示输出图像的深度

3、threshold函数

图像的二值化就是将图像上的像素点的灰度值设置为0或255,这样将使整个图像呈现出明显的黑白效果。在数字图像处理中,二值图像占有非常重要的地位,图像的二值化使图像中数据量大为减少,从而能凸显出目标的轮廓。OpenCV中提供了函数cv::threshold();

参数说明

src:源图像,可以为8位的灰度图,也可以为32位的彩色图像。(两者由区别)

dst:输出图像

thresh:阈值

maxval:dst图像中最大值

type:阈值类型,可以具体类型如下:

猜你喜欢

转载自blog.csdn.net/u011473714/article/details/89373220