当前位置:网站首页>Halcon's practice based on shape template matching [2]
Halcon's practice based on shape template matching [2]
2022-07-05 07:56:00 【BoomBiuBiu】
Reprint here with code , The result is the same as that displayed by the matching assistant
* Image Acquisition 01: Code generated by Image Acquisition 01
* Turn on camera
open_framegrabber ('DirectShow', 1, 1, 0, 0, 0, 0, 'default', 8, 'rgb', -1, 'false', 'default', '[0] Web Camera', 0, -1, AcqHandle)
grab_image_start (AcqHandle, -1)
* Create a template , First show the pictures captured by the camera grab_image_start (AcqHandle, -1)
grab_image_async (Image, AcqHandle, -1)
* use ROI Draw a rectangle
gen_rectangle2 (ROI_0, 291.907, 1059.07, rad(-90), 138.921, 92.1362)
* Cutout
reduce_domain (Image, ROI_0, ImageReduced)
* The starting angle and ending angle are determined by 0-0 Change it to rad(0)-rad(360)
* Create a template
create_scaled_shape_model (ImageReduced, 'auto',rad(0), rad(360), 'auto', 0.9, 1.1, 'auto', 'auto', 'use_polarity', 'auto', 'auto', ModelID)
* Or the outline of the template
get_shape_model_contours (Model, ModelID, 1)
* Set the color
dev_set_color ('red')
* Set the line width
dev_set_line_width (3)
while (true)
grab_image_async (Image, AcqHandle, -1)
* The starting angle and ending angle are changed to rad(0)-rad(360)
* Find template
find_scaled_shape_model (Image, ModelID, rad(0), rad(360), 0.9, 1.1, 0.5, 10, 0.5, 'least_squares', 0, 0.9, Row, Column, Angle, Scale, Score)
* Judge whether there is a target in the area , Otherwise, an error will be reported
if(|Score|>0)
* Target by target
for I := 0 to |Score| - 1 by 1
* Unit matrix
hom_mat2d_identity (HomMat2DIdentity)
* Translation matrix
hom_mat2d_translate (HomMat2DIdentity, Row[I], Column[I], HomMat2DTranslate)
* Rotation matrix
hom_mat2d_rotate (HomMat2DTranslate, Angle[I], Row[I], Column[I], HomMat2DRotate)
* Zoom matrix
hom_mat2d_scale (HomMat2DRotate, Scale[I], Scale[I], Row[I], Column[I], HomMat2DScale)
* Show the outline
affine_trans_contour_xld (Model, ModelTrans, HomMat2DScale)
dev_display (Image)
dev_display (ModelTrans)
endfor
endif
endwhile
* Turn off camera
close_framegrabber (AcqHandle)
result :
notes : The affine transformation here can be replaced by other operators
* Unit matrix
hom_mat2d_identity (HomMat2DIdentity)
* Translation matrix
hom_mat2d_translate (HomMat2DIdentity, Row[I], Column[I], HomMat2DTranslate)
* Rotation matrix
hom_mat2d_rotate (HomMat2DTranslate, Angle[I], Row[I], Column[I], HomMat2DRotate)
* Zoom matrix
hom_mat2d_scale (HomMat2DRotate, Scale[I], Scale[I], Row[I], Column[I], HomMat2DScale)
*-----------------------
* The following operators can be used instead
vector_angle_to_rigid (0, 0, 0, Row[I], Column[I], Angle[I], HomMat2D1)
* Zoom matrix
hom_mat2d_scale (HomMat2D1, Scale[I], Scale[I], Row[I], Column[I], HomMat2DScale)
result :
边栏推荐
- How to define guid in AMI code
- Batch modify the txt file code to UTF-8 (notepad++)
- Global and Chinese market of digital shore durometer 2022-2028: Research Report on technology, participants, trends, market size and share
- Basic embedded concepts
- C#,数值计算(Numerical Recipes in C#),线性代数方程的求解,LU分解(LU Decomposition)源程序
- Altium Designer 19.1.18 - 导入板框
- assert_ Usage of param function
- Some tips for using source insight (solve the problem of selecting all)
- Record the visual shock of the Winter Olympics and the introduction of the screen 2
- Acwing-宠物小精灵之收服-(多维01背包+正序倒序+两种形式dp求答案)
猜你喜欢
UEFI development learning 6 - creation of protocol
C#,数值计算(Numerical Recipes in C#),线性代数方程的求解,LU分解(LU Decomposition)源程序
How to select conductive slip ring
1-stm32 operation environment construction
Factors affecting the quality of slip rings in production
MySQL - storage engine
mysql 盲注常见函数
The research found that the cross-border e-commerce customer service system has these five functions!
Practical application cases of digital Twins - fans
C WinForm [help interface - send email] - practice five
随机推荐
Extended application of single chip microcomputer-06 independent key
Record the torch encountered by win10 cuda. is_ False problem in available()
Use of orbbec Astra depth camera of OBI Zhongguang in ROS melody
Network port usage
Detailed explanation of C language pointer
Programming knowledge -- basis of C language
Global and Chinese market of quenching furnaces 2022-2028: Research Report on technology, participants, trends, market size and share
About yolov3, conduct map test directly
How to realize audit trail in particle counter software
Embedded composition and route
Day08 ternary operator extension operator character connector symbol priority
Fundamentals of C language
Global and Chinese markets of large aperture scintillators 2022-2028: Research Report on technology, participants, trends, market size and share
Create inf module in AMI code
研究发现,跨境电商客服系统都有这五点功能!
Acwing - the collection of pet elves - (multidimensional 01 Backpack + positive and reverse order + two forms of DP for the answer)
Cadence learning records
Embedded AI intelligent technology liquid particle counter
Count and sort the occurrence times of specific fields through SQL statements
The global and Chinese market of lithographic labels 2022-2028: Research Report on technology, participants, trends, market size and share