'How to format the input for `reconstructScene`?

I'm trying to use reconstructScene to project my disparity map into a 3D point cloud. In the online documentation, this function takes a 4x4 reprojection_matrix as input, but

When I try to use a 4x4 matrix as input, I get the following error

Error using reconstructScene
Expected stereoParams to be one of these types:

stereoParameters

Instead its type was double.

Error in reconstructScene (line 74)
validateattributes(stereoParams, {'stereoParameters'}, {}, ...

Looking deeper, in my installation of MATLAB R2021b, the function has the following header.

% reconstructScene Reconstructs a 3-D scene from a disparity map.
%   xyzPoints = reconstructScene(disparityMap, stereoParams) returns an
%   M-by-N-by-3 array of [X,Y,Z] coordinates of world points corresponding
%   to pixels in disparityMap, an M-by-N array of disparity values.
%   stereoParams is a stereoParameters object. The 3-D world coordinates
%   are relative to the optical center of camera 1 of the stereo system
%   represented by stereoParams.

Okay, well then, I'll construct a stereoParameters object. To do so, I first need a cameraParameters. My attempt follows:

intrinsics = cameraIntrinsics([3999, 3988], [959.5, 599], [1920, 1199]); #focal length, camera center, and imager size

left_camera = cameraParameters('Intrinsics', intrinsics, 'TranslationVectors', [0, 0, 0], 'RotationMatrices', eye(3)); # My  left camera coordinates are the same as the world coordinate system so my translation and rotation are unchanged.

The cameraParameters line produces the error

Error using cameraIntrinsics/cameraParameters
Cannot access method 'cameraParameters' in class 'cameraIntrinsics'. 

TLDR; How can I run reconstructScene given that I have a disparity map and the camera intrinsics and extrinsics? How do I need to format my input?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source