手眼标定eye-to-hand 示例:handeye_stationarycam_calibration

世界坐标系就是标定板上的坐标系

*
* This example explains how to use the hand eye calibration for the case where
* the camera is stationary with respect to the robot and the calibration
* object is attached to the robot arm.
*这个示例展示了如何使用手眼标定,这种情形用于相机与机械手基础坐标系位置固定且标定板固定在相机的末端轴上。
* In this case, the goal of the hand eye calibration
* is to determine two unknown poses:
*在这种情况下,手眼标定目标是确定一下两个位置姿态。
* - the pose of the robot base in the coordinate system
* of the camera (BaseInCamPose).
*基于相机坐标系的机械手基础坐标系姿态
* - the pose of the calibration object in the coordinate system of the
* tool (CalObjInToolPose)
*基于相机末端(工具)坐标系的标定板姿态
* Theoretically, as input the method needs at least 3 poses of the
* calibration object in the camera coordinate system and the corresponding
* poses of the robot tool in the coordinate system of the
* robot base. However it is recommended
* to use at least 10 Poses.
* The poses of the calibration object are obtained from images of the
* calibration object recorded with the stationary camera.
* The calibration object is moved by the robot with respect to the camera.
* To obtain good calibration results, it its essential to position
* the calibration object with respect to the camera so that the object appears
* tilted in the image.
* After the hand eye calibration, the computed transformations are
* extracted and used to compute the pose of the calibration object in the
* camera coordinate system.
dev_update_off ()
* Directories with calibration images and data files
ImageNameStart := ‘3d_machine_vision/handeye/stationarycam_calib3cm_‘
DataNameStart := ‘handeye/stationarycam_‘
NumImages := 17
* Read image
read_image (Image, ImageNameStart + ‘00‘)
get_image_size (Image, Width, Height)
* Open window
dev_close_window ()
dev_open_window (0, 0, Width, Height, ‘black‘, WindowHandle)
dev_set_line_width (2)
dev_set_draw (‘margin‘)
dev_display (Image)
* Set font
set_display_font (WindowHandle, 14, ‘mono‘, ‘true‘, ‘false‘)
* Load the calibration plate description file.
* Make sure that the file is in the current directory,
* the HALCONROOT/calib directory, or use an absolut path
CalTabFile := ‘caltab_30mm.descr‘
* Read the initial values for the internal camera parameters
read_cam_par (DataNameStart + ‘start_campar.dat‘, StartCamParam)
* Create the calibration model for the hand eye calibration
create_calib_data (‘hand_eye_stationary_cam‘, 1, 1, CalibDataID)
set_calib_data_cam_param (CalibDataID, 0, ‘area_scan_division‘, StartCamParam)
set_calib_data_calib_object (CalibDataID, 0, CalTabFile)
set_calib_data (CalibDataID, ‘model‘, ‘general‘, ‘optimization_method‘, ‘nonlinear‘)
disp_message (WindowHandle, ‘The calibration data model was created‘, ‘window‘, 12, 12, ‘black‘, ‘true‘)
disp_continue_message (WindowHandle, ‘black‘, ‘true‘)
stop ()
* Start the loop over the calibration images
for I := 0 to NumImages - 1 by 1
read_image (Image, ImageNameStart + I$‘02d‘)
* Search for the calibration plate, extract the marks and the
* pose of it, and store the results in the calibration data model of the
* hand-eye calibration
find_calib_object (Image, CalibDataID, 0, 0, I, [], [])
get_calib_data_observ_contours (Caltab, CalibDataID, ‘caltab‘, 0, 0, I)
get_calib_data_observ_points (CalibDataID, 0, 0, I, RCoord, CCoord, Index, CalObjInCamPose)
* Visualize the extracted calibration marks and the estimated pose (coordinate system)
dev_set_color (‘green‘)
dev_display (Image)
dev_display (Caltab)
dev_set_color (‘yellow‘)
disp_cross (WindowHandle, RCoord, CCoord, 6, 0)
dev_set_colored (3)
disp_3d_coord_system (WindowHandle, StartCamParam, CalObjInCamPose, 0.01)
* Read pose of tool in robot base coordinates (ToolInBasePose)
read_pose (DataNameStart + ‘robot_pose_‘ + I$‘02d‘ + ‘.dat‘, ToolInBasePose)
* Set the pose tool in robot base coordinates in the calibration data model
set_calib_data (CalibDataID, ‘tool‘, I, ‘tool_in_base_pose‘, ToolInBasePose)
* Uncomment to inspect visualization
* disp_message (WindowHandle, ‘Extracting data from calibration image ‘ + (I + 1) + ‘ of ‘ + NumImages, ‘window‘, -1, -1, ‘black‘, ‘true‘)
* disp_continue_message (WindowHandle, ‘black‘, ‘true‘)
* stop ()
endfor
disp_message (WindowHandle, ‘All relevant data has been set in the calibration data model‘, ‘window‘, 12, 12, ‘black‘, ‘true‘)
disp_continue_message (WindowHandle, ‘black‘, ‘true‘)
stop ()
* Perform hand-eye calibration
* Internally before performing the hand-eye calibration the cameras are calibrated
* and the calibrated poses of the calibration object in the camera are used.
dev_display (Image)
disp_message (WindowHandle, ‘Performing the hand-eye calibration‘, ‘window‘, 12, 12, ‘black‘, ‘true‘)
calibrate_hand_eye (CalibDataID, Errors)
* Query the camera parameters and the poses
get_calib_data (CalibDataID, ‘camera‘, 0, ‘params‘, CamParam)
* Get poses computed by the hand eye calibration
get_calib_data (CalibDataID, ‘camera‘, 0, ‘base_in_cam_pose‘, BaseInCamPose)
get_calib_data (CalibDataID, ‘calib_obj‘, 0, ‘obj_in_tool_pose‘, ObjInToolPose)
dev_get_preferences (‘suppress_handled_exceptions_dlg‘, PreferenceValue)
dev_set_preferences (‘suppress_handled_exceptions_dlg‘, ‘true‘)
try
* Store the camera parameters to file
write_cam_par (CamParam, DataNameStart + ‘final_campar.dat‘)
* Save the hand eye calibration results to file
write_pose (BaseInCamPose, DataNameStart + ‘final_pose_cam_base.dat‘)
write_pose (ObjInToolPose, DataNameStart + ‘final_pose_tool_calplate.dat‘)
catch (Exception)
* Do nothing
endtry
dev_set_preferences (‘suppress_handled_exceptions_dlg‘, PreferenceValue)
* Display calibration errors of the hand-eye calibration
Message := ‘Quality of the results: root mean square maximum‘
Message[1] := ‘Translation part in meter: ‘ + Errors[0]$‘6.4f‘ + ‘ ‘ + Errors[2]$‘6.4f‘
Message[2] := ‘Rotation part in degree: ‘ + Errors[1]$‘6.4f‘ + ‘ ‘ + Errors[3]$‘6.4f‘
disp_message (WindowHandle, Message, ‘window‘, 12, 12, ‘black‘, ‘true‘)
disp_continue_message (WindowHandle, ‘black‘, ‘true‘)
stop ()
* For the given camera, get the corresponding pose indices and calibration object indices
query_calib_data_observ_indices (CalibDataID, ‘camera‘, 0, CalibObjIdx, PoseIds)
* Compute the pose of the calibration object in the camera coordinate
* system via calibrated poses and the ToolInBasePose and visualize it.
for I := 0 to NumImages - 1 by 1
read_image (Image, ImageNameStart + I$‘02d‘)
* Obtain the pose of the tool in robot base coordinates used in the calibration.
* The index corresponds to the index of the pose of the observation object.
get_calib_data (CalibDataID, ‘tool‘, PoseIds[I], ‘tool_in_base_pose‘, ToolInBasePose)
dev_display (Image)
* Compute the pose of the calibration plate with respect to the camera
* and visualize it
calc_calplate_pose_stationarycam (ObjInToolPose, BaseInCamPose, ToolInBasePose, CalObjInCamPose)
dev_set_colored (3)
disp_3d_coord_system (WindowHandle, CamParam, CalObjInCamPose, 0.01)
Message := ‘Using the calibration results to display the‘
Message[1] := ‘coordinate system in image ‘ + (I + 1) + ‘ of ‘ + NumImages
disp_message (WindowHandle, Message, ‘window‘, 12, 12, ‘black‘, ‘true‘)
if (I < NumImages - 1)
disp_continue_message (WindowHandle, ‘black‘, ‘true‘)
stop ()
endif
endfor
* Clear the data model
clear_calib_data (CalibDataID)
*
* After the hand-eye calibration the computed pose
* BaseInCamPose can be used in robotic grasping applications.
* If the tool coordinate system is placed at the gripper
* and a object detected at ObjInCamPose shall be grasped,
* the pose of the detected object relative
* to the robot base coordinate system has to be computed.
pose_invert (BaseInCamPose, CamInBasePose)
pose_compose (CamInBasePose, CalObjInCamPose, ObjInBasePose)

