C# +HALCON 工业相机调试

HALCON error #5312: Image acquisition:device cannot be initialized in operator

   winform和HDevelop同时对相机进行连接导致的。关闭其中一个就可以正常连接相机。

HALCON error #5301 Image acquisition: wrong color depth

  取相时,报异常。原因是open_framegrabber的ColorSpace参数设置为rgb。但是相机是黑白相机。修改ColorSpace可取图。

HALCON error #5329: Image acquisition: could not set parameter value in operator set_framegrabber_param

set_framegrabber_param算子区分大小写。ON写入失败,On写入成功。

软触发事件取图

eg

* Image Acquisition 01: Code generated by Image Acquisition 01
open_framegrabber ('GigEVision', 0, 0, 0, 0, 0, 0, 'default', -1, 'default', -1, 'false', 'default', 'cam4', 0, -1, AcqHandle)
set_framegrabber_param (AcqHandle, 'TriggerMode', 'On')
set_framegrabber_param (AcqHandle, 'TriggerSource', 'Software')
grab_image_start (AcqHandle, -1)
while (true)
    set_framegrabber_param (AcqHandle, 'TriggerSoftware', '1')
    grab_image_async (Image, AcqHandle, -1)
    get_image_time (Image, MSecond, Second, Minute, Hour, Day, YDay, Month, Year)
    *时间格式:年_月_日_时_分_秒_毫秒
     DayString := Year$'4d' +'_'+ Month$'02d' + '_'+Day$'02d'+'_'
    TimeString := Hour$'02d' +'_'+ Minute$'02d' + '_'+Second$'02d'+'_'+MSecond$'03d'
     write_image (Image, 'jpeg', 0, 'C:/Users/Administrator/Desktop/Test/'+DayString+TimeString+'.jpeg')
     wait_seconds (2)
endwhile
close_framegrabber (AcqHandle)

你可能感兴趣的:(笔记,工作记录)