Skip to content

getDefaultNewCameraMatrix

geometryfunctionOpenCV 5.0.0
import { getDefaultNewCameraMatrix } from '@banou/opencv-wasm'

Use after await initOpenCV(). See the initialization and named imports guide.

ARGUMENTScameraMatrix, imgsize, centerPrincipalPoint
FUNCTIONgetDefaultNewCameraMatrix
RETURN TYPEMat
Call structure. A void return can still write to destination arguments. The parameter descriptions define inputs, outputs and ownership.

Returns the default new camera matrix.

The function returns the camera matrix that is either an exact copy of the input cameraMatrix (when centerPrinicipalPoint=false ), or the modified one (when centerPrincipalPoint=true).

In the latter case, the new camera matrix will be:

\begin{bmatrix} f_x && 0 && ( \texttt{imgSize.width} -1)*0.5  \\ 0 && f_y && ( \texttt{imgSize.height} -1)*0.5  \\ 0 && 0 && 1 \end{bmatrix} ,

where f_x and f_y are (0,0) and (1,1) elements of cameraMatrix, respectively.

By default, the undistortion functions in OpenCV (see #initUndistortRectifyMap, #undistort) do not move the principal point. However, when you work with stereo, it is important to move the principal points in both views to the same y-coordinate (which is required by most of stereo correspondence algorithms), and may be to the same x-coordinate too. So, you can form the new camera matrix for each view where the principal points are located at the center.

getDefaultNewCameraMatrix(cameraMatrix: Mat, imgsize: Size, centerPrincipalPoint: boolean): Mat;
3 available overloads
getDefaultNewCameraMatrix(cameraMatrix: Mat): Mat;
getDefaultNewCameraMatrix(cameraMatrix: Mat, imgsize: Size): Mat;
getDefaultNewCameraMatrix(cameraMatrix: Mat, imgsize: Size, centerPrincipalPoint: boolean): Mat;
cameraMatrix

Input camera matrix.

imgsize

Camera view image size in pixels.

centerPrincipalPoint

Location of the principal point in the new camera matrix. The parameter indicates whether this location should be at the image center or not.

Returns

The Mat result. Release returned native handles with using or delete(), including handles nested in results.

These signatures describe this package. Upstream documentation can mention optional backends that are absent from this build. Check runtime compatibility before choosing a backend or file format.