OpenCV and Blender pipeline

Is there any solid pipeline on how to work with OpenCV and Blender?

My goal is to render and overlay the result on real photos with pixel-match accuracy.

I have real photos with Aruco markers. I did camera calibration and can track the object with Aruco tracker. I got camera intrinsics parameters (camera matrix + distortion coefficients) with object position (rvec and tvec)

I’m facing with two problems:

  1. Blender doesn’t have fx and fy parameters for a camera
  2. Blender doesn’t have distortion by default.

How I tried to solve this:

  1. Find the aspect ratio and use horizontal or vertical fit, f=fx or f=fy depending on the results.
  2. I tried to undistort an image first, tracking Aruco on undistorted images, rendering them, and then applying distortion back. But how do you apply distortion back? Basically, how do you undistort and distort the image to get the same image as an input?

I have seen people use Blender, and the results looked good. IDK if they were subpixel-accurate or “just” good to ± one pixel due to minor math definition differences.