收藏 分享(赏)

halcon标定详解.docx

上传人:HR专家 文档编号:5910295 上传时间:2019-03-21 格式:DOCX 页数:4 大小:15.21KB
下载 相关 举报
halcon标定详解.docx_第1页
第1页 / 共4页
halcon标定详解.docx_第2页
第2页 / 共4页
halcon标定详解.docx_第3页
第3页 / 共4页
halcon标定详解.docx_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

1、*创建标定板gen_caltab(7,7,0.008,0.5,48_48mm.descr,48_48mm.ps)*=标定内参dev_close_window ()dev_open_window (0, 0, 652, 494, black, WindowHandle)dev_update_off ()dev_set_draw (margin)dev_set_line_width (3)OpSystem := environment(OS)set_display_font (WindowHandle, 14, mono, true, false)*标定相机StartCamPar := 0.0,0

2、.0,0.0000299,0.0000299,4896/2,3264/2,4896,3264create_calib_data (calibration_object, 1, 1, CalibDataID)set_calib_data_cam_param (CalibDataID, 0, area_scan_telecentric_division, StartCamPar)set_calib_data_calib_object (CalibDataID, 0, 48_48mm.descr)* Note, we do not use the image from which the pose

3、of the measurement plane can be derivedfor index := 1 to 13 by 1read_image (Image, 标定 20/ + index + .png)get_image_size(Image, Width, Height)dev_display (Image)find_calib_object (Image, CalibDataID, 0, 0, index, , )get_calib_data_observ_contours (Caltab, CalibDataID, caltab, 0, 0, index)dev_set_colo

4、r (green)dev_display (Caltab)endforcalibrate_cameras (CalibDataID, Error)get_calib_data (CalibDataID, camera, 0, params, CamParam)get_calib_data (CalibDataID, calib_obj_pose, 0,1, pose, PoseCalib)*输出计算的相机内参write_cam_par (CamParam, camera_parameters.dat)Message:= 相机内参已经写入文件中disp_message (WindowHandle

5、, Message, window, 12, 12, red, false)clear_calib_data (CalibDataID)stop()*=标定外参dev_set_draw (margin)dev_set_line_width (1)set_display_font (WindowHandle, 14, mono, true, false)*从文件中读取内参 存储文件:camera_parameters.dattryread_cam_par (camera_parameters.dat, CamParam)catch (Exception)stop ()endtry*开始计算ope

6、n_file(data.csv,output, FileHandle)fwrite_string(FileHandle,Dis_pix*0.0299204,Dis_m*1000,Distance)fnew_line (FileHandle)close_file(FileHandle)*选择一张作为标定作为最终标定位姿(任意一张都可以)index:=1read_image (Image,标定 20/+index+.png)dev_display (Image)CaltabName := 48_48mm.descrcreate_calib_data (calibration_object, 1,

7、1, CalibDataID)* Here, the final camera parameters are already known and can be used instead* of the starting values used in the program camera_calibration_internal.hdevset_calib_data_cam_param (CalibDataID, 0, area_scan_telecentric_division, CamParam)set_calib_data_calib_object (CalibDataID, 0, Cal

8、tabName)find_calib_object (Image, CalibDataID, 0, 0, 1, , )get_calib_data_observ_contours (Caltab, CalibDataID, caltab, 0, 0, 1)get_calib_data_observ_points (CalibDataID, 0, 0, 1, RCoord, CCoord, Index, PoseForCalibrationPlate)dev_set_color (green)dev_display (Caltab)dev_set_color (red)disp_caltab (

9、WindowHandle, CaltabName, CamParam, PoseForCalibrationPlate, 1)dev_set_line_width (1)disp_circle (WindowHandle, RCoord, CCoord, gen_tuple_const(|RCoord|,1.5)* caltab_points (CaltabName, X, Y, Z)* calibrate_cameras (CalibDataID, Error)* To take the thickness of the calibration plate into account, the

10、 z-value* of the origin given by the camera pose has to be translated by the* thickness of the calibration plate.* Deactivate the following line if you do not want to add the correction.set_origin_pose (PoseForCalibrationPlate, 0, 0, 0, PoseCalib)* disp_continue_message (WindowHandle, black, true)*

11、stop ()*像素距离distance_pp(RCoord0,CCoord0,RCoord48,CCoord48, Dis_pix)*像素直接转换 mm然后计算pix2mm(RCoord, CCoord,CamParam2,CamParam3,newCol,newRow)distance_pp(newRow0,newCol0,newRow48,newCol48, Dis_m)*用同一个世界坐标系来计算image_points_to_world_plane(CamParam, PoseCalib,RCoord0,RCoord48,CCoord0,CCoord48, mm, X1, Y1)distance_pp(Y10,X10,Y11,X11,Distance) *输出计算结果比较open_file(data.csv,append, FileHandle)fwrite_string(FileHandle, Dis_pix*0.0299+,+Dis_m*1000+,+Distance+n)close_file(FileHandle) Message:= 计算完毕disp_message (WindowHandle, Message, window, 12, 12, red, false)stop()

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 企业管理 > 经营企划

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报