HALCON学习之条形码实时扫描

 1 dev_open_window(1,1,400,400,'blue',ThisHandle)
 2 create_bar_code_model([], [], BarCodeHandle)
 3 set_bar_code_param(BarCodeHandle,'element_size_max',8)
 4 set_bar_code_param(BarCodeHandle,'check_char','present')
 5 set_bar_code_param(BarCodeHandle,'persistence',1)
 6 set_bar_code_param(BarCodeHandle,'composite_code','none')
 7 set_bar_code_param(BarCodeHandle,'meas_thresh',0.1)
 8 set_bar_code_param(BarCodeHandle,'num_scanlines',10)
 9 set_bar_code_param(BarCodeHandle,'min_identical_scanlines',2)
10 set_bar_code_param(BarCodeHandle,'max_diff_orient',10)
11 set_bar_code_param(BarCodeHandle,'element_height_min',8)
12 set_bar_code_param(BarCodeHandle,'stop_after_result_num',1)
13 *read_image(img,'C:/Users/IBM_ADMIN/Desktop/Halcon/2.jpg')
14 *get_image_size (img, Width, Height)
15 *dev_set_window_extents (0, 0, Width-1, Height-1)
16 *find_bar_code(img,SymbolRegions,BarCodeHandle,'auto',DecodedataStrings)
17 *get_bar_code_result(BarCodeHandle,'all','decoded_types',DecodedDataTypes)
18 *dev_close_window()
19 * open computer camera
20 open_framegrabber ('DirectShow', 1, 1, 0, 0, 0, 0, 'default', -1, 'gray', -1, 'default', 'default', '0', -1, -1, AcqHandle1)
21 * open another USB camera
22 *open_framegrabber ('DirectShow', 1, 1, 0, 0, 0, 0, 'default', -1, 'gray', -1, 'default', 'default', '1', -1, -1, AcqHandle1)
23 condition := true
24 set_window_param(ThisHandle,'background_color','gray')
25 *grab_image_start(AcqHandle1,-1000)
26 while(condition)    
27     *grab_image_async(BarImage,AcqHandle1, -1000)
28     grab_image (BarImage, AcqHandle1)
29     find_bar_code(BarImage,SymbolRegions,BarCodeHandle,'auto',scannString)
30     if(|scannString| >= 1)
31         dev_display(BarImage)
32         disp_message(ThisHandle,scannString,'window',12,12,'blue','false')
33         disp_continue_message(ThisHandle,'black','true')
34         stop()
35         condition := false
36     endif
37 endwhile
38 clear_all_bar_code_models()
39 close_all_framegrabbers()
40 dev_close_window()
原文地址:https://www.cnblogs.com/liuzebei/p/5458700.html