I’m trying to register a frame from camera to a template.
The most naive approach would be a feature based approach, finding a homography.
Unfortunately, for my case, images don’t have adequate features to use as feature (they consist of vertical and horizontal lines. Ex, tennis court). I tried all the features available in OpenCV.
The closest transform ITK has to perspective is Rigid3DPerspectiveTransform, which does not do exactly what you want. While deformable transforms should be able to accomplish your task, they have many degrees of freedom (dozens, hundreds, or thousands) making them suboptimal. You could try BSplineTransform, it might be enough. Easy way to experiment is by using Slicer as it contains BRAINS (more classic ITK registration) and elastix (via an extension).
Alternatively, you could add PerspectiveTransform to ITK and then use that. You could start from AffineTransform.