Non-planar stereo camera calibration (Two cameras with a physical Z-offset)

Thank you to both for your inputs.

I’ve been trying with variations of this sort of scene (note, some of the pics below are from slightly different arrangements of objects):

(I output L / R images without the R / B effect – this is just for viz)

In this example, they’re set to 25mm focal length cameras, and are 0.06m apart in the X axis, and 0.01m apart in the Z axis.

If there’s no Z displacement, I get reasonable(?) results such as this:

If there is Z displacement, things rapidly go to hell. The rectification breaks completely.

I get stuff like this:

alpha doesn’t really help much.

I’ve been exploring ZNCC and SAD, and my implementation seems to be a bit better. I’m able to something usable (note that there was a matt with texture on it below the apple, hence the unusual patterning):

But it’s slow as heck (all python, and horribly un-optimized code)