* Image Acquisition 01: Code generated by Image Acquisition 01
open_framegrabber ('DirectShow', 1, 1, 0, 0, 0, 0, 'default', 8, 'rgb', -1, 'false', 'default', '[1] Webcam C170', 0, -1, AcqHandle)
grab_image_start (AcqHandle, -1)
grab_image_async (Image, AcqHandle, -1)
get_image_size (Image, Width, Height)
*转为灰度图像才能成功创建ncc模型
rgb1_to_gray (Image, grayImage)
dev_open_window (0, 0, Width, Height, 'black', WindowHandle)
dev_display (Image)
gen_circle (Cirle, 268, 324, 87.0057)
area_center (Cirle, Area, Row, Column)
reduce_domain (grayImage, Cirle, ImageReduced)
*创建ncc模型
create_ncc_model (ImageReduced, 'auto', -0.39, 0.79, 'auto', 'use_polarity', ModelID)
dev_set_draw ('margin')
dev_display (Cirle)
while (true)
grab_image_async (Image, AcqHandle, -1)
rgb1_to_gray (Image, grayImage)
* Image Acquisition 01: Do something
*找到匹配度最高的目标
find_ncc_model (grayImage, ModelID, -0.39, 0.79, 0.8, 1, 0.5, 'true', 0, Row, Column, Angle, Score)
dev_display (Image)
dev_display_ncc_matching_results (ModelID, 'green', Row, Column, Angle, 0)
endwhile
close_framegrabber (AcqHandle)
Halcon:瓶盖相关性目标识别NCC
于 2022-02-16 16:16:15 首次发布