百度了很久,还是不懂,有大佬帮我解释下么,创建模型的时候这些算子的参数数据怎么获得的。大体思路是?
- set_system ('border_shape_models', 'false')
- set_system ('int_zooming', 'true')
- set_system('clip_region','false')
- dev_close_window ()
- dev_update_off ()
- dev_open_window (0, 0, 640, 480, 'black', WindowHandle)
- dev_set_draw ('margin')
- set_display_font (WindowHandle, 16, 'mono', 'true', 'false')
- dev_set_line_width (2)
- dev_set_color ('green')
- AmplitudeThreshold := 12
-
- * 创建模板
- if(false)
- //读取图片
- read_image (Image, 'Model.bmp')
- //创建矩形模板
- gen_rectangle2 (ModelRegion, 1046.55, 502.87, rad(10.9339), 178.542, 81.8375)
- //减少图片的范围
- reduce_domain (Image, ModelRegion, TemplateImage)
- //创建一个匹配的模型
- create_shape_model (TemplateImage, 5, rad(0), rad(360), rad(0.6245), ['none','no_pregeneration'], 'use_polarity', [15,30,50], 4, ModelID)
- //返回形状模型
- get_shape_model_contours (ModelContours, ModelID, 1)
- //区域面积和中心
- area_center (ModelRegion, ModelRegionArea, RefRow, RefColumn)
- //从点和角度计算刚性仿射变换。
- vector_angle_to_rigid (0, 0, 0, RefRow, RefColumn, 0, HomMat2D)
- //对XLD轮廓应用任意仿射2D变换。
- affine_trans_contour_xld (ModelContours, TransContours, HomMat2D)
- //在“图像”中找到形状模型的最佳匹配。
- find_shape_model (Image, ModelID, rad(0), rad(360), 0.51, 1, 0.5, 'least_squares', [5,1], 0.75, ModelRow, ModelColumn, ModelAngle, Score)
- //将形状模型写入文件。
- write_shape_model (ModelID, './ModelID')
- //显示
- dev_display (Image)
- dev_display (ModelRegion)
- dev_display (TransContours)
-
- * Rectangle0
- TmpCtrl_Row := 926
- TmpCtrl_Column := 1074
- TmpCtrl_Phi := -1.35726
- TmpCtrl_Len1 := 100
- TmpCtrl_Len2 := 10
- //创建一个任意方向的矩形。
- gen_rectangle2 (Rectangle0, TmpCtrl_Row, TmpCtrl_Column, TmpCtrl_Phi, TmpCtrl_Len1, TmpCtrl_Len2)
- //将区域写入文件
- write_region (Rectangle0, 'Rectangle0.hobj')
- * Rectangle1
- TmpCtrl_Row := 847.673
- TmpCtrl_Column := 1425.64
- TmpCtrl_Phi := -1.36127
- TmpCtrl_Len1 := 70
- TmpCtrl_Len2 := 10
- gen_rectangle2 (Rectangle1_1, TmpCtrl_Row, TmpCtrl_Column, TmpCtrl_Phi, TmpCtrl_Len1, TmpCtrl_Len2)
- write_region (Rectangle1_1, 'Rectangle1_1.hobj')
-
- TmpCtrl_Row := 1038
- TmpCtrl_Column := 554
- TmpCtrl_Phi := -1.36127
- TmpCtrl_Len1 := 70
- TmpCtrl_Len2 := 10
- gen_rectangle2 (Rectangle1_2, TmpCtrl_Row, TmpCtrl_Column, TmpCtrl_Phi, TmpCtrl_Len1, TmpCtrl_Len2)
- write_region (Rectangle1_2, 'Rectangle1_2.hobj')
-
- * Rectangle2
- TmpCtrl_Row := 987.028
- TmpCtrl_Column := 1061.99
- TmpCtrl_Phi := 0.214
- TmpCtrl_Len1 := 374
- TmpCtrl_Len2 := 10
- gen_rectangle2 (Rectangle2, TmpCtrl_Row, TmpCtrl_Column, TmpCtrl_Phi, TmpCtrl_Len1, TmpCtrl_Len2)
- write_region (Rectangle2, 'Rectangle2.hobj')
- * Rectangle3
- TmpCtrl_Row := 874.972
- TmpCtrl_Column := 1038.08
- TmpCtrl_Phi := 0.214
- TmpCtrl_Len1 := 374
- TmpCtrl_Len2 := 10
- gen_rectangle2 (Rectangle3, TmpCtrl_Row, TmpCtrl_Column, TmpCtrl_Phi, TmpCtrl_Len1, TmpCtrl_Len2)
- write_region (Rectangle3, 'Rectangle3.hobj')
- * Rectangle4
- TmpCtrl_Row := 959.71
- TmpCtrl_Column := 918.038
- TmpCtrl_Phi := 0.217258
- TmpCtrl_Len1 := 616.136
- TmpCtrl_Len2 := 10
- gen_rectangle2 (Rectangle4, TmpCtrl_Row, TmpCtrl_Column, TmpCtrl_Phi, TmpCtrl_Len1, TmpCtrl_Len2)
- write_region (Rectangle4, 'Rectangle4.hobj')
-
- * Rectangle5 检测区域
- gen_rectangle2 (Rectangle5_1, 994.108, 760.656, 1.78017, 75, 38)
- gen_rectangle2 (Rectangle5_2, 963.114, 904.277, 1.78017, 75, 38)
- write_region (Rectangle5_1, 'Rectangle5_1.hobj')
- write_region (Rectangle5_2, 'Rectangle5_2.hobj')
- stop ()
- endif
复制代码 |