我使用 cvRemap 来应用失真校正。
map_x 部分是图像分辨率,并为每个像素存储要应用的 x 偏移量,而 map_y 部分与 y 偏移量相同。
在不失真的情况下
# create map_x/map_y
self.map_x = cvCreateImage(cvGetSize(self.image), IPL_DEPTH_32F, 1)
self.map_y = cvCreateImage(cvGetSize(self.image), IPL_DEPTH_32F, 1)
# I know the camera intrisic already so create a distortion map out
# of it for each image pixel
# this defined where each pixel has to go so the image is no longer
# distorded
cvInitUndistortMap(self.intrinsic, self.distortion, self.map_x, self.map_y)
# later in the code:
# "image_raw" is the distorted image, i want to store the undistorted into
# "self.image"
cvRemap(image_raw, self.image, self.map_x, self.map_y)
因此:map_x/map_y 是浮点值,在图像分辨率中,就像 1024x768 中的两个图像。 cvRemap 中发生的事情基本上是这样的
orig_pixel = input_image[x,y]
new_x = map_x[x,y]
new_y = map_y[x,y]
output_image[new_x,new_y] = orig_pixel
你想用这个做什么样的几何变换?