当前位置:网站首页>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 :


边栏推荐
- Significance and requirements of semiconductor particle control
- Global and Chinese market of plastic recycling machines 2022-2028: Research Report on technology, participants, trends, market size and share
- .NET服务治理之限流中间件-FireflySoft.RateLimit
- Ads learning record (lna_atf54143)
- RTOS in the development of STM32 single chip microcomputer
- MLPerf Training v2.0 榜单发布,在同等GPU配置下百度飞桨性能世界第一
- 如何进行导电滑环选型
- 1089 insert or merge, including test point 5
- STM32 knowledge points
- Global and Chinese market of core pallets 2022-2028: Research Report on technology, participants, trends, market size and share
猜你喜欢

Connection mode - bridge and net

The research found that the cross-border e-commerce customer service system has these five functions!

Altium Designer 19.1.18 - 隐藏某一个网络的飞线

Process communication mode between different hosts -- socket

L'étude a révélé que le système de service à la clientèle du commerce électronique transfrontalier a ces cinq fonctions!

Network communication process

Screen record of the opening ceremony of the Beijing winter olympics 2

Altium Designer 19.1.18 - 导入板框

Mlperf training v2.0 list released, with the same GPU configuration, the performance of Baidu PaddlePaddle ranks first in the world

Network communication model -- Network OSI tcp/ip layering
随机推荐
Altium Designer 19.1.18 - 隐藏某一个网络的飞线
Nombre - 1. Création de tableaux
QT's excellent articles
Day01 markdown log entry tips
Fundamentals of C language
UEFI development learning 4 - getting to know variable services
Improve lighting C program
Programming knowledge -- assembly knowledge
A series of problems in offline installation of automated test environment (ride)
[untitled] record the visual shock of the Winter Olympics and the introduction of the display screen
Application of ultra pure water particle counter in electronic semiconductors
C language enhancement -- pointer
Latex notes
Reasons for rapid wear of conductive slip rings
Altium Designer 19.1.18 - 清除测量距离产生的信息
2021-10-28
Global and Chinese markets of large aperture scintillators 2022-2028: Research Report on technology, participants, trends, market size and share
Random function usage notes
PIL's image tool image reduction and splicing.
Global and Chinese markets for flexible endoscopic lithotripsy devices 2022-2028: Research Report on technology, participants, trends, market size and share