原图
程序源码
* gen_caltab (7, 7, 0.0025, 1/2.5, 'GB025标定板.descr', 'GB025标定板.ps')
* Calibration 01: Code generated by Calibration 01
* CameraParameters := [0.048105,-44.0585,8.31518e-006,8.3e-006,641.37,588.269,1280,1024]
* CameraPose := [-0.000849522,-0.00119001,0.155349,357.367,2.64825,174.694,0]
* stop ()
* Calibration 01: Code generated by Calibration 01
CameraParameters := [0.0481151,56.7536,-739213,1.05534e+010,0.00643696,0.00896216,8.31503e-006,8.3e-006,636.538,582.388,1280,1024]
CameraPose := [-0.000719502,-0.00103218,0.155376,357.307,2.70546,174.696,0]
stop ()read_image (Image, '直线标定板图片/Left201113141949916.bmp')
get_image_size (Image, Width, Height)
dev_close_window ()
dev_open_window_fit_image (Image, 0, 0, -1, -1, WindowHandle)
dev_display (Image)
* Image Acquisition 01: Code generated by Image Acquisition 01
list_files ('直线标定板图片', ['files','follow_links'], ImageFiles)
tuple_regexp_select (ImageFiles, ['\\.(tif|tiff|gif|bmp|jpg|jpeg|jp2|png|pcx|pgm|ppm|pbm|xwd|ima|hobj)$','ignore_case'], ImageFiles)
gen_empty_obj (Edges)
for Index := 0 to 20 - 1 by 1read_image (Image, ImageFiles[Index])edges_sub_pix (Image, ImageEdges, 'canny', 1, 10, 40)segment_contours_xld (ImageEdges, SplitEdges, 'lines_circles', 5, 4, 2)select_shape_xld (SplitEdges, SelectedEdges, 'contlength', 'and', 30, 100000)concat_obj (Edges, SelectedEdges, Edges)dev_display (Image)dev_set_colored (12)dev_display (SelectedEdges)wait_seconds (0.1)
* stop ()
endforradial_distortion_self_calibration (Edges, CalibrationEdges, Width, Height, 0.08, 42, 'polynomial', 'variable', 0, CamParMultiImage)
dev_clear_window ()
dev_set_colored (12)
dev_display (CalibrationEdges)**********对比矫正后的图片与矫正前的图片
change_radial_distortion_cam_par ('fixed', CamParMultiImage, 0, CamParMultiImageRect)
for Index := 0 to |ImageFiles| - 1 by 1read_image (Image, ImageFiles[Index])get_domain (Image, Domain)* Rectify the image, i.e., remove the radial distortions.change_radial_distortion_image (Image, Domain, ImageRectified, CamParMultiImage, CamParMultiImageRect)* Display the distorted and undistorted image to visualize the* differences between the images.dev_display (Image)sub_image (Image, ImageRectified, ImageSub3, 1, 0)stop ()disp_message (WindowHandle, 'Image with radial distortions', 'window', 0, 0, 'black', 'true')wait_seconds (0.5)dev_display (ImageRectified)disp_message (WindowHandle, 'Image without radial distortions', 'window', 0, 0, 'black', 'true')wait_seconds (0.5)
endfor*标定板畸变矫正准备
change_radial_distortion_cam_par ('fixed', CameraParameters, [0,0,0,0,0], CamParVirtualFixed)
* CamParVirtualFixed:=CameraParameters
gen_radial_distortion_map(MapFixed,CameraParameters,CamParVirtualFixed,'bilinear')
*直线畸变矫正准备
change_radial_distortion_cam_par ('fixed', CamParMultiImage, [0,0,0,0,0], CamParMultiImageRect)
get_domain (Image, Domain)for Index := 0 to |ImageFiles| - 1 by 1read_image (Image, ImageFiles[Index])* 直线标定change_radial_distortion_image (Image, Domain, ImageRectified, CamParMultiImage, CamParMultiImageRect)* 标定板标定map_image(Image,MapFixed,ImageRectifiedFixed)*标定板与直线标定sub_image (ImageRectified, ImageRectifiedFixed, ImageSub, 1, 128)intensity (Domain, ImageSub, Mean, Deviation)sub_image (Image, ImageRectifiedFixed, ImageSub1, 1, 128)intensity (Domain, ImageSub1, Mean1, Deviation1)sub_image (Image, ImageRectified, ImageSub2, 1, 128)intensity (Domain, ImageSub2, Mean2, Deviation2)dev_display (Image)disp_message (WindowHandle, 'Image with radial distortions', 'window', 0, 0, 'black', 'true')wait_seconds (0.5)dev_display (ImageRectified)disp_message (WindowHandle, 'Image without radial distortions', 'window', 0, 0, 'black', 'true')wait_seconds (0.5)
endfor