当前位置:网站首页>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 :
边栏推荐
- C WinForm [exit application] - practice 3
- Detailed explanation of pragma usage
- Day06 class variables instance variables local variables constant variables naming conventions
- . Net service governance flow limiting middleware -fireflysoft RateLimit
- STM32 learning method
- C # joint configuration with Halcon
- Can't find real-time chat software? Recommend to you what e-commerce enterprises are using!
- Day07 type of mathematical operator automatic conversion relational operator bitwise operator blind date math
- Baiwen 7-day smart home learning experience of Internet of things
- UEFI development learning 5 - simple use of protocol
猜你喜欢
Altium designer learning (I)
A simple method to prove 1/t Fourier transform
The printer encountered an abnormal configuration problem 0x8007007e (win10)
Application of ultra pure water particle counter in electronic semiconductors
Record the opening ceremony of Beijing Winter Olympics with display equipment
软件设计师:03-数据库系统
Win10 shortcut key
C WinForm [help interface - send email] - practice five
万字详解八大排序 必读(代码+动图演示)
Embedded AI intelligent technology liquid particle counter
随机推荐
Global and Chinese markets for recycled boilers 2022-2028: Research Report on technology, participants, trends, market size and share
.NET服务治理之限流中间件-FireflySoft.RateLimit
The research found that the cross-border e-commerce customer service system has these five functions!
Random function usage notes
Day08 ternary operator extension operator character connector symbol priority
A series of problems in offline installation of automated test environment (ride)
Count and sort the occurrence times of specific fields through SQL statements
Screen record of the opening ceremony of the Beijing winter olympics 2
UEFI development learning series
The browser cannot access Baidu
Global and Chinese market of digital shore durometer 2022-2028: Research Report on technology, participants, trends, market size and share
RF ride side door processing of prompt box
Global and Chinese markets for waste treatment air switches 2022-2028: Research Report on technology, participants, trends, market size and share
Some errors in configuring the environment
Record the opening ceremony of Beijing Winter Olympics with display equipment
Global and Chinese market of core pallets 2022-2028: Research Report on technology, participants, trends, market size and share
Could NOT find XXX (missing: XXX_LIBRARY XXX_DIR)
Nombre - 1. Création de tableaux
UEFI development learning 2 - running ovmf in QEMU
C WinForm [help interface - send email] - practice five