原文地址:https://www.cnblogs.com/yangmengke2018/p/9743334.html

时间: 2024-10-09 22:17:18

手眼标定eye-to-hand 示例:handeye_stationarycam_calibration的相关文章

手眼标定之相机随动eye-in-hand 示例:handeye_movingcam_calibration

* * This example explains how to use the hand eye calibration for the case where* the camera is attached to the robot tool and the calibration object* is stationary with respect to the robot. *这个示例展示了如何使用手眼标定,针对相机固定在机械手末端且标定板相对于机械手基础坐标系静止的情形.* The ro

halcon 手眼标定的坐标转换原理讲解

原文链接:https://blog.csdn.net/opencv_learner/article/details/82113323 一直以来,对于手眼标定所涉及到的坐标系及坐标系之间的转换关系都没能有一个很好的理解,最近找了halcon手眼标定的实例在研究,发现对于相机的两种安装方式(眼在手和眼在手外),其坐标转换关系是类似的,这样说好像太抽象了,下面具体说说. 我觉得标定最基本的是要将坐标系理清楚,这里涉及到的坐标系有四个:机器人基坐标系base.法兰上的工具坐标系tool.相机坐标系cam

VINS-mono详细解读

VINS-mono详细解读 极品巧克力 前言 Vins-mono是香港科技大学开源的一个VIO算法,https://github.com/HKUST-Aerial-Robotics/VINS-Mono,是用紧耦合方法实现的,通过单目+IMU恢复出尺度,效果非常棒. 感谢他们开源,我从中学到了非常多的知识.源码总共有15000多行,我在通读完程序之后,结合参考文献,把程序背后的算法理论都推导了一遍,总结成了本文,与各位分享. 本文目标读者:对vins-mono有一定了解的SLAM算法工程师.由于程

