Apply same camera distortion from one image to another

Hello everyone,

I have a scene with both simple images and static videos. I did the RC alignment workflow using the simple images and one frame from each video, which works fine, giving me the undistorted cameras.

Now my problem is how I can apply the distortions found for the frames to the whole videos ?

Basically it should just be reduced to extracting the camera intrinsic parameters and distortion (RC -> Registration -> save as Internal/External camera parameters), and then apply the undistortion formula to the other frames, for example using OpenCV undistort built in function: https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html?#undistort 

However I was unable to reproduce the same effect, and I am guessing the issue comes from converting the calibration parameters from RC to OpenCV (the distortion coefficients should not be a problem, here I am using Brown3 model with k1, k2 and k3 radial coefficients).

I saw some related threads here but they were not really helpful:

https://support.capturingreality.com/hc/en-us/community/posts/115001359032-Camera-calibration-and-distortion-parameters-to-OpenCV (marked as answered but not providing anything)

https://support.capturingreality.com/hc/en-us/community/posts/115001778112-How-can-i-undistort-images-myself-using-the-export-xml-camera-parameters- 

So is it possible to apply the same transformation directly in RC ? And if not, has someone successfully convert RC cameras parameters to OpenCV or to any other setup that allows to do the undistortion myself.

Many thanks,

Yes, you can. 

You basically have to follow the XMP workflow (“reuse alignment” in the doc / multi cameras rigs …). This is covered in the documentation.

In a few words : 

-you align all the cameras of the first frame (or another if suitable) of your video.

-you export XMP files for each camera.

-you reuse the XMP files for the other frames.

Of course, you can do that manually but you better do this with the CLI if you want to automate. I am usually using simple windows batch files (.BAT) to do all the copy / rename work and then the CLI to process with RC.

 

Sorry maybe I misunderstood a bit your question : if you want to export the undistorded images, you can also follow the same workflow and export the undistorded pitctures in RC (I forgot how but you are able to do that). So this is just a matter of duplicating the right XMP for all your pictures. 

Thank your for your reply Jonathan,

Using your suggestions, I was able to make things work. I only had to modify in the XMP the xcr:PosePrior and xcr:CalibrationPrior from “intial” to “locked”. Also for some reason I could only export the calibration with 3 frames or more but that should not be a problem for the actual videos.

However, since I do no have access to the CLI, it requires some manual steps. So if someone has a solution to get the job done outside of RC (ideally OpenCV), I am still very interested.