|
相机标定map_image:
- dev_close_window ()
- dev_open_window (0, 0, 768 / 2, 576 / 2, 'black', WindowHandle1)
- set_display_font (WindowHandle1, 14, 'mono', 'true', 'false')
- dev_update_off ()
- dev_set_draw ('margin')
- dev_set_line_width (2)
- *
- * Calibrate the camera.
- *
- CalTabDescrFile := 'caltab_big.descr'
- * Make sure that the file 'CaltabName' is in the current directory,
- * the HALCONROOT/calib directory, or use an absolute path
- StartCamPar := [0.008,0,0.0000086,0.0000086,384,288,768,576]
- create_calib_data ('calibration_object', 1, 1, CalibDataID)
- set_calib_data_cam_param (CalibDataID, 0, 'area_scan_division', StartCamPar)
- set_calib_data_calib_object (CalibDataID, 0, CalTabDescrFile)
- NumImages := 9
- for I := 1 to NumImages by 1
- read_image (Image, 'C:/Users/Public/Documents/MVTec/HALCON-12.0/examples/images/calib/calib-3d-coord-0' + I + '.png')
- dev_display (Image)
- Message := 'Find calibration plate in\nall calibration images (' + I + '/' + NumImages + ')'
- disp_message (WindowHandle1, Message, 'window', 12, 12, 'black', 'true')
- * Find the calibration plate
- find_calib_object (Image, CalibDataID, 0, 0, I - 1, [], [])
- get_calib_data (CalibDataID, 'camera', 0, 'init_params', StartCamPar)
- get_calib_data_observ_points (CalibDataID, 0, 0, I - 1, Row, Column, Index, Pose)
- get_calib_data_observ_contours (Contours, CalibDataID, 'caltab', 0, 0, I - 1)
- gen_cross_contour_xld (Cross, Row, Column, 6, 0.785398)
- dev_set_color ('green')
- dev_display (Contours)
- dev_set_color ('yellow')
- dev_display (Cross)
- endfor
- disp_continue_message (WindowHandle1, 'black', 'true')
- stop ()
- calibrate_cameras (CalibDataID, Error)
- get_calib_data (CalibDataID, 'camera', 0, 'params', CamParam)
- gen_empty_obj (Maps)
- for I := 1 to NumImages by 1
- * Obtain the pose of the calibration table
- get_calib_data (CalibDataID, 'calib_obj_pose', [0,I - 1], 'pose', Pose)
- set_origin_pose (Pose, -1.125, -1.0, 0, PoseNewOrigin)
- * Generate map
- gen_image_to_world_plane_map (MapSingle, CamParam, PoseNewOrigin, 768, 576, 900, 800, 0.0025, 'bilinear')
- concat_obj (Maps, MapSingle, Maps)
- endfor
- clear_calib_data (CalibDataID)
- disp_continue_message (WindowHandle1, 'black', 'true')
- stop ()
- *
- * Map the images
- *
- dev_open_window (0, 391, 900 / 2, 800 / 2, 'black', WindowHandle2)
- set_display_font (WindowHandle2, 14, 'mono', 'true', 'false')
- Button := 0
- NumImage := 1
- for I := 1 to NumImages by 1
- dev_set_window (WindowHandle1)
- dev_set_part (0, 0, 575, 767)
- dev_clear_window ()
- read_image (Image, 'C:/Users/Public/Documents/MVTec/HALCON-12.0/examples/images/calib/calib-3d-coord-0' + I + '.png')
- dev_display (Image)
- select_obj (Maps, MapSingle, I)
- map_image (Image, MapSingle, ImageMapped)
- dev_set_window (WindowHandle2)
- dev_set_part (0, 0, 799, 899)
- dev_clear_window ()
- dev_display (ImageMapped)
- Message := 'Calibration image (' + I + '/' + NumImages + ')'
- disp_message (WindowHandle1, Message, 'window', 12, 12, 'black', 'true')
- Message := 'Mapped image'
- disp_message (WindowHandle2, Message, 'window', 12, 12, 'black', 'true')
- endfor
- stop ()
复制代码
PS:
【1】StartCamPar := [Focus, Kappa, Sx, Sy, Cx, Cy, ImageWidth, ImageHeight]
【2】单目相机标定
【3】'caltab.descr':File name of the calibration plate description.
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|