import clr
clr.AddReference("OpenCV.Net")
from System import Array
from OpenCV.Net import CV, Mat, Depth, Point2f
@returns(Point2f)
def process(input):
# Initialize input point matrix to 2xN array of points
points = Array[float]([input.X, input.Y])
source = Mat.FromArray(points,points.Length/2,1,Depth.F64,2)
# Create result matrix, will contain undistorted points
undistorted = Array.CreateInstance(Point2f,1)
result = Mat.CreateMatHeader(undistorted,
source.Rows,
source.Cols,
source.Depth,
source.Channels)
# Undistortion parameters
camera = Array[float]([1,0,320,0,1,240,0,0,1])
cameraMatrix = Mat.FromArray(camera,3,3,Depth.F64,1)
distortion = Mat.FromArray(Array[float]([0, 0, 0, 0, 0]))
CV.UndistortPoints(source,result,cameraMatrix,distortion)
return undistorted[0]