当前位置:网站首页>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')
边栏推荐
- Explore the authentication mechanism of StarUML
- Old Wang's esp8266 and old Wu's ws2818 light strip
- Run菜单解析
- Array integration initialization (C language)
- Arduino+a4988 control stepper motor
- [formation quotidienne - Tencent Selection 50] 557. Inverser le mot III dans la chaîne
- MATLAB小技巧(28)模糊综合评价
- Infix expression evaluation
- MATLAB skills (28) Fuzzy Comprehensive Evaluation
- 【日常训练】1200. 最小绝对差
猜你喜欢
Guess riddles (5)
Arduino operation stm32
Agile project management of project management
Hello everyone, welcome to my CSDN blog!
Guess riddles (9)
Guess riddles (2)
猜谜语啦(6)
猜谜语啦(9)
Example 003: a complete square is an integer. It is a complete square after adding 100, and it is a complete square after adding 168. What is the number?
每日一题——输入一个日期,输出它是该年的第几天
随机推荐
[daily training -- Tencent selected 50] 557 Reverse word III in string
Arduino operation stm32
Arduino+a4988 control stepper motor
[牛客网刷题 Day4] JZ32 从上往下打印二叉树
猜谜语啦(11)
猜谜语啦(7)
Xrosstools tool installation for X-Series
MATLAB skills (28) Fuzzy Comprehensive Evaluation
Array integration initialization (C language)
Esphone Feixun DC1 soft change access homeassstant
Example 001: the number combination has four numbers: 1, 2, 3, 4. How many three digits can be formed that are different from each other and have no duplicate numbers? How many are each?
实例002:“个税计算” 企业发放的奖金根据利润提成。利润(I)低于或等于10万元时,奖金可提10%;利润高于10万元,低于20万元时,低于10万元的部分按10%提成,高于10万元的部分,可提成7.
【日常訓練--騰訊精選50】557. 反轉字符串中的單詞 III
Stm32--- systick timer
剑指 Offer 06. 从尾到头打印链表
How can fresh students write resumes to attract HR and interviewers
Illustration of eight classic pointer written test questions
Is the security account given by Yixue school safe? Where can I open an account
[NAS1](2021CVPR)AttentiveNAS: Improving Neural Architecture Search via Attentive Sampling (未完)
Example 005: three numbers sorting input three integers x, y, Z, please output these three numbers from small to large.