Example program for distance_pc
程序员文章站
2022-07-04 16:00:32
...
* Example program for distance_pc
* Determine the minimal and maximal radius of drill holes
*
dev_close_window ()
read_image (Rim, 'rim')
get_image_size (Rim, Width, Height)
dev_open_window (0, 0, Width, Height, 'black', WindowID)
dev_display (Rim)
set_display_font (WindowID, 14, 'mono', 'false', 'false')
* 提取边缘
edges_sub_pix (Rim, Edges, 'canny', 4, 20, 40)
* 选择形状
select_shape_xld (Edges, Holes, 'circularity', 'and', 0.7, 1.0)
* 整理排序
sort_contours_xld (Holes, Holes, 'upper_left', 'true', 'row')
* 最小外接圆
smallest_circle_xld (Holes, Row, Column, Radius)
count_obj (Holes, Number)
dev_set_color ('yellow')
* For all boles ...
for i := 1 to Number by 1
select_obj (Holes, Hole, i)
dev_display (Rim)
dev_display (Hole)
* 通过计算中点到轮廓的距离来计算孔的最小和最大半径
distance_pc (Hole, Row[i - 1], Column[i - 1], DistanceMin, DistanceMax)
* 显示结果
disp_cross (WindowID, Row[i - 1], Column[i - 1], 6, 0)
tuple_string (DistanceMin, '.3f', SVal)
get_string_extents (WindowID, 'min: ' + SVal, Ascent, Descent, Width1, Height1)
disp_message (WindowID, 'min: ' + SVal, 'image', Row[i - 1] - 2 * Ascent, Column[i - 1] - Radius[i - 1] - Width1 - 10, 'black', 'true')
disp_message (WindowID, 'max: ' + DistanceMax$'.3f', 'image', Row[i - 1], Column[i - 1] - Radius[i - 1] - Width1 - 10, 'black', 'true')
disp_continue_message (WindowID, 'black', 'true')
stop ()
endfor
dev_close_window ()
上一篇: 苹果鼠标20年演化史
推荐阅读
-
[PHP] small example to show dynamic type change
-
example2.php
-
注册微软账户失败无法查看验证example.com邮箱该怎么办?
-
example1.php
-
ftp类(example.php)
-
注册微软账户失败无法查看验证example.com邮箱该怎么办?
-
springboot 报错 org.springframework.beans.factory.NoSuchBeanDefinitionException:No qualifying bean of type 'com.example.service.HrService' avai
-
asp.net core 3.1 入口:Program.cs中的Main函数
-
[PHP] small example to show dynamic type change
-
Can't debug c++ project because unable to static library start program *.lib