I’m currently trying to use the OpenCv Lens Distortion plugin that comes installed by default with the Virtual Production example in Unreal 4.27 to try and create a camera undistortion texture for my camera. So far I have had no issue getting this to work with by manually setting the lens distortion parameters (K[1-6], P1, P2, etc.) but now I want to automatically generate this data using a series of images from my camera. To do this I threw together a blueprint (couldn’t get access to OpenCV from C++ scripts) that takes a directory, grabs all jpg files and feeds them into the calibrator.
Unfortunately no matter what I try the calibrator refuses to accept any of my test images, and since this is a blueprint I can’t really debug the problem any more, all I know is that the FeedImage node returns false for every image. I’ve tried searching for documentation or tutorials using OpenCV Lens Distortion but for some reason it is a completely undocumented feature besides a couple pages saying the nodes exist and 2 or 3 questions on this answer hub asking how to turn the distortion variables into a texture. If anyone knows what I might be missing please let me know.
Just for reference, here is a sample of one of my test images:
- Board Width: 10
- Board Height: 7
- Square Size: 3.2727 cm
I was able to get OpenCV working directly in another program using a python script but I would like to have this working in Unreal to minimize the amount of programs needed. Obviously the functions are difference since Python deals directly with OpenCv while Unreal is using a blueprint wrapper but at least I know the images and calibrator settings should be valid.
I also want to mention I saw the Lens Distortion plugin mentioned in this post, but unfortunately it does not seem to have the ability to accept images to generate a lens distortion model, it simply builds one using the k1, k2, k3, p1, p2 parameters and camera matrix values.