请选择 进入手机版 | 继续访问电脑版

Hello Mat

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 1079|回复: 1

相机标定map_image

[复制链接]

41

主题

67

帖子

1152

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1152
发表于 2020-4-19 09:35:44 | 显示全部楼层 |阅读模式
相机标定map_image:
  1. dev_close_window ()
  2. dev_open_window (0, 0, 768 / 2, 576 / 2, 'black', WindowHandle1)
  3. set_display_font (WindowHandle1, 14, 'mono', 'true', 'false')
  4. dev_update_off ()
  5. dev_set_draw ('margin')
  6. dev_set_line_width (2)
  7. *
  8. * Calibrate the camera.
  9. *
  10. CalTabDescrFile := 'caltab_big.descr'
  11. * Make sure that the file 'CaltabName' is in the current directory,
  12. * the HALCONROOT/calib directory, or use an absolute path
  13. StartCamPar := [0.008,0,0.0000086,0.0000086,384,288,768,576]
  14. create_calib_data ('calibration_object', 1, 1, CalibDataID)
  15. set_calib_data_cam_param (CalibDataID, 0, 'area_scan_division', StartCamPar)
  16. set_calib_data_calib_object (CalibDataID, 0, CalTabDescrFile)
  17. NumImages := 9
  18. for I := 1 to NumImages by 1
  19.     read_image (Image, 'C:/Users/Public/Documents/MVTec/HALCON-12.0/examples/images/calib/calib-3d-coord-0' + I + '.png')
  20.     dev_display (Image)
  21.     Message := 'Find calibration plate in\nall calibration images (' + I + '/' + NumImages + ')'
  22.     disp_message (WindowHandle1, Message, 'window', 12, 12, 'black', 'true')
  23.     * Find the calibration plate
  24.     find_calib_object (Image, CalibDataID, 0, 0, I - 1, [], [])
  25.     get_calib_data (CalibDataID, 'camera', 0, 'init_params', StartCamPar)
  26.     get_calib_data_observ_points (CalibDataID, 0, 0, I - 1, Row, Column, Index, Pose)
  27.     get_calib_data_observ_contours (Contours, CalibDataID, 'caltab', 0, 0, I - 1)
  28.     gen_cross_contour_xld (Cross, Row, Column, 6, 0.785398)
  29.     dev_set_color ('green')
  30.     dev_display (Contours)
  31.     dev_set_color ('yellow')
  32.     dev_display (Cross)
  33. endfor
  34. disp_continue_message (WindowHandle1, 'black', 'true')
  35. stop ()
  36. calibrate_cameras (CalibDataID, Error)
  37. get_calib_data (CalibDataID, 'camera', 0, 'params', CamParam)
  38. gen_empty_obj (Maps)
  39. for I := 1 to NumImages by 1
  40.     * Obtain the pose of the calibration table
  41.     get_calib_data (CalibDataID, 'calib_obj_pose', [0,I - 1], 'pose', Pose)
  42.     set_origin_pose (Pose, -1.125, -1.0, 0, PoseNewOrigin)
  43.     * Generate map
  44.     gen_image_to_world_plane_map (MapSingle, CamParam, PoseNewOrigin, 768, 576, 900, 800, 0.0025, 'bilinear')
  45.     concat_obj (Maps, MapSingle, Maps)
  46. endfor
  47. clear_calib_data (CalibDataID)
  48. disp_continue_message (WindowHandle1, 'black', 'true')
  49. stop ()
  50. *
  51. * Map the images
  52. *
  53. dev_open_window (0, 391, 900 / 2, 800 / 2, 'black', WindowHandle2)
  54. set_display_font (WindowHandle2, 14, 'mono', 'true', 'false')
  55. Button := 0
  56. NumImage := 1
  57. for I := 1 to NumImages by 1
  58.     dev_set_window (WindowHandle1)
  59.     dev_set_part (0, 0, 575, 767)
  60.     dev_clear_window ()
  61.     read_image (Image, 'C:/Users/Public/Documents/MVTec/HALCON-12.0/examples/images/calib/calib-3d-coord-0' + I + '.png')
  62.     dev_display (Image)
  63.     select_obj (Maps, MapSingle, I)
  64.     map_image (Image, MapSingle, ImageMapped)
  65.     dev_set_window (WindowHandle2)
  66.     dev_set_part (0, 0, 799, 899)
  67.     dev_clear_window ()
  68.     dev_display (ImageMapped)
  69.     Message := 'Calibration image (' + I + '/' + NumImages + ')'
  70.     disp_message (WindowHandle1, Message, 'window', 12, 12, 'black', 'true')
  71.     Message := 'Mapped image'
  72.     disp_message (WindowHandle2, Message, 'window', 12, 12, 'black', 'true')
  73. endfor
  74. stop ()
复制代码


PS:
【1】StartCamPar := [Focus, Kappa, Sx, Sy, Cx, Cy, ImageWidth, ImageHeight]
【2】单目相机标定
【3】'caltab.descr':File name of the calibration plate description.



本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Python|Opencv|MATLAB|Halcom.cn  

GMT+8, 2020-6-2 14:22 , Processed in 0.140793 second(s), 28 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表