Halcon10 下载

Halcon10 下载地址:http://www.211xun.com/20181025225722.htm HALCON 10 是一套机器视觉图像处理库,由一千多个算子以及底层的数据管理核心构成.其功能包含各类滤波,色彩以及几何,数学转换,形态学计算分析,校正,分类辨识,形状搜寻,手眼标定等等影像计算功能.应用范围几乎没有限制,涵盖医学,遥感探测,监控,到工业上的各类自动化检测. HALCON支持Windows,Linux和Mac OS X操作系统.整个函数库可以用C,C++,C#,Visua

Halcon18 Linux 下载

Halcon18 Linux下载地址:http://www.211xun.com/20181025225502.htm HALCON 18 是一套机器视觉图像处理库,由一千多个算子以及底层的数据管理核心构成.其功能包含各类滤波,色彩以及几何,数学转换,形态学计算分析,校正,分类辨识,形状搜寻,手眼标定等等影像计算功能.应用范围几乎没有限制,涵盖医学,遥感探测,监控,到工业上的各类自动化检测. HALCON支持Windows,Linux和Mac OS X操作系统.整个函数库可以用C,C++,C#,

Halcon18 Mac os 下载

Halcon18 Mac os 下载地址:http://www.211xun.com/20181025225455.htm HALCON 18 是一套机器视觉图像处理库,由一千多个算子以及底层的数据管理核心构成.其功能包含各类滤波,色彩以及几何,数学转换,形态学计算分析,校正,分类辨识,形状搜寻,手眼标定等等影像计算功能.应用范围几乎没有限制,涵盖医学,遥感探测,监控,到工业上的各类自动化检测. HALCON支持Windows,Linux和Mac OS X操作系统.整个函数库可以用C,C++,C

Halcon17 Linux 下载

Halcon17 windows 下载地址:http://www.211xun.com/20181025225540.htm HALCON 17 是一套机器视觉图像处理库,由一千多个算子以及底层的数据管理核心构成.其功能包含各类滤波,色彩以及几何,数学转换,形态学计算分析,校正,分类辨识,形状搜寻,手眼标定等等影像计算功能.应用范围几乎没有限制,涵盖医学,遥感探测,监控,到工业上的各类自动化检测. HALCON支持Windows,Linux和Mac OS X操作系统.整个函数库可以用C,C++,

Halcon17 windows 下载

Halcon17 windows 下载地址:http://www.211xun.com/20181025225550.htm HALCON 17 是一套机器视觉图像处理库,由一千多个算子以及底层的数据管理核心构成.其功能包含各类滤波,色彩以及几何,数学转换,形态学计算分析,校正,分类辨识,形状搜寻,手眼标定等等影像计算功能.应用范围几乎没有限制,涵盖医学,遥感探测,监控,到工业上的各类自动化检测. HALCON支持Windows,Linux和Mac OS X操作系统.整个函数库可以用C,C++,

Halcon11 Linux 下载

Halcon11 Linux下载地址:http://www.211xun.com/20181025225701.htm HALCON 11 是一套机器视觉图像处理库,由一千多个算子以及底层的数据管理核心构成.其功能包含各类滤波,色彩以及几何,数学转换,形态学计算分析,校正,分类辨识,形状搜寻,手眼标定等等影像计算功能.应用范围几乎没有限制,涵盖医学,遥感探测,监控,到工业上的各类自动化检测. HALCON支持Windows,Linux和Mac OS X操作系统.整个函数库可以用C,C++,C#,