不需要事先获取相机内参
*在拼接应用程序中匹配两个图像。
read_image (Image1, 'C:/Users/zjm/Desktop/图像拼接/3.jpg')
read_image (Image2, 'C:/Users/zjm/Desktop/图像拼接/4.jpg')
get_image_size (Image1, Width, Height)
* 使用Foerstner寻找特征点
points_foerstner (Image1, 1, 2, 3, 50, 0.1, 'gauss', 'true', Rows1, Columns1, CoRRJunctions, CoRCJunctions, CoCCJunctions, RowArea, ColumnArea, CoRRArea, CoRCArea, CoCCArea)
points_foerstner (Image2, 1, 2, 3, 50, 0.1, 'gauss', 'true', Rows2, Columns2, CoRRJunctions, CoRCJunctions, CoCCJunctions, RowArea, ColumnArea, CoRRArea, CoRCArea, CoCCArea)
*****************************进行了畸变修正*************************************
*之前实现的凭借功能并未实现修正图像畸变现在,我们将执行一个径向的投影匹配。现在,我们要做一个投影匹配,它是径向的。扭曲。
get_image_size (Image1, Width, Height)
*根据两幅图像的特征点,计算两幅图像之间的投影变换矩阵和径向畸变系数。
proj_match_points_distortion_ransac (Image1, Image2, Rows1, Columns1, Rows2, Columns2, 'ncc', 10, 0, 0, Height, Width, 0, 0.5, 'gold_standard', 1, 42, HomMat2D, Kappa, Error, Points1, Points2)
*构造相机参数以校正图像,以消除径向畸变。
CamParDist := [0.0,Kappa,1.0,1.0,0.5 * (Width - 1),0.5 * (Height - 1),Width,Height]
*从消除图像中的径向畸变。
change_radial_distortion_cam_par ('fixed', CamParDist, 0, CamPar)
change_radial_distortion_image (Image1, Image1, Image1Rect, CamParDist, CamPar)
change_radial_distortion_image (Image2, Image2, Image2Rect, CamParDist, CamPar)
*从两幅已校正的图像中构建马赛克。注意,图片配合完美。
concat_obj (Image1Rect, Image2Rect, ImagesRect)
gen_projective_mosaic (ImagesRect, MosaicImage, 1, 1, 2, HomMat2D, 'default', 'false', MosaicMatrices2D)
* Display rectified results
get_image_size (MosaicImage, Width, Height)
dev_clear_window ()
dev_open_window (0, 0, Width/3, Height/3, 'white', WindowHandle)
dev_display (MosaicImage)
效果图:
![](https://i-blog.csdnimg.cn/blog_migrate/bbe8b70171ff0c9cc695c36e6bc4158d.png)