- dev_update_off ()
- dev_close_window ()
- dev_open_window (0, 0, 512, 512, 'black', WindowHandle)
- * 1.图像采集部分
- read_image (Image, 'C:/Users/JSZX/Desktop/1.jpg')
- decompose3 (Image, Image1, Image2, Image3) //对图像进行rgb颜色分解
- trans_from_rgb (Image1, Image2, Image3, ImageResult1, ImageResult2, ImageResult3, 'hsv') //rgb转化为hsv,观察最适合分量为ImageResult2
- threshold (ImageResult2, Regions, 0, 110)
- opening_rectangle1 (Regions, RegionOpening, 3, 3)
- fill_up (RegionOpening, RegionFillUp)
- connection (RegionFillUp, ConnectedRegions)
- select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 100, 10000)
- shape_trans (SelectedRegions, RegionTrans, 'rectangle2') //变换区域形状,rectangle2:最小外接矩形
- *2. 图像矫正部分
- orientation_region (RegionTrans, Phi) //区域方向计算,得到弧度Phi
- area_center (RegionTrans, Area, Row, Column)//获得区域坐标,面积
- vector_angle_to_rigid (Row, Column, rad(180)-Phi, Row, Column,0 , HomMat2D)//生成旋转矩形,Phi>0 , [rad(180)-Phi]防止旋转后图像反转
- affine_trans_image (Image, ImageAffineTrans, HomMat2D, 'constant', 'false')//旋转操作
- reduce_domain (ImageAffineTrans, RegionTrans, ImageReduced)//截取车牌区域操作
- *3. 车牌号码提取部分
- invert_image (ImageReduced, ImageInvert) //图像反转,只能识别亮背景,暗目标
- rgb1_to_gray (ImageInvert, GrayImage)
- threshold (GrayImage, Regions1, 15, 128)
- *opening_rectangle1 (Regions1, RegionOpening1, 3, 3)
- connection (Regions1, ConnectedRegions1)
- select_shape (ConnectedRegions1, SelectedRegions1, 'area', 'and', 9301.62, 15394.7)
- *4.车牌号识别部分
- sort_region (SelectedRegions1, SortedRegions, 'character', 'true', 'row') //连通域排序操作
- read_ocr_class_mlp ('Industrial_0-9A-Z_NoRej.omc', OCRHandle) //读取识别库
- do_ocr_multi_class_mlp (SortedRegions, ImageInvert, OCRHandle, Class, Confidence)//为根据给定区域字符和
- *OCR分级器OCRHandle的灰度图像值,而给定的每个字符计,算出最好的类,将类返回到Class中,且将类的置信度返回到Confidence中。
- *5.显示结果
- dev_display (Image)
- dev_display (SortedRegions)
- for i := 1 to |Class| by 1
- disp_message (WindowHandle,Class[i-1], 'image', Row+200 , -800+Column+ i*200, 'blue', 'true')
- endfor
复制代码
|