当前位置:   article > 正文

halcon海康双相机采集与标定_海康相机标定

海康相机标定

 1.相机设置

相机设置自动曝光,bayerRG8, 触发模式关闭,触发源=软触发
 

2.异步采集 设置及程序

采集助手设置 colortype=default bit=8

相机分辨率3072x2048,下采样2=1536x1024,否则无法采集

  1. * Example for grabbing images from two GigEVision cameras.
  2. *
  3. * For this example we assume that both cameras are connected
  4. * to the PC directly. If the cameras are connected to the PC
  5. * via a switch please refer to the example
  6. * gigevision2_interpacket_delay.hdev.
  7. *
  8. *
  9. dev_close_window ()
  10. dev_close_window ()
  11. info_framegrabber ('GigEVision2', 'device', Information, Devices)
  12. while (|Devices| < 2)
  13. * This example requires two GigEVision cameras.
  14. endwhile
  15. scale:=5
  16. open_framegrabber ('GigEVision2', 0, 0, 0, 0, 0, 0, 'progressive', 8, 'default', -1, 'false', 'default', 'LL', 0, -1, AcqHandle1)
  17. get_framegrabber_param (AcqHandle1, ['image_width','image_height'], ImageSize1)
  18. dev_open_window (0, 0, ImageSize1[0] / scale, ImageSize1[1] / scale, 'black', WindowHandle1)
  19. open_framegrabber ('GigEVision2', 0, 0, 0, 0, 0, 0, 'progressive', 8, 'default', -1, 'false', 'default', 'RR', 0, -1, AcqHandle2)
  20. get_framegrabber_param (AcqHandle2, ['image_width','image_height'], ImageSize2)
  21. dev_open_window ((ImageSize1[0] / scale) + 10, 0, ImageSize2[0] / scale, ImageSize2[1]/ scale , 'black', WindowHandle2)
  22. * Deactivate HDevelop update for better performance.
  23. dev_update_off ()
  24. grab_image_start (AcqHandle1, -1)
  25. grab_image_start (AcqHandle2, -1)
  26. while (true)
  27. dev_set_window (WindowHandle1)
  28. *grab_image (Image1, AcqHandle1)
  29. grab_image_async (Image1, AcqHandle1, -1)
  30. dev_display (Image1)
  31. *
  32. dev_set_window (WindowHandle2)
  33. *grab_image(Image2, AcqHandle2)
  34. grab_image_async (Image2, AcqHandle2, -1)
  35. dev_display (Image2)
  36. endwhile
  37. dev_close_window ()
  38. dev_close_window ()
  39. close_framegrabber (AcqHandle1)
  40. close_framegrabber (AcqHandle2)

3.新建程序,创建标定板文件

 我的标定板尺寸:外形70x70,图案56x56,直径3.5,圆心距7,阵列7x7

gen_caltab (7, 7, 0.07, 0.5, 'caltab_hc070x_56x_7_35.descr', 'caltabcaltab_hc070x_56x_7_35.ps')

执行后当前目录产生对应2个文件 ,只用描述文件。ps是photoshop文件

4.打开标定助手

引入上面描述文件

线扫描多相式,单个像素宽2.4um,焦距3.37mm,其他默认

我的海康相机cb060:

传感器类型CMOS,卷帘快门
传感器型号IMX178
像元尺寸2.4 µm × 2.4 µm
靶面尺寸1/1.8”
分辨率3072 × 2048

生成标定函数

  1. * Calibration 03: Code generated by Calibration 03
  2. ImageFiles := []
  3. TmpCtrl_ReferenceIndex := -1
  4. TmpCtrl_PlateDescription := '/opt/halcon/calib/calplate_80mm.cpd'
  5. StartParameters := ['line_scan_polynomial',0.00337,0,0,0,0,0,2.4e-06,2.4e-06,320,0,640,480,0,0.0005,0]
  6. TmpCtrl_FindCalObjParNames := 'sigma'
  7. TmpCtrl_FindCalObjParValues := 1
  8. * Calibration 03: Create calibration model for managing calibration data
  9. create_calib_data ('calibration_object', 1, 1, CalibHandle)
  10. set_calib_data_cam_param (CalibHandle, 0, [], StartParameters)
  11. set_calib_data_calib_object (CalibHandle, 0, TmpCtrl_PlateDescription)
  12. * Calibration 03: Collect mark positions and estimated poses for all plates
  13. for Index := 0 to |ImageFiles|-1 by 1
  14. read_image (Image, ImageFiles[Index])
  15. * Calibration 03: No image files. Please load images first!
  16. endfor
  17. * Calibration 03: Perform the actual calibration
  18. calibrate_cameras (CalibHandle, TmpCtrl_Errors)
  19. get_calib_data (CalibHandle, 'camera', 0, 'params', CameraParameters)
  20. get_calib_data (CalibHandle, 'calib_obj_pose', [0, TmpCtrl_ReferenceIndex], 'pose', CameraPose)
  21. * Calibration 03: Adjust origin for plate thickness
  22. set_origin_pose (CameraPose, 0.0, 0.0, 0.001, CameraPose)
  23. stop ()

5.标定

线阵相机矫正所需参数共17个

11个参数为内参CamParam:= [Focus, Kappa, Sx, Sy, Cx, Cy, ImageWidth, ImageHeight, Vx, Vy, Vz]

6个参数分别为x,y,z三个轴的旋转角度和x,y,z三个轴的平移量

4. ------------------------

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/561442
推荐阅读
相关标签
  

闽ICP备14008679号