* This program demonstrates how to perform a calibrated measurement by using the sheet-of-light technique
* 通过激光三角测量技术实现有标定的测量
*-------------
* First, a sheet-of light model is created and suitable parameters are set.
*首先,创建激光三角测量模型和合适的参数
*Then, a series of profile images is processed successively.
*然后,处理一系列的概要文件
*Finally, the disparity image, the score images, the calibrated coordinates X, Y and Z,
*and the 3D object model resulting from the measurement are retrieved from the model and displayed.
*最后从模型中的恢复,差异图像,得分图像,标定坐标X,Y,Z和三维物体模型,并展示
* --------------------------
* Perform some initializations
dev_update_off ()
read_image (ProfileImage, 'sheet_of_light/connection_rod_001')
dev_close_window ()
dev_open_window_fit_image (ProfileImage, 0, 0, 1024, 768, WindowHandle1)
dev_set_draw ('margin')
dev_set_line_width (3)
dev_set_color ('green')
dev_set_lut ('default')
*
* Set the poses and camera parameters required to compute a calibrated measurement
*设置所需的姿态和摄像机参数,以计算校准测量
CamParam := [0.0126514,640.275,-2.07143e+007,3.18867e+011,-0.0895689,0.0231197,6.00051e-006,6e-006,387.036,120.112,752,240]
CamPose := [-0.00164029,1.91372e-006,0.300135,0.575347,0.587877,180.026,0]
LightplanePose := [0.00270989,-0.00548841,0.00843714,66.9928,359.72,0.659384,0]
MovementPose := [7.86235e-008,0.000120112,1.9745e-006,0,0,0,0]
*
* Create a model in order to process the profile images and set the required parameters for the model.
* 创建一个模型去处理profile图像和设置模型的参数
gen_rectangle1 (ProfileRegion, 120, 75, 195, 710)
*用激光三角测量技术创建一个模型去实现3D测量,依次是包括概要文件的区域,通用参数的名称,,SheetOfLightModelID
create_sheet_of_light_model (ProfileRegion, ['min_gray','num_profiles','ambiguity_solving'], [70,290,'first'], SheetOfLightModelID)
*设置选定的参数,依次是模型ID,模型参数名称,模型参数值
set_sheet_of_light_param (SheetOfLightModelID, 'calibration', 'xyz')
set_sheet_of_light_param (SheetOfLightModelID, 'scale', 'mm')
set_sheet_of_light_param (SheetOfLightModelID, 'camera_parameter', CamParam)
set_sheet_of_light_param (SheetOfLightModelID, 'camera_pose', CamPose)
set_sheet_of_light_param (SheetOfLightModelID, 'lightplane_pose', LightplanePose)
set_sheet_of_light_param (SheetOfLightModelID, 'movement_pose', MovementPose)
*
* Measure the profile from successive images,从连续的图像中测量概要信息
for Index := 1 to 290 by 1
read_image (ProfileImage, 'sheet_of_light/connection_rod_' + Index$'.3')
dev_display (ProfileImage)
dev_display (ProfileRegion)
measure_profile_sheet_of_light (ProfileImage, SheetOfLightModelID, [])
endfor
* Get the resulting images and close the sheet-of-light handle
*得到测量的结果,依次是测量结果,模型ID,
get_sheet_of_light_result (Disparity, SheetOfLightModelID, 'disparity')
get_sheet_of_light_result (X, SheetOfLightModelID, 'x')
get_sheet_of_light_result (Y, SheetOfLightModelID, 'y')
get_sheet_of_light_result (Z, SheetOfLightModelID, 'z')
get_sheet_of_light_result_object_model_3d (SheetOfLightModelID, ObjectModel3DID)
clear_sheet_of_light_model (SheetOfLightModelID)
*
* Display the disparity image
get_image_size (Disparity, Width, Height)
*更改活动图形窗口的位置和大小
dev_set_window_extents (0, 0, Width, Height)
dev_set_lut ('temperature')
set_display_font (WindowHandle1, 14, 'mono', 'true', 'false')
dev_clear_window ()
dev_display (Disparity)
disp_message (WindowHandle1, 'Disparity', 'window', -1, -1, 'black', 'true')
disp_continue_message (WindowHandle1, 'black', 'true')
stop ()
*
* Display the Z-coordinates
dev_close_window ()
dev_open_window (Height + 10, 0, Width * .5, Height * .5, 'black', WindowHandle3)
set_display_font (WindowHandle3, 14, 'mono', 'true', 'false')
dev_display (Z)
disp_message (WindowHandle3, 'Calibrated Z-coordinates', 'window', -1, -1, 'black', 'true')
*
* Display the Y-coordinates
dev_open_window ((Height + 10) * .5, 0, Width * .5, Height * .5, 'black', WindowHandle2)
set_display_font (WindowHandle2, 14, 'mono', 'true', 'false')
dev_display (Y)
disp_message (WindowHandle2, 'Calibrated Y-coordinates', 'window', -1, -1, 'black', 'true')
*
* Display the X-coordinates
dev_open_window (0, 0, Width * .5, Height * .5, 'black', WindowHandle1)
dev_display (X)
dev_set_lut ('default')
set_display_font (WindowHandle1, 14, 'mono', 'true', 'false')
disp_message (WindowHandle1, 'Calibrated X-coordinates', 'window', -1, -1, 'black', 'true')
disp_continue_message (WindowHandle3, 'black', 'true')
stop ()
*
* Display the 3d object model
CameraParam1 := [0.012,0,6e-006,6e-006,376,240,752,480]
Instructions[0] := 'Rotate: Left button'
Instructions[1] := 'Zoom: Shift + left button'
Instructions[2] := 'Move: Ctrl + left button'
PoseIn := [0,-10,300,-30,0,-30,0]
dev_close_window ()
dev_close_window ()
dev_close_window ()
dev_open_window (0, 0, CameraParam1[6], CameraParam1[7], 'black', WindowHandle)
set_display_font (WindowHandle, 14, 'mono', 'true', 'false')
*交互式地显示3D对象模型, 场景的摄像机参数,物体的三维姿态 文本将显示
visualize_object_model_3d (WindowHandle, ObjectModel3DID, CameraParam1, PoseIn, 'color', 'white', 'Reconstructed Connection Rod', '', Instructions, PoseOut)
*
clear_object_model_3d (ObjectModel3DID)
reconstruct_connection_rod_calib----------恢复三维点云
最新推荐文章于 2023-03-12 09:22:20 发布