sslzjx 最近的时间轴更新
sslzjx

sslzjx

V2EX 第 668738 号会员,加入于 2023-12-27 17:49:12 +08:00
sslzjx 最近回复了
7 天前
回复了 gzldc 创建的主题 分享发现 关于显卡 老婆一句话给我整破防了
最便宜的肯定是闲鱼吧
14.98
21.98
50 天前
回复了 wjx0912 创建的主题 OpenCV 请教一个 opencv 算法,图片中检测圆形对象
Halcon 代码,可以试下

* This program fits circles into circular contour segments
* to extract their positions and radii
*
dev_update_off ()
*
* step: acquire image
*
read_image (Image, 'OXfE6Ph.png')

* auto_threshold (Image, all_Region, 15.0)
* connection (all_Region, all_ConnectedRegions)
* select_shape (all_ConnectedRegions, all_ConnectedRegions, 'area', 'and', 7000, 14000)
* count_obj (all_ConnectedRegions, all_NumberContours)
* for Index := 1 to all_NumberContours by 1
* select_obj(all_ConnectedRegions, ObjectSelected1, Index)
* smallest_rectangle1(ObjectSelected1, Row1, Column1, Row2, Column2)
* crop_part(Image, ImagePart, Row1, Column1, Row2-Row1, Column2-Colu)
* endfor

get_image_size (Image, Width, Height)
dev_close_window ()
dev_open_window (0, 0, Width / 2, Height / 2, 'light gray', WindowID)
dev_set_part (0, 0, Height - 1, Width - 1)
dev_set_line_width (3)
dev_set_color ('white')
dev_set_draw ('margin')
dev_display (Image)
set_display_font (WindowID, 14, 'mono', 'true', 'false')
disp_continue_message (WindowID, 'black', 'true')
stop ()
*
* step: segment image into regions
*
dev_set_colored (12)
dev_set_line_width (2)
dev_set_draw ('fill')

*equ_histo_image (Image, Image)
scale_image_max (Image, Image)
decompose3 (Image, Image_R, Image_G, Image_B)
* fast_threshold (Image, Region, 180, 230, 20)
auto_threshold (Image_G, Region, 5.0)
stop()

connection (Region, ConnectedRegions)
select_shape (ConnectedRegions, SelectedRegions, 'circularity', 'and', 0.6, 1.2)
select_shape (SelectedRegions, SelectedRegions, 'area', 'and', 200, 500)
dev_display (Image)
dev_display (SelectedRegions)
disp_continue_message (WindowID, 'black', 'true')
stop ()
*
* step: create ROI for contour processing
*
boundary (SelectedRegions, RegionBorder, 'inner_filled')
dilation_circle (RegionBorder, RegionDilation, 3.5)
union1 (RegionDilation, RegionUnion)
reduce_domain (Image, RegionUnion, ImageReduced)
dev_clear_window ()
dev_display (ImageReduced)
disp_continue_message (WindowID, 'black', 'true')
stop ()
*
* step: create contours and fit circles to them
*
edges_sub_pix (ImageReduced, Edges, 'canny', 1.5, 10, 40)
segment_contours_xld (Edges, ContoursSplit, 'lines_circles', 5, 2, 2)
select_contours_xld (ContoursSplit, SelectedContours, 'contour_length', 25, 99999, -0.5, 0.5)
count_obj (SelectedContours, NumberContours)
gen_empty_obj (Circles)
for i := 1 to NumberContours by 1
select_obj (SelectedContours, ObjectSelected, i)
get_contour_global_attrib_xld (ObjectSelected, 'cont_approx', Attrib)
if (Attrib == 1)
concat_obj (Circles, ObjectSelected, Circles)
endif
endfor
union_cocircular_contours_xld (Circles, UnionContours, rad(60), rad(10), rad(30), 100, 50, 10, 'true', 1)
dev_clear_window ()
dev_set_color ('black')
dev_display (UnionContours)
disp_continue_message (WindowID, 'black', 'true')
stop ()
count_obj (UnionContours, NumberCircles)
CenterRow := []
CenterColumn := []
dev_clear_window ()
dev_set_color ('black')
set_display_font (WindowID, 12, 'mono', 'true', 'false')
dev_display (SelectedContours)
for i := 1 to NumberCircles by 1
select_obj (UnionContours, ObjectSelected, i)
fit_circle_contour_xld (ObjectSelected, 'algebraic', -1, 0, 0, 3, 2, Row, Column, Radius, StartPhi, EndPhi, PointOrder)
gen_circle_contour_xld (ContCircle, Row, Column, Radius, 0, rad(360), 'positive', 1.5)
dev_set_color ('white')
dev_display (ContCircle)
if (i == 1)
Row2 := Row + Radius * sin(rad(-45))
Column2 := Column + Radius * cos(rad(-45))
set_tposition (WindowID, Row2 - 35, Column2 + 5)
endif
if (i > 1)
exist := 0
for j := 0 to i - 2 by 1
distance_pp (Row, Column, CenterRow[j], CenterColumn[j], DistanceCenters)
if (DistanceCenters < 20)
exist := 1
endif
endfor
if (exist == 1)
Row2 := Row + Radius * sin(rad(-135))
Column2 := Column + Radius * cos(rad(-135))
set_tposition (WindowID, Row2 - 40, Column2 - 30)
else
Row2 := Row + Radius * sin(rad(-45))
Column2 := Column + Radius * cos(rad(-45))
set_tposition (WindowID, Row2 - 35, Column2 + 5)
endif
endif
disp_arrow (WindowID, Row, Column, Row2, Column2, 2)
write_string (WindowID, i)
if (i < 8)
disp_message (WindowID, 'R' + i + ' = ' + Radius$'.4', 'window', i * 20, 130, 'black', 'false')
else
disp_message (WindowID, 'R' + i + ' = ' + Radius$'.4', 'window', (i - 7) * 20, 400, 'black', 'false')
endif
CenterRow := [CenterRow,Row]
CenterColumn := [CenterColumn,Column]
endfor
*
dev_update_window ('on')
88 天前
回复了 Renco 创建的主题 职场话题 统计一下 V 友们,除夕不放假的有多少
不放+1
91 天前
回复了 justincnn 创建的主题 互联网 请问有将模糊图片高清化的网站么?
可以买 flash 闪电竞的
118 天前
回复了 KKLeon 创建的主题 机械键盘 入了一把几十块的薄膜键盘,非常好用。
学校机房键盘
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2760 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 15ms · UTC 05:44 · PVG 13:44 · LAX 22:44 · JFK 01:44
Developed with CodeLauncher
♥ Do have faith in what you're doing.