当前位置:网站首页>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')
边栏推荐
- 2020-05-21
- 696. 计数二进制子串
- Lori remote control commissioning record
- Basic number theory - factors
- Example 002: the bonus paid by the "individual income tax calculation" enterprise is based on the profit commission. When the profit (I) is less than or equal to 100000 yuan, the bonus can be increase
- 287. Looking for repeats - fast and slow pointer
- C# LINQ源码分析之Count
- Bit operation related operations
- C语言标准函数scanf不安全的原因
- 猜谜语啦(7)
猜你喜欢
实例003:完全平方数 一个整数,它加上100后是一个完全平方数,再加上168又是一个完全平方数,请问该数是多少?
实例001:数字组合 有四个数字:1、2、3、4,能组成多少个互不相同且无重复数字的三位数?各是多少?
实例004:这天第几天 输入某年某月某日,判断这一天是这一年的第几天?
Count the number of inputs (C language)
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?
剑指 Offer 05. 替换空格
Bluebridge cup internet of things basic graphic tutorial - GPIO input key control LD5 on and off
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?
Bluebridge cup internet of things basic graphic tutorial - GPIO output control LD5 on and off
STM32---IIC
随机推荐
Business modeling of software model | overview
How apaas is applied in different organizational structures
Xrosstools tool installation for X-Series
The first week of summer vacation
UE pixel stream, come to a "diet pill"!
Cinq détails de conception du régulateur de tension linéaire
Business modeling of software model | object modeling
696. Count binary substring
实例002:“个税计算” 企业发放的奖金根据利润提成。利润(I)低于或等于10万元时,奖金可提10%;利润高于10万元,低于20万元时,低于10万元的部分按10%提成,高于10万元的部分,可提成7.
C语言标准函数scanf不安全的原因
Array integration initialization (C language)
Search data in geo database
Agile project management of project management
2020-05-21
如何写Cover Letter?
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
Yolov4 target detection backbone
Run menu analysis