当前位置:网站首页>Shape template matching based on Halcon learning [VII] reuse_ model. Hdev routine
Shape template matching based on Halcon learning [VII] reuse_ model. Hdev routine
2022-07-05 07:55:00 【BoomBiuBiu】
This sample program shows how to reuse the created model .
1、 Read the picture
dev_update_window ('off')
* Read the picture
read_image (ModelImage, 'rings_and_nuts')
* Get a channel Pointer( Indicator )
get_image_pointer1 (ModelImage, Pointer, Type, Width, Height)
dev_close_window ()
dev_open_window (0, 0, Width, Height, 'white', WindowHandle)
dev_set_part (0, 0, Height - 1, Width - 1)
dev_display (ModelImage)
* Set some column parameters
dev_set_color ('cyan')
dev_set_draw ('margin')
dev_set_line_width (2)
set_display_font (WindowHandle, 14, 'mono', 'true', 'false')
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
2、 Create a template
* Create a template
Row := 324
Column := 279
Radius := 60
gen_circle (ROI1, Row, Column, Radius)
gen_circle (ROI2, Row, Column, 0.5 * Radius)
* Difference set
difference (ROI1, ROI2, ModelROI)
* Cutout
reduce_domain (ModelImage, ModelROI, ImageROI)
* Create a template
create_scaled_shape_model (ImageROI, 'auto', -rad(30), rad(60), 'auto', 0.6, 1.4, 'auto', 'none', 'use_polarity', 60, 10, ModelID)
inspect_shape_model (ImageROI, ShapeModelImage, ShapeModelRegion, 1, 30)
dev_clear_window ()
dev_display (ShapeModelRegion)
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
3、 The storage model ( Include XLD)
ModelFile := 'model_nut.sbm'
* Save template
write_shape_model (ModelID, ModelFile)
* Besides , We store the model area
ModelRegionFile := 'model_region_nut.png'
write_image (ImageROI, 'png', 0, ModelRegionFile)
* Clear template
clear_shape_model (ModelID)
4、 Read the model from the file
read_shape_model (ModelFile, ReusedModelID)
* Access the parameters used to create the model
get_shape_model_contours (ReusedShapeModel, ReusedModelID, 1)
get_shape_model_origin (ReusedModelID, ReusedRefPointRow, ReusedRefPointCol)
get_shape_model_params (ReusedModelID, NumLevels, AngleStart, AngleExtent, AngleStep, ScaleMin, ScaleMax, ScaleStep, Metric, MinContrast)
* Access model area
read_image (ImageModelRegion, 'model_region_nut.png')
get_domain (ImageModelRegion, DomainModelRegion)
dev_display (ImageModelRegion)
dev_display (DomainModelRegion)
stop ()
5、 Search for
read_image (SearchImage, 'rings_and_nuts')
dev_display (SearchImage)
* Begin to match
find_scaled_shape_model (SearchImage, ReusedModelID, AngleStart, AngleExtent, ScaleMin, ScaleMax, 0.65, 0, 0, 'least_squares', 0, 0.8, RowCheck, ColumnCheck, AngleCheck, ScaleCheck, Score)
for i := 0 to |Score| - 1 by 1
* Affine transformation
vector_angle_to_rigid (ReusedRefPointRow, ReusedRefPointCol, 0, RowCheck[i], ColumnCheck[i], AngleCheck[i], MovementOfObject)
hom_mat2d_scale (MovementOfObject, ScaleCheck[i], ScaleCheck[i], RowCheck[i], ColumnCheck[i], MoveAndScalingOfObject)
affine_trans_contour_xld (ReusedShapeModel, ModelAtNewPosition, MoveAndScalingOfObject)
dev_display (ModelAtNewPosition)
endfor
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
6、 Clear template
clear_shape_model (ModelID)
边栏推荐
- Opendrive arc drawing script
- Fundamentals of C language
- Temperature sensor DS18B20 principle, with STM32 routine code
- Global and Chinese markets of large aperture scintillators 2022-2028: Research Report on technology, participants, trends, market size and share
- UEFI development learning 5 - simple use of protocol
- The research found that the cross-border e-commerce customer service system has these five functions!
- Software designer: 03 database system
- Acwing - the collection of pet elves - (multidimensional 01 Backpack + positive and reverse order + two forms of DP for the answer)
- 找不到实时聊天软件?给你推荐电商企业都在用的!
- Screen record of the opening ceremony of the Beijing winter olympics 2
猜你喜欢
Ads usage skills
如何进行导电滑环选型
Embedded composition and route
[untitled] record the visual shock of the Winter Olympics and the introduction of the display screen
Network port usage
生产中影响滑环质量的因素
Extended application of single chip microcomputer-06 independent key
UEFI development learning 2 - running ovmf in QEMU
Basic embedded concepts
Improve lighting C program
随机推荐
Use stm32cubemx tool to write the demo program of FreeRTOS
Process communication mode between different hosts -- socket
研究發現,跨境電商客服系統都有這五點功能!
Esmini longspeedaction modification
LED display equipment records of the opening ceremony of the Beijing Winter Olympics
A series of problems in offline installation of automated test environment (ride)
Can't find real-time chat software? Recommend to you what e-commerce enterprises are using!
How to define guid in AMI code
L'étude a révélé que le système de service à la clientèle du commerce électronique transfrontalier a ces cinq fonctions!
MySql——存储引擎
Global and Chinese markets for waste treatment air switches 2022-2028: Research Report on technology, participants, trends, market size and share
Drive LED -- GPIO control
Makefile application
How to select conductive slip ring
Acwing - the collection of pet elves - (multidimensional 01 Backpack + positive and reverse order + two forms of DP for the answer)
Global and Chinese market of digital shore durometer 2022-2028: Research Report on technology, participants, trends, market size and share
IC software learning
GPIO circuit principle of stm32
A simple method to prove 1/t Fourier transform
Shell脚本基本语法