当前位置:网站首页>Halcon color recognition_ fuses. hdev:classify fuses by color
Halcon color recognition_ fuses. hdev:classify fuses by color
2022-07-05 08:40:00 【Aii parson】
* Refresh the window Turn off
dev_update_window('off')
* name Give the selected thing a name (a It's a variable , You can use it , As long as it's in English )
a:=[' Orange ',' Red ',' Blue ',' yellow ',' green ']
* classification There are several kinds of things to choose (fusetypes Used to cycle , You can name it as you like , As long as it's in English )
fusetypes:=[1,2,3,4,5]
* Name the gray value range Something has a certain scope ( Such as : Orange 10-30, Red 0-10.. It can also be size “ area ”, shape )
hueranges:=[10,30,0,10,125,162,30,64,96,128]
* close window ( Closing the window first is to ensure that the window is not closed under special circumstances )
dev_close_window ()
* open windows
dev_open_window (0, 0, 512, 512, 'black', WindowHandle)
* Read images
read_image (Image, ' Color recognition picture .png')
* Display images
dev_display (Image)
* Settings window Used to display content ( second 、 The three parameters are where to display )
set_tposition (WindowHandle, 10, 512)
* Display the content in the set window The second parameter is what you want
write_string (WindowHandle, ' Color recognition ')
* Split into RGB Images
decompose3 (Image, Red, Green, Blue)
*RGB The image turns into HSV Images
trans_from_rgb (Red, Green, Blue, Hue, Saturation, Intensity, 'hsv')
* Graying ( Yes S The component image is grayed , Choose a few things you want )
threshold (Saturation, Regions, 60, 261)# Can also be directly in Hue Choose from the top
* Regional segmentation stay H Components are divided into grayed S Area of component ( If we H Component processing ...)
reduce_domain (Hue, Regions, ImageReduced)
* Establish a cycle fuse It's a variable. , It can be letters or English
* stay fusetypes Class from 0 Start to deal with , Deal with one at a time
for fuse:=0 to |fusetypes| -1 by 1
* Gray the segmented area ( Be careful : The grayed value is determined by the third ( minimum value )、 Four parameters ( Maximum ) decision )
*hueranges The scope has been divided at the beginning
* Such as :fuse=0, Then the value is 10-30,fuse=1 Then the value is 0-10
threshold (ImageReduced, Regions1,hueranges[fuse*2],hueranges[fuse*2+1])
* Disconnect connected domain
connection (Regions1, ConnectedRegions)
* Filling and flushing
fill_up (ConnectedRegions, RegionFillUp)
* feature selection ( Be careful : You cannot choose features related to location , This program is selected by using area characteristics ,
* The choice of area cannot be too small or too large , Otherwise, you won't be able to choose )
select_shape (RegionFillUp, SelectedRegions, 'area', 'and', 3998.14, 10000)
* Find the area 、 Central coordinates ( Used to display the location of the content to be displayed )
area_center (SelectedRegions, fuseArea, Row, Column)
* Set the color of the content font to be displayed
dev_set_color ('red')
* loop This loop is used to display the name of the obtained thing , |fuseArea| To express a
for i:=0 to |fuseArea| -1 by 1
* Settings window Used to display content ( second 、 The three parameters are where to display , The position of this instruction is variable (i It's a variable ))
set_tposition (WindowHandle, Row[i], Column[i]-15)
* Display the content in the set window The second parameter is what you want ( The content of this article is based on a Named after Variable
*fuse To show ,fusea The value of is determined by the previous cycle , What was dealt with in the previous loop? There will be corresponding values )
write_string (WindowHandle, a[fuse])
* End of cycle ( Be careful : Loops must be in pairs , Otherwise you'll make a mistake )
endfor
* Display the operation result of this program
* Settings window Used to display content
set_tposition (WindowHandle, 16*[fuse+1], 16)
* Display the content in the set window use ‘’ What is displayed directly The second parameter is what you want
* ( Show : name Number 》 Must use | | Encircle )
write_string (WindowHandle, a[fuse]+' '+|fuseArea|)
disp_message (3600, ' Pay attention to WeChat public number ( Robots are equipped with vision ind400)', 'window', 300, 120, 'black', 'true')
endfor
* Refresh the window open ( Refresh the window after program execution , Or you'll make a mistake )
dev_update_window('on')
边栏推荐
- Xrosstools tool installation for X-Series
- Digital analog 1: linear programming
- 实例007:copy 将一个列表的数据复制到另一个列表中。
- [daily training -- Tencent selected 50] 557 Reverse word III in string
- Basic number theory -- Euler function
- 猜谜语啦(6)
- Typescript hands-on tutorial, easy to understand
- Sword finger offer 06 Print linked list from end to end
- Guess riddles (11)
- Hello everyone, welcome to my CSDN blog!
猜你喜欢
随机推荐
Chapter 18 using work queue manager (1)
【三层架构及JDBC总结】
Matlab tips (28) fuzzy comprehensive evaluation
【NOI模拟赛】汁树(树形DP)
Go dependency injection -- Google open source library wire
Hello everyone, welcome to my CSDN blog!
每日一题——输入一个日期,输出它是该年的第几天
Typical low code apaas manufacturer cases
696. Count binary substring
TypeScript手把手教程,简单易懂
Five design details of linear regulator
实例001:数字组合 有四个数字:1、2、3、4,能组成多少个互不相同且无重复数字的三位数?各是多少?
Business modeling | process of software model
STM32---IIC
The first week of summer vacation
Example 006: Fibonacci series
Sword finger offer 06 Print linked list from end to end
Business modeling of software model | stakeholders
Is the security account given by Yixue school safe? Where can I open an account
【日常训练--腾讯精选50】557. 反转字符串中的单词 III