ZV_REGION(copy_subImg, modRe, 1, 0) 'Draw the invalid area of modRe image on the template image, the drawing color is black, used as mask
ZV_LATCH(copy_subImg, 1) 'Show the copied template image
end sub
'Update the eraser area
GLOBAL SUB draw_eraser()
if d_edit_m = 0 then 'If the template is edited
return 'Return to the sub-function and do not continue to execute
endif
DRAWRECT(c_rect(0), c_rect(1), c_rect(2), c_rect(3))'Draw the eraser area
END SUB
15
In the main.bas file, add a function that responds to the [Create Template] button on the edit template interface and associate it with the action function.
↓
'The function that responds when the create template button is pressed on the edit template interface
GLOBAL SUB btn_loc_creModel()
d_is_creModel = 1
ZV_SHAPECREATERE(subImg, modRe,s_mod, d_mod_param(0), d_mod_param(1), d_mod_param(2), d_mod_param(3), d_mod_param(4), d_mod_param(5), d_mod_param(6), d_mod_param(7), d_mod_param( 8))
'Create a template
ZV_SHAPECONTOURS(s_mod, contlist1, 0) 'Get the template contour on the 0th pyramid
ZV_GRAYTORGB(subImg, colorSubImg) 'Convert grayscale image to RGB image
ZV_IMGINFO(colorSubImg, 0) 'Get colorSubImg image information and store it in table0
ZV_GETRIGIDVECTOR(mat_rigid1, 0, 0, 0, TABLE(0)/2, TABLE(1)/2, 0)' Calculate the rigid transformation matrix
ZV_CONTAFFINE(contlist1, mat_rigid1, tsContlist1)'Affine transformation of contour or contour sequence
ZV_CONTLIST(colorSubImg, tsContlist1, ZV_COLOR(0, 255, 0), 0) 'Draw a green contour sequence on the colorSubImg image
ZV_LATCHCLEAR(2)
ZV_LATCH(colorSubImg, 2)
end sub
↓
16
In the draw.bas file, add a function that responds to the [OK] button in the editing template interface and associate it with the action function.
↓
'The function executed when the OK button is pressed on the editing template interface
GLOBAL SUB btn_erase_cfm()
ZV_LATCHCLEAR(0)
ZV_LATCH(grabImg, 0) 'Display image on latch
HMI_CLOSEWINDOW(12) 'Close the template editing window
END SUB
↓
17
In the main.bas file, add a function to create a response to the [Test] button in the template interface and associate it with the action function.
↓
'Create a function that responds when the test button is pressed on the template interface
GLOBAL SUB btn_loc_test()
if (d_is_creModel = 0) then
?"Template not created!"
return
endif
'Start matching
TICKS = 0
ZVOBJECT match_rst, sIm g, colorImg
ZV_GAUSSBLUR(grabImg, sImg, 3)
ZV_SHAPEFIND(s_mod, sImg, match_rst, d_match_param(0), d_match_param(1), d_match_param(2), d_match_param(3), d_match_param(4), d_match_param(5), d_match_param(6))
ZV_MATINFO(match_rst, 0)
ZV_GRAYTORGB(sImg, colorImg)
if TABLE(0) > 0 then
local rowr
for rowr = 0 to TABLE(0) -1
ZV_MATGETROW(match_rst, rowr, 5, 3) 'Get the data of rowr in the match_rst matrix into table. The maximum length of table is 5
if(rowr = 0) then
d_match_rst(0) = TABLE(3)
d_match_rst(1) = TABLE(4)
d_match_rst(2) = TABLE(5)
d_match_rst(3) = TABLE(6)
d_match_rst(4) = TABLE(7)
ZV_GETRIGIDVECTOR(mat_rigid1, 0, 0, 0, TABLE(4), TABLE(5), TABLE(6))'Calculate the rigid transformation matrix
ZV_CONTAFFINE(contlist1, mat_rigid1, tsContlist1)'Affine transformation of contour or contour sequence
ZV_CONTLIST(colorImg, tsContlist1, ZV_COLOR(0, 255, 0), 0) 'Draw a green contour sequence on the colorSubImg image
endif
next
else
d_match_rst(0) = -1
d_match_rst(1) = -1
d_match_rst(2) = -1
d_match_rst(3) = -1
d_match_rst(4) = -1
endif
d_match_time = abs(TICKS) 'match time
ZV_LATCH(colorImg, 0)
end sub
↓
18
In the draw.bas file, add a function to create a template interface [OK] button response and associate it with the action function.
↓
'Create a function that responds when the OK button is pressed on the template interface
GLOBAL SUB btn_loc_cfm()
grab_switch = 0 'Turn off continuous acquisition of correction source
d_is_rtn_loc = 1
ZV_LATCHCLEAR(0)
ZV_LATCH(grabImg, 0) 'Display image on latch
ZV_LATCH(grabImg, 1) 'Display image on latch
HMI_CLOSEWINDOW(11)
END SUB
↓
19
In the main.bas file, add a function that responds to the [Single Execution] button on the main interface and associate it with the action function.
↓
'The function that responds when the single execution button is pressed on the main interface
GLOBAL SUB btn_test()
btn_grab()' Single acquisition image
btn_loc_test() 'matching test function
END SUB
↓
20
In the main.bas file, add a function that responds to the [Continuous Run] button on the main interface and associate it with the action function.
↓
'The function that responds when the continuous run button is clicked on the main interface
GLOBAL SUB btn_run()
if(run_switch = 1) then
"Continuous operation has been started, please do not repeat the operation!"
return
endif
run_switch = 1
if (1 = run_switch) then
if (0 = PROC_STATUS(main_task_id)) then
RUNTASK main_task_id, main_task
endif
endif
END SUB
'Continuously run the main task content
main_task:
while(1)
if (0 = run_switch) then
exit while
endif
'The following performs related positioning operations
btn_grab()
btn_loc_test()
wend
END
↓
twenty one
In the main.bas file, add a function that responds to the [Stop Running] button on the main interface and associate it with the action function.
↓
'The function that responds when the stop execution button is clicked on the main interface
GLOBAL SUB btn_stop()
if(run_switch = 0) then
?"Continuous operation is not enabled!"
return
endif
run_switch = 0
END SUB
↓
Simulation Demonstration effect
This time, the VPLC series machine vision motion control all-in-one machine quick start (Part 3) - visual positioning based on shape matching is shared here.
Previous article:What is the output voltage of the torque motor controller?
Next article:ZMC Motion Controller SCARA Robot Application Quick Start
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- Brief Analysis of Automotive Ethernet Test Content and Test Methods
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- Do you know the power supply solutions for tethered, aerial/underwater drones? Vicor engineers tell you!
- Electrician certification questions, increase daily knowledge
- I want to build an oscillator circuit to generate a certain frequency, 10~100KHZ,
- How to learn FPGA technology?
- Announcement of Moderator Chip Coin and Physical Gift Rewards in November 2018
- Be the first to experience NUCLEO-WL55JC2, the world's first Lora SoC microcontroller!
- Brushless DC Motor
- 8 star products from industry leaders, listed on EDN Hot 100, let’s take a look
- What inverter chip should I use for a 200Khz square wave signal?
- EEWORLD University ---- Introduction to Intelligent Control