🤖 AIによる機械翻訳(非公式) — これは OpenCV 5.0.0 公式リファレンス(英語)を AI (Claude) で自動翻訳したものです。訳に誤りを含む場合があります。正確な情報は 公式英語版(原文) を参照してください。

クラス Stereo


  • public class Stereo
    extends java.lang.Object
    • フィールドの要約

      フィールド
      Modifier and Type Field Description
      static int STEREO_ZERO_DISPARITY  
    • コンストラクタの要約

      コンストラクタ
      Constructor Description
      Stereo()  
    • メソッドの要約

      すべてのメソッド 静的メソッド 具象メソッド
      Modifier and Type Method Description
      static void filterSpeckles​(Mat img, double newVal, int maxSpeckleSize, double maxDiff)
      Filters off small noise blobs (speckles) in the disparity map
      static void filterSpeckles​(Mat img, double newVal, int maxSpeckleSize, double maxDiff, Mat buf)
      Filters off small noise blobs (speckles) in the disparity map
      static void fisheye_stereoRectify​(Mat K1, Mat D1, Mat K2, Mat D2, Size imageSize, Mat R, Mat tvec, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags)
      Stereo rectification for fisheye camera model
      static void fisheye_stereoRectify​(Mat K1, Mat D1, Mat K2, Mat D2, Size imageSize, Mat R, Mat tvec, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, Size newImageSize)
      Stereo rectification for fisheye camera model
      static void fisheye_stereoRectify​(Mat K1, Mat D1, Mat K2, Mat D2, Size imageSize, Mat R, Mat tvec, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, Size newImageSize, double balance)
      Stereo rectification for fisheye camera model
      static void fisheye_stereoRectify​(Mat K1, Mat D1, Mat K2, Mat D2, Size imageSize, Mat R, Mat tvec, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, Size newImageSize, double balance, double fov_scale)
      Stereo rectification for fisheye camera model
      static Rect getValidDisparityROI​(Rect roi1, Rect roi2, int minDisparity, int numberOfDisparities, int blockSize)  
      static void reprojectImageTo3D​(Mat disparity, Mat _3dImage, Mat Q)
      Reprojects a disparity image to 3D space.
      static void reprojectImageTo3D​(Mat disparity, Mat _3dImage, Mat Q, boolean handleMissingValues)
      Reprojects a disparity image to 3D space.
      static void reprojectImageTo3D​(Mat disparity, Mat _3dImage, Mat Q, boolean handleMissingValues, int ddepth)
      Reprojects a disparity image to 3D space.
      static void stereoRectify​(Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q)
      Computes rectification transforms for each head of a calibrated stereo camera.
      static void stereoRectify​(Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags)
      Computes rectification transforms for each head of a calibrated stereo camera.
      static void stereoRectify​(Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, double alpha)
      Computes rectification transforms for each head of a calibrated stereo camera.
      static void stereoRectify​(Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, double alpha, Size newImageSize)
      Computes rectification transforms for each head of a calibrated stereo camera.
      static void stereoRectify​(Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, double alpha, Size newImageSize, Rect validPixROI1)
      Computes rectification transforms for each head of a calibrated stereo camera.
      static void stereoRectify​(Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, double alpha, Size newImageSize, Rect validPixROI1, Rect validPixROI2)
      Computes rectification transforms for each head of a calibrated stereo camera.
      static boolean stereoRectifyUncalibrated​(Mat points1, Mat points2, Mat F, Size imgSize, Mat H1, Mat H2)
      Computes a rectification transform for an uncalibrated stereo camera.
      static boolean stereoRectifyUncalibrated​(Mat points1, Mat points2, Mat F, Size imgSize, Mat H1, Mat H2, double threshold)
      Computes a rectification transform for an uncalibrated stereo camera.
      static void validateDisparity​(Mat disparity, Mat cost, int minDisparity, int numberOfDisparities)  
      static void validateDisparity​(Mat disparity, Mat cost, int minDisparity, int numberOfDisparities, int disp12MaxDisp)  
      • クラス java.lang.Object から継承したメソッド

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • フィールドの詳細

    • コンストラクタの詳細

      • Stereo

        public Stereo()
    • メソッドの詳細

      • stereoRectify

        public static void stereoRectify​(Mat cameraMatrix1,
                                         Mat distCoeffs1,
                                         Mat cameraMatrix2,
                                         Mat distCoeffs2,
                                         Size imageSize,
                                         Mat R,
                                         Mat T,
                                         Mat R1,
                                         Mat R2,
                                         Mat P1,
                                         Mat P2,
                                         Mat Q,
                                         int flags,
                                         double alpha,
                                         Size newImageSize,
                                         Rect validPixROI1,
                                         Rect validPixROI2)
        Computes rectification transforms for each head of a calibrated stereo camera.
        引数:
        cameraMatrix1 - 第1カメラの内部行列。
        distCoeffs1 - 第1カメラの歪みパラメータ。
        cameraMatrix2 - 第2カメラの内部行列。
        distCoeffs2 - 第2カメラの歪みパラメータ。
        imageSize - ステレオキャリブレーションに使用する画像のサイズ。
        R - 第1カメラの座標系から第2カメラへの回転行列。REF: stereoCalibrate を参照。
        T - 第1カメラの座標系から第2カメラへの並進ベクトル。REF: stereoCalibrate を参照。
        R1 - 第1カメラの出力3x3平行化変換(回転行列)。この行列は、平行化されていない第1カメラの座標系で与えられた点を、平行化された第1カメラの座標系の点へと変換する。より技術的に言えば、平行化されていない第1カメラの座標系から平行化された第1カメラの座標系への基底変換を行う。
        R2 - 第2カメラの出力3x3平行化変換(回転行列)。この行列は、平行化されていない第2カメラの座標系で与えられた点を、平行化された第2カメラの座標系の点へと変換する。より技術的に言えば、平行化されていない第2カメラの座標系から平行化された第2カメラの座標系への基底変換を行う。
        P1 - 第1カメラの新しい(平行化された)座標系における出力3x4射影行列。すなわち、平行化された第1カメラ座標系で与えられた点を平行化された第1カメラの画像へ射影する。
        P2 - 第2カメラの新しい(平行化された)座標系における出力3x4射影行列。すなわち、平行化された第1カメラ座標系で与えられた点を平行化された第2カメラの画像へ射影する。
        Q - 出力 \(4 \times 4\) 視差から深度への写像行列(REF: reprojectImageTo3D を参照)。
        flags - 0 または REF: STEREO_ZERO_DISPARITY を指定できる操作フラグ。このフラグが設定されている場合、関数は各カメラの主点が平行化(rectified)後のビューで同じピクセル座標を持つようにする。フラグが設定されていない場合、関数は有効な画像領域を最大化するために、(エピポーラ線の向きに応じて)画像を水平方向または垂直方向にシフトすることがある。
        alpha - 自由スケーリングパラメータ。-1 または指定されていない場合、関数はデフォルトのスケーリングを実行する。それ以外の場合、このパラメータは0から1の間でなければならない。alpha=0 は、有効なピクセルのみが見えるように(平行化後に黒い領域が生じないように)平行化画像が拡大・移動されることを意味する。alpha=1 は、カメラの元画像のすべてのピクセルが平行化画像に保持される(元画像のピクセルが失われない)ように、平行化画像が縮小・移動されることを意味する。中間の値はこれら両極端の間の中間的な結果をもたらす。
        newImageSize - 平行化後の新しい画像解像度。同じサイズを #initUndistortRectifyMap に渡す必要がある(OpenCV の samples ディレクトリにある stereo_calib.cpp サンプルを参照)。(0,0) を渡した場合(デフォルト)、元の imageSize に設定される。これをより大きな値に設定すると、特に大きな放射方向の歪みがある場合に、元画像の細部を保持するのに役立つ。
        validPixROI1 - 平行化画像内ですべてのピクセルが有効となる省略可能な出力矩形。alpha=0 の場合、ROI は画像全体を覆う。それ以外の場合は、より小さくなる可能性が高い(下図を参照)。
        validPixROI2 - Optional output rectangles inside the rectified images where all the pixels are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller (see the picture below). The function computes the rotation matrices for each camera that (virtually) make both camera image planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate as input. As output, it provides two rotation matrices and also two projection matrices in the new coordinates. The function distinguishes the following two cases:
        • 水平ステレオ: 第1カメラと第2カメラのビューが、主にx軸に沿って互いにずれている(垂直方向の小さなずれも起こりうる)。平行化された画像では、左右のカメラの対応するエピポーラ線は水平で、同じy座標を持つ。P1 と P2 は次のようになる:
        \(\texttt{P1} = \begin{bmatrix} f & 0 & cx_1 & 0 \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\) \(\texttt{P2} = \begin{bmatrix} f & 0 & cx_2 & T_x \cdot f \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix} ,\) \(\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx_1 \\ 0 & 1 & 0 & -cy \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_x} & \frac{cx_1 - cx_2}{T_x} \end{bmatrix} \) where \(T_x\) is a horizontal shift between the cameras and \(cx_1=cx_2\) if REF: STEREO_ZERO_DISPARITY is set.
        • 垂直ステレオ: 第1カメラと第2カメラのビューが、主に垂直方向に互いにずれている(おそらく水平方向にも少しずれている)。平行化された画像のエピポーラ線は垂直で、同じx座標を持つ。P1 と P2 は次のようになる:
        \(\texttt{P1} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_1 & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\) \(\texttt{P2} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_2 & T_y \cdot f \\ 0 & 0 & 1 & 0 \end{bmatrix},\) \(\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx \\ 0 & 1 & 0 & -cy_1 \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_y} & \frac{cy_1 - cy_2}{T_y} \end{bmatrix} \) where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if REF: STEREO_ZERO_DISPARITY is set. As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to initialize the rectification map for each camera. See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through the corresponding image regions. This means that the images are well rectified, which is what most stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that their interiors are all valid pixels. ![image](pics/stereo_undistort.jpg)
      • stereoRectify

        public static void stereoRectify​(Mat cameraMatrix1,
                                         Mat distCoeffs1,
                                         Mat cameraMatrix2,
                                         Mat distCoeffs2,
                                         Size imageSize,
                                         Mat R,
                                         Mat T,
                                         Mat R1,
                                         Mat R2,
                                         Mat P1,
                                         Mat P2,
                                         Mat Q,
                                         int flags,
                                         double alpha,
                                         Size newImageSize,
                                         Rect validPixROI1)
        Computes rectification transforms for each head of a calibrated stereo camera.
        引数:
        cameraMatrix1 - 第1カメラの内部行列。
        distCoeffs1 - 第1カメラの歪みパラメータ。
        cameraMatrix2 - 第2カメラの内部行列。
        distCoeffs2 - 第2カメラの歪みパラメータ。
        imageSize - ステレオキャリブレーションに使用する画像のサイズ。
        R - 第1カメラの座標系から第2カメラへの回転行列。REF: stereoCalibrate を参照。
        T - 第1カメラの座標系から第2カメラへの並進ベクトル。REF: stereoCalibrate を参照。
        R1 - 第1カメラの出力3x3平行化変換(回転行列)。この行列は、平行化されていない第1カメラの座標系で与えられた点を、平行化された第1カメラの座標系の点へと変換する。より技術的に言えば、平行化されていない第1カメラの座標系から平行化された第1カメラの座標系への基底変換を行う。
        R2 - 第2カメラの出力3x3平行化変換(回転行列)。この行列は、平行化されていない第2カメラの座標系で与えられた点を、平行化された第2カメラの座標系の点へと変換する。より技術的に言えば、平行化されていない第2カメラの座標系から平行化された第2カメラの座標系への基底変換を行う。
        P1 - 第1カメラの新しい(平行化された)座標系における出力3x4射影行列。すなわち、平行化された第1カメラ座標系で与えられた点を平行化された第1カメラの画像へ射影する。
        P2 - 第2カメラの新しい(平行化された)座標系における出力3x4射影行列。すなわち、平行化された第1カメラ座標系で与えられた点を平行化された第2カメラの画像へ射影する。
        Q - 出力 \(4 \times 4\) 視差から深度への写像行列(REF: reprojectImageTo3D を参照)。
        flags - 0 または REF: STEREO_ZERO_DISPARITY を指定できる操作フラグ。このフラグが設定されている場合、関数は各カメラの主点が平行化(rectified)後のビューで同じピクセル座標を持つようにする。フラグが設定されていない場合、関数は有効な画像領域を最大化するために、(エピポーラ線の向きに応じて)画像を水平方向または垂直方向にシフトすることがある。
        alpha - 自由スケーリングパラメータ。-1 または指定されていない場合、関数はデフォルトのスケーリングを実行する。それ以外の場合、このパラメータは0から1の間でなければならない。alpha=0 は、有効なピクセルのみが見えるように(平行化後に黒い領域が生じないように)平行化画像が拡大・移動されることを意味する。alpha=1 は、カメラの元画像のすべてのピクセルが平行化画像に保持される(元画像のピクセルが失われない)ように、平行化画像が縮小・移動されることを意味する。中間の値はこれら両極端の間の中間的な結果をもたらす。
        newImageSize - 平行化後の新しい画像解像度。同じサイズを #initUndistortRectifyMap に渡す必要がある(OpenCV の samples ディレクトリにある stereo_calib.cpp サンプルを参照)。(0,0) を渡した場合(デフォルト)、元の imageSize に設定される。これをより大きな値に設定すると、特に大きな放射方向の歪みがある場合に、元画像の細部を保持するのに役立つ。
        validPixROI1 - Optional output rectangles inside the rectified images where all the pixels are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller (see the picture below). are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller (see the picture below). The function computes the rotation matrices for each camera that (virtually) make both camera image planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate as input. As output, it provides two rotation matrices and also two projection matrices in the new coordinates. The function distinguishes the following two cases:
        • 水平ステレオ: 第1カメラと第2カメラのビューが、主にx軸に沿って互いにずれている(垂直方向の小さなずれも起こりうる)。平行化された画像では、左右のカメラの対応するエピポーラ線は水平で、同じy座標を持つ。P1 と P2 は次のようになる:
        \(\texttt{P1} = \begin{bmatrix} f & 0 & cx_1 & 0 \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\) \(\texttt{P2} = \begin{bmatrix} f & 0 & cx_2 & T_x \cdot f \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix} ,\) \(\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx_1 \\ 0 & 1 & 0 & -cy \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_x} & \frac{cx_1 - cx_2}{T_x} \end{bmatrix} \) where \(T_x\) is a horizontal shift between the cameras and \(cx_1=cx_2\) if REF: STEREO_ZERO_DISPARITY is set.
        • 垂直ステレオ: 第1カメラと第2カメラのビューが、主に垂直方向に互いにずれている(おそらく水平方向にも少しずれている)。平行化された画像のエピポーラ線は垂直で、同じx座標を持つ。P1 と P2 は次のようになる:
        \(\texttt{P1} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_1 & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\) \(\texttt{P2} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_2 & T_y \cdot f \\ 0 & 0 & 1 & 0 \end{bmatrix},\) \(\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx \\ 0 & 1 & 0 & -cy_1 \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_y} & \frac{cy_1 - cy_2}{T_y} \end{bmatrix} \) where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if REF: STEREO_ZERO_DISPARITY is set. As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to initialize the rectification map for each camera. See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through the corresponding image regions. This means that the images are well rectified, which is what most stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that their interiors are all valid pixels. ![image](pics/stereo_undistort.jpg)
      • stereoRectify

        public static void stereoRectify​(Mat cameraMatrix1,
                                         Mat distCoeffs1,
                                         Mat cameraMatrix2,
                                         Mat distCoeffs2,
                                         Size imageSize,
                                         Mat R,
                                         Mat T,
                                         Mat R1,
                                         Mat R2,
                                         Mat P1,
                                         Mat P2,
                                         Mat Q,
                                         int flags,
                                         double alpha,
                                         Size newImageSize)
        Computes rectification transforms for each head of a calibrated stereo camera.
        引数:
        cameraMatrix1 - 第1カメラの内部行列。
        distCoeffs1 - 第1カメラの歪みパラメータ。
        cameraMatrix2 - 第2カメラの内部行列。
        distCoeffs2 - 第2カメラの歪みパラメータ。
        imageSize - ステレオキャリブレーションに使用する画像のサイズ。
        R - 第1カメラの座標系から第2カメラへの回転行列。REF: stereoCalibrate を参照。
        T - 第1カメラの座標系から第2カメラへの並進ベクトル。REF: stereoCalibrate を参照。
        R1 - 第1カメラの出力3x3平行化変換(回転行列)。この行列は、平行化されていない第1カメラの座標系で与えられた点を、平行化された第1カメラの座標系の点へと変換する。より技術的に言えば、平行化されていない第1カメラの座標系から平行化された第1カメラの座標系への基底変換を行う。
        R2 - 第2カメラの出力3x3平行化変換(回転行列)。この行列は、平行化されていない第2カメラの座標系で与えられた点を、平行化された第2カメラの座標系の点へと変換する。より技術的に言えば、平行化されていない第2カメラの座標系から平行化された第2カメラの座標系への基底変換を行う。
        P1 - 第1カメラの新しい(平行化された)座標系における出力3x4射影行列。すなわち、平行化された第1カメラ座標系で与えられた点を平行化された第1カメラの画像へ射影する。
        P2 - 第2カメラの新しい(平行化された)座標系における出力3x4射影行列。すなわち、平行化された第1カメラ座標系で与えられた点を平行化された第2カメラの画像へ射影する。
        Q - 出力 \(4 \times 4\) 視差から深度への写像行列(REF: reprojectImageTo3D を参照)。
        flags - 0 または REF: STEREO_ZERO_DISPARITY を指定できる操作フラグ。このフラグが設定されている場合、関数は各カメラの主点が平行化(rectified)後のビューで同じピクセル座標を持つようにする。フラグが設定されていない場合、関数は有効な画像領域を最大化するために、(エピポーラ線の向きに応じて)画像を水平方向または垂直方向にシフトすることがある。
        alpha - 自由スケーリングパラメータ。-1 または指定されていない場合、関数はデフォルトのスケーリングを実行する。それ以外の場合、このパラメータは0から1の間でなければならない。alpha=0 は、有効なピクセルのみが見えるように(平行化後に黒い領域が生じないように)平行化画像が拡大・移動されることを意味する。alpha=1 は、カメラの元画像のすべてのピクセルが平行化画像に保持される(元画像のピクセルが失われない)ように、平行化画像が縮小・移動されることを意味する。中間の値はこれら両極端の間の中間的な結果をもたらす。
        newImageSize - New image resolution after rectification. The same size should be passed to #initUndistortRectifyMap (see the stereo_calib.cpp sample in OpenCV samples directory). When (0,0) is passed (default), it is set to the original imageSize . Setting it to a larger value can help you preserve details in the original image, especially when there is a big radial distortion. are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller (see the picture below). are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller (see the picture below). The function computes the rotation matrices for each camera that (virtually) make both camera image planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate as input. As output, it provides two rotation matrices and also two projection matrices in the new coordinates. The function distinguishes the following two cases:
        • 水平ステレオ: 第1カメラと第2カメラのビューが、主にx軸に沿って互いにずれている(垂直方向の小さなずれも起こりうる)。平行化された画像では、左右のカメラの対応するエピポーラ線は水平で、同じy座標を持つ。P1 と P2 は次のようになる:
        \(\texttt{P1} = \begin{bmatrix} f & 0 & cx_1 & 0 \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\) \(\texttt{P2} = \begin{bmatrix} f & 0 & cx_2 & T_x \cdot f \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix} ,\) \(\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx_1 \\ 0 & 1 & 0 & -cy \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_x} & \frac{cx_1 - cx_2}{T_x} \end{bmatrix} \) where \(T_x\) is a horizontal shift between the cameras and \(cx_1=cx_2\) if REF: STEREO_ZERO_DISPARITY is set.
        • 垂直ステレオ: 第1カメラと第2カメラのビューが、主に垂直方向に互いにずれている(おそらく水平方向にも少しずれている)。平行化された画像のエピポーラ線は垂直で、同じx座標を持つ。P1 と P2 は次のようになる:
        \(\texttt{P1} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_1 & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\) \(\texttt{P2} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_2 & T_y \cdot f \\ 0 & 0 & 1 & 0 \end{bmatrix},\) \(\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx \\ 0 & 1 & 0 & -cy_1 \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_y} & \frac{cy_1 - cy_2}{T_y} \end{bmatrix} \) where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if REF: STEREO_ZERO_DISPARITY is set. As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to initialize the rectification map for each camera. See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through the corresponding image regions. This means that the images are well rectified, which is what most stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that their interiors are all valid pixels. ![image](pics/stereo_undistort.jpg)
      • stereoRectify

        public static void stereoRectify​(Mat cameraMatrix1,
                                         Mat distCoeffs1,
                                         Mat cameraMatrix2,
                                         Mat distCoeffs2,
                                         Size imageSize,
                                         Mat R,
                                         Mat T,
                                         Mat R1,
                                         Mat R2,
                                         Mat P1,
                                         Mat P2,
                                         Mat Q,
                                         int flags,
                                         double alpha)
        Computes rectification transforms for each head of a calibrated stereo camera.
        引数:
        cameraMatrix1 - 第1カメラの内部行列。
        distCoeffs1 - 第1カメラの歪みパラメータ。
        cameraMatrix2 - 第2カメラの内部行列。
        distCoeffs2 - 第2カメラの歪みパラメータ。
        imageSize - ステレオキャリブレーションに使用する画像のサイズ。
        R - 第1カメラの座標系から第2カメラへの回転行列。REF: stereoCalibrate を参照。
        T - 第1カメラの座標系から第2カメラへの並進ベクトル。REF: stereoCalibrate を参照。
        R1 - 第1カメラの出力3x3平行化変換(回転行列)。この行列は、平行化されていない第1カメラの座標系で与えられた点を、平行化された第1カメラの座標系の点へと変換する。より技術的に言えば、平行化されていない第1カメラの座標系から平行化された第1カメラの座標系への基底変換を行う。
        R2 - 第2カメラの出力3x3平行化変換(回転行列)。この行列は、平行化されていない第2カメラの座標系で与えられた点を、平行化された第2カメラの座標系の点へと変換する。より技術的に言えば、平行化されていない第2カメラの座標系から平行化された第2カメラの座標系への基底変換を行う。
        P1 - 第1カメラの新しい(平行化された)座標系における出力3x4射影行列。すなわち、平行化された第1カメラ座標系で与えられた点を平行化された第1カメラの画像へ射影する。
        P2 - 第2カメラの新しい(平行化された)座標系における出力3x4射影行列。すなわち、平行化された第1カメラ座標系で与えられた点を平行化された第2カメラの画像へ射影する。
        Q - 出力 \(4 \times 4\) 視差から深度への写像行列(REF: reprojectImageTo3D を参照)。
        flags - 0 または REF: STEREO_ZERO_DISPARITY を指定できる操作フラグ。このフラグが設定されている場合、関数は各カメラの主点が平行化(rectified)後のビューで同じピクセル座標を持つようにする。フラグが設定されていない場合、関数は有効な画像領域を最大化するために、(エピポーラ線の向きに応じて)画像を水平方向または垂直方向にシフトすることがある。
        alpha - Free scaling parameter. If it is -1 or absent, the function performs the default scaling. Otherwise, the parameter should be between 0 and 1. alpha=0 means that the rectified images are zoomed and shifted so that only valid pixels are visible (no black areas after rectification). alpha=1 means that the rectified image is decimated and shifted so that all the pixels from the original images from the cameras are retained in the rectified images (no source image pixels are lost). Any intermediate value yields an intermediate result between those two extreme cases. #initUndistortRectifyMap (see the stereo_calib.cpp sample in OpenCV samples directory). When (0,0) is passed (default), it is set to the original imageSize . Setting it to a larger value can help you preserve details in the original image, especially when there is a big radial distortion. are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller (see the picture below). are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller (see the picture below). The function computes the rotation matrices for each camera that (virtually) make both camera image planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate as input. As output, it provides two rotation matrices and also two projection matrices in the new coordinates. The function distinguishes the following two cases:
        • 水平ステレオ: 第1カメラと第2カメラのビューが、主にx軸に沿って互いにずれている(垂直方向の小さなずれも起こりうる)。平行化された画像では、左右のカメラの対応するエピポーラ線は水平で、同じy座標を持つ。P1 と P2 は次のようになる:
        \(\texttt{P1} = \begin{bmatrix} f & 0 & cx_1 & 0 \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\) \(\texttt{P2} = \begin{bmatrix} f & 0 & cx_2 & T_x \cdot f \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix} ,\) \(\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx_1 \\ 0 & 1 & 0 & -cy \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_x} & \frac{cx_1 - cx_2}{T_x} \end{bmatrix} \) where \(T_x\) is a horizontal shift between the cameras and \(cx_1=cx_2\) if REF: STEREO_ZERO_DISPARITY is set.
        • 垂直ステレオ: 第1カメラと第2カメラのビューが、主に垂直方向に互いにずれている(おそらく水平方向にも少しずれている)。平行化された画像のエピポーラ線は垂直で、同じx座標を持つ。P1 と P2 は次のようになる:
        \(\texttt{P1} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_1 & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\) \(\texttt{P2} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_2 & T_y \cdot f \\ 0 & 0 & 1 & 0 \end{bmatrix},\) \(\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx \\ 0 & 1 & 0 & -cy_1 \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_y} & \frac{cy_1 - cy_2}{T_y} \end{bmatrix} \) where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if REF: STEREO_ZERO_DISPARITY is set. As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to initialize the rectification map for each camera. See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through the corresponding image regions. This means that the images are well rectified, which is what most stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that their interiors are all valid pixels. ![image](pics/stereo_undistort.jpg)
      • stereoRectify

        public static void stereoRectify​(Mat cameraMatrix1,
                                         Mat distCoeffs1,
                                         Mat cameraMatrix2,
                                         Mat distCoeffs2,
                                         Size imageSize,
                                         Mat R,
                                         Mat T,
                                         Mat R1,
                                         Mat R2,
                                         Mat P1,
                                         Mat P2,
                                         Mat Q,
                                         int flags)
        Computes rectification transforms for each head of a calibrated stereo camera.
        引数:
        cameraMatrix1 - 第1カメラの内部行列。
        distCoeffs1 - 第1カメラの歪みパラメータ。
        cameraMatrix2 - 第2カメラの内部行列。
        distCoeffs2 - 第2カメラの歪みパラメータ。
        imageSize - ステレオキャリブレーションに使用する画像のサイズ。
        R - 第1カメラの座標系から第2カメラへの回転行列。REF: stereoCalibrate を参照。
        T - 第1カメラの座標系から第2カメラへの並進ベクトル。REF: stereoCalibrate を参照。
        R1 - 第1カメラの出力3x3平行化変換(回転行列)。この行列は、平行化されていない第1カメラの座標系で与えられた点を、平行化された第1カメラの座標系の点へと変換する。より技術的に言えば、平行化されていない第1カメラの座標系から平行化された第1カメラの座標系への基底変換を行う。
        R2 - 第2カメラの出力3x3平行化変換(回転行列)。この行列は、平行化されていない第2カメラの座標系で与えられた点を、平行化された第2カメラの座標系の点へと変換する。より技術的に言えば、平行化されていない第2カメラの座標系から平行化された第2カメラの座標系への基底変換を行う。
        P1 - 第1カメラの新しい(平行化された)座標系における出力3x4射影行列。すなわち、平行化された第1カメラ座標系で与えられた点を平行化された第1カメラの画像へ射影する。
        P2 - 第2カメラの新しい(平行化された)座標系における出力3x4射影行列。すなわち、平行化された第1カメラ座標系で与えられた点を平行化された第2カメラの画像へ射影する。
        Q - 出力 \(4 \times 4\) 視差から深度への写像行列(REF: reprojectImageTo3D を参照)。
        flags - Operation flags that may be zero or REF: STEREO_ZERO_DISPARITY . If the flag is set, the function makes the principal points of each camera have the same pixel coordinates in the rectified views. And if the flag is not set, the function may still shift the images in the horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the useful image area. scaling. Otherwise, the parameter should be between 0 and 1. alpha=0 means that the rectified images are zoomed and shifted so that only valid pixels are visible (no black areas after rectification). alpha=1 means that the rectified image is decimated and shifted so that all the pixels from the original images from the cameras are retained in the rectified images (no source image pixels are lost). Any intermediate value yields an intermediate result between those two extreme cases. #initUndistortRectifyMap (see the stereo_calib.cpp sample in OpenCV samples directory). When (0,0) is passed (default), it is set to the original imageSize . Setting it to a larger value can help you preserve details in the original image, especially when there is a big radial distortion. are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller (see the picture below). are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller (see the picture below). The function computes the rotation matrices for each camera that (virtually) make both camera image planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate as input. As output, it provides two rotation matrices and also two projection matrices in the new coordinates. The function distinguishes the following two cases:
        • 水平ステレオ: 第1カメラと第2カメラのビューが、主にx軸に沿って互いにずれている(垂直方向の小さなずれも起こりうる)。平行化された画像では、左右のカメラの対応するエピポーラ線は水平で、同じy座標を持つ。P1 と P2 は次のようになる:
        \(\texttt{P1} = \begin{bmatrix} f & 0 & cx_1 & 0 \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\) \(\texttt{P2} = \begin{bmatrix} f & 0 & cx_2 & T_x \cdot f \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix} ,\) \(\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx_1 \\ 0 & 1 & 0 & -cy \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_x} & \frac{cx_1 - cx_2}{T_x} \end{bmatrix} \) where \(T_x\) is a horizontal shift between the cameras and \(cx_1=cx_2\) if REF: STEREO_ZERO_DISPARITY is set.
        • 垂直ステレオ: 第1カメラと第2カメラのビューが、主に垂直方向に互いにずれている(おそらく水平方向にも少しずれている)。平行化された画像のエピポーラ線は垂直で、同じx座標を持つ。P1 と P2 は次のようになる:
        \(\texttt{P1} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_1 & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\) \(\texttt{P2} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_2 & T_y \cdot f \\ 0 & 0 & 1 & 0 \end{bmatrix},\) \(\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx \\ 0 & 1 & 0 & -cy_1 \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_y} & \frac{cy_1 - cy_2}{T_y} \end{bmatrix} \) where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if REF: STEREO_ZERO_DISPARITY is set. As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to initialize the rectification map for each camera. See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through the corresponding image regions. This means that the images are well rectified, which is what most stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that their interiors are all valid pixels. ![image](pics/stereo_undistort.jpg)
      • stereoRectify

        public static void stereoRectify​(Mat cameraMatrix1,
                                         Mat distCoeffs1,
                                         Mat cameraMatrix2,
                                         Mat distCoeffs2,
                                         Size imageSize,
                                         Mat R,
                                         Mat T,
                                         Mat R1,
                                         Mat R2,
                                         Mat P1,
                                         Mat P2,
                                         Mat Q)
        Computes rectification transforms for each head of a calibrated stereo camera.
        引数:
        cameraMatrix1 - 第1カメラの内部行列。
        distCoeffs1 - 第1カメラの歪みパラメータ。
        cameraMatrix2 - 第2カメラの内部行列。
        distCoeffs2 - 第2カメラの歪みパラメータ。
        imageSize - ステレオキャリブレーションに使用する画像のサイズ。
        R - 第1カメラの座標系から第2カメラへの回転行列。REF: stereoCalibrate を参照。
        T - 第1カメラの座標系から第2カメラへの並進ベクトル。REF: stereoCalibrate を参照。
        R1 - 第1カメラの出力3x3平行化変換(回転行列)。この行列は、平行化されていない第1カメラの座標系で与えられた点を、平行化された第1カメラの座標系の点へと変換する。より技術的に言えば、平行化されていない第1カメラの座標系から平行化された第1カメラの座標系への基底変換を行う。
        R2 - 第2カメラの出力3x3平行化変換(回転行列)。この行列は、平行化されていない第2カメラの座標系で与えられた点を、平行化された第2カメラの座標系の点へと変換する。より技術的に言えば、平行化されていない第2カメラの座標系から平行化された第2カメラの座標系への基底変換を行う。
        P1 - 第1カメラの新しい(平行化された)座標系における出力3x4射影行列。すなわち、平行化された第1カメラ座標系で与えられた点を平行化された第1カメラの画像へ射影する。
        P2 - 第2カメラの新しい(平行化された)座標系における出力3x4射影行列。すなわち、平行化された第1カメラ座標系で与えられた点を平行化された第2カメラの画像へ射影する。
        Q - Output \(4 \times 4\) disparity-to-depth mapping matrix (see REF: reprojectImageTo3D). the function makes the principal points of each camera have the same pixel coordinates in the rectified views. And if the flag is not set, the function may still shift the images in the horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the useful image area. scaling. Otherwise, the parameter should be between 0 and 1. alpha=0 means that the rectified images are zoomed and shifted so that only valid pixels are visible (no black areas after rectification). alpha=1 means that the rectified image is decimated and shifted so that all the pixels from the original images from the cameras are retained in the rectified images (no source image pixels are lost). Any intermediate value yields an intermediate result between those two extreme cases. #initUndistortRectifyMap (see the stereo_calib.cpp sample in OpenCV samples directory). When (0,0) is passed (default), it is set to the original imageSize . Setting it to a larger value can help you preserve details in the original image, especially when there is a big radial distortion. are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller (see the picture below). are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller (see the picture below). The function computes the rotation matrices for each camera that (virtually) make both camera image planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate as input. As output, it provides two rotation matrices and also two projection matrices in the new coordinates. The function distinguishes the following two cases:
        • 水平ステレオ: 第1カメラと第2カメラのビューが、主にx軸に沿って互いにずれている(垂直方向の小さなずれも起こりうる)。平行化された画像では、左右のカメラの対応するエピポーラ線は水平で、同じy座標を持つ。P1 と P2 は次のようになる:
        \(\texttt{P1} = \begin{bmatrix} f & 0 & cx_1 & 0 \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\) \(\texttt{P2} = \begin{bmatrix} f & 0 & cx_2 & T_x \cdot f \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix} ,\) \(\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx_1 \\ 0 & 1 & 0 & -cy \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_x} & \frac{cx_1 - cx_2}{T_x} \end{bmatrix} \) where \(T_x\) is a horizontal shift between the cameras and \(cx_1=cx_2\) if REF: STEREO_ZERO_DISPARITY is set.
        • 垂直ステレオ: 第1カメラと第2カメラのビューが、主に垂直方向に互いにずれている(おそらく水平方向にも少しずれている)。平行化された画像のエピポーラ線は垂直で、同じx座標を持つ。P1 と P2 は次のようになる:
        \(\texttt{P1} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_1 & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\) \(\texttt{P2} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_2 & T_y \cdot f \\ 0 & 0 & 1 & 0 \end{bmatrix},\) \(\texttt{Q} = \begin{bmatrix} 1 & 0 & 0 & -cx \\ 0 & 1 & 0 & -cy_1 \\ 0 & 0 & 0 & f \\ 0 & 0 & -\frac{1}{T_y} & \frac{cy_1 - cy_2}{T_y} \end{bmatrix} \) where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if REF: STEREO_ZERO_DISPARITY is set. As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to initialize the rectification map for each camera. See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through the corresponding image regions. This means that the images are well rectified, which is what most stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that their interiors are all valid pixels. ![image](pics/stereo_undistort.jpg)
      • stereoRectifyUncalibrated

        public static boolean stereoRectifyUncalibrated​(Mat points1,
                                                        Mat points2,
                                                        Mat F,
                                                        Size imgSize,
                                                        Mat H1,
                                                        Mat H2,
                                                        double threshold)
        Computes a rectification transform for an uncalibrated stereo camera.
        引数:
        points1 - 第1画像の特徴点の配列。
        points2 - 第2画像における対応する点。#findFundamentalMat と同じ形式がサポートされている。
        F - 入力基礎行列。同じ点ペアの集合から #findFundamentalMat を用いて計算できる。
        imgSize - 画像のサイズ。
        H1 - 第1画像の出力平行化ホモグラフィ行列。
        H2 - 第2画像の出力平行化ホモグラフィ行列。
        threshold - 外れ値を除外するために使用する省略可能なしきい値。パラメータが0より大きい場合、エピポーラ幾何に適合しないすべての点ペア(すなわち \(|\texttt{points2[i]}^T \cdot \texttt{F} \cdot \texttt{points1[i]}|>\texttt{threshold}\) となる点)は、ホモグラフィを計算する前に除外される。それ以外の場合、すべての点がインライアとみなされる。この関数は、カメラの内部パラメータや空間内での相対位置を知らずに平行化変換を計算するため、接尾辞「uncalibrated」が付いている。#stereoRectify とのもう一つの関連する違いは、この関数が物体(3D)空間での平行化変換ではなく、ホモグラフィ行列 H1 と H2 によって符号化された平面透視変換を出力する点である。この関数はアルゴリズム CITE: Hartley99 を実装している。注: このアルゴリズムはカメラの内部パラメータを知る必要はないが、エピポーラ幾何に大きく依存する。したがって、カメラレンズに大きな歪みがある場合は、基礎行列を計算しこの関数を呼び出す前にそれを補正しておくほうがよい。たとえば、#calibrateCamera を使用してステレオカメラの各ヘッドごとに歪み係数を個別に推定できる。その後、#undistort を使用して画像を補正するか、あるいは #undistortPoints を使用して点の座標だけを補正できる。
        戻り値:
        自動生成
      • stereoRectifyUncalibrated

        public static boolean stereoRectifyUncalibrated​(Mat points1,
                                                        Mat points2,
                                                        Mat F,
                                                        Size imgSize,
                                                        Mat H1,
                                                        Mat H2)
        Computes a rectification transform for an uncalibrated stereo camera.
        引数:
        points1 - 第1画像の特徴点の配列。
        points2 - 第2画像における対応する点。#findFundamentalMat と同じ形式がサポートされている。
        F - 入力基礎行列。同じ点ペアの集合から #findFundamentalMat を用いて計算できる。
        imgSize - 画像のサイズ。
        H1 - 第1画像の出力平行化ホモグラフィ行列。
        H2 - 第2画像の出力平行化ホモグラフィ行列。0より大きい場合、エピポーラ幾何に適合しないすべての点ペア(すなわち \(|\texttt{points2[i]}^T \cdot \texttt{F} \cdot \texttt{points1[i]}|>\texttt{threshold}\) となる点)は、ホモグラフィを計算する前に除外される。それ以外の場合、すべての点がインライアとみなされる。この関数は、カメラの内部パラメータや空間内での相対位置を知らずに平行化変換を計算するため、接尾辞「uncalibrated」が付いている。#stereoRectify とのもう一つの関連する違いは、この関数が物体(3D)空間での平行化変換ではなく、ホモグラフィ行列 H1 と H2 によって符号化された平面透視変換を出力する点である。この関数はアルゴリズム CITE: Hartley99 を実装している。注: このアルゴリズムはカメラの内部パラメータを知る必要はないが、エピポーラ幾何に大きく依存する。したがって、カメラレンズに大きな歪みがある場合は、基礎行列を計算しこの関数を呼び出す前にそれを補正しておくほうがよい。たとえば、#calibrateCamera を使用してステレオカメラの各ヘッドごとに歪み係数を個別に推定できる。その後、#undistort を使用して画像を補正するか、あるいは #undistortPoints を使用して点の座標だけを補正できる。
        戻り値:
        自動生成
      • fisheye_stereoRectify

        public static void fisheye_stereoRectify​(Mat K1,
                                                 Mat D1,
                                                 Mat K2,
                                                 Mat D2,
                                                 Size imageSize,
                                                 Mat R,
                                                 Mat tvec,
                                                 Mat R1,
                                                 Mat R2,
                                                 Mat P1,
                                                 Mat P2,
                                                 Mat Q,
                                                 int flags,
                                                 Size newImageSize,
                                                 double balance,
                                                 double fov_scale)
        Stereo rectification for fisheye camera model
        引数:
        K1 - 1台目のカメラの内部行列。
        D1 - 1台目のカメラの歪みパラメータ。
        K2 - 2台目のカメラの内部行列。
        D2 - 2台目のカメラの歪みパラメータ。
        imageSize - ステレオキャリブレーションに使用する画像のサイズ。
        R - 1台目と2台目のカメラの座標系間の回転行列。
        tvec - カメラの座標系間の並進ベクトル。
        R1 - 1台目のカメラに対する出力の3x3整列変換(回転行列)。
        R2 - 2台目のカメラに対する出力の3x3整列変換(回転行列)。
        P1 - 1台目のカメラに対する、新しい(整列後の)座標系での出力の3x4投影行列。
        P2 - 2台目のカメラに対する、新しい(整列後の)座標系での出力の3x4投影行列。
        Q - 出力される \(4 \times 4\) の視差-深度変換行列 (reprojectImageTo3D を参照)。
        flags - 0 または REF: cv::CALIB_ZERO_DISPARITY を指定できる操作フラグ。このフラグが設定されている場合、関数は各カメラの主点が平行化(rectified)後のビューで同じピクセル座標を持つようにする。フラグが設定されていない場合、関数は有効な画像領域を最大化するために、(エピポーラ線の向きに応じて)画像を水平方向または垂直方向にシフトすることがある。
        newImageSize - 整列後の新しい画像解像度。同じサイズを #initUndistortRectifyMap へ渡す必要がある(OpenCVのsamplesディレクトリにある stereo_calib.cpp のサンプルを参照)。(0,0) が渡された場合(デフォルト)、元の imageSize に設定される。より大きい値を設定すると、特に大きな放射状歪みがある場合に元画像のディテールを保持しやすくなる。
        balance - 最小焦点距離と最大焦点距離の間の範囲で新しい焦点距離を設定する。balance は [0, 1] の範囲。
        fov_scale - 新しい焦点距離の除数。
      • fisheye_stereoRectify

        public static void fisheye_stereoRectify​(Mat K1,
                                                 Mat D1,
                                                 Mat K2,
                                                 Mat D2,
                                                 Size imageSize,
                                                 Mat R,
                                                 Mat tvec,
                                                 Mat R1,
                                                 Mat R2,
                                                 Mat P1,
                                                 Mat P2,
                                                 Mat Q,
                                                 int flags,
                                                 Size newImageSize,
                                                 double balance)
        Stereo rectification for fisheye camera model
        引数:
        K1 - 1台目のカメラの内部行列。
        D1 - 1台目のカメラの歪みパラメータ。
        K2 - 2台目のカメラの内部行列。
        D2 - 2台目のカメラの歪みパラメータ。
        imageSize - ステレオキャリブレーションに使用する画像のサイズ。
        R - 1台目と2台目のカメラの座標系間の回転行列。
        tvec - カメラの座標系間の並進ベクトル。
        R1 - 1台目のカメラに対する出力の3x3整列変換(回転行列)。
        R2 - 2台目のカメラに対する出力の3x3整列変換(回転行列)。
        P1 - 1台目のカメラに対する、新しい(整列後の)座標系での出力の3x4投影行列。
        P2 - 2台目のカメラに対する、新しい(整列後の)座標系での出力の3x4投影行列。
        Q - 出力される \(4 \times 4\) の視差-深度変換行列 (reprojectImageTo3D を参照)。
        flags - 0 または REF: cv::CALIB_ZERO_DISPARITY を指定できる操作フラグ。このフラグが設定されている場合、関数は各カメラの主点が平行化(rectified)後のビューで同じピクセル座標を持つようにする。フラグが設定されていない場合、関数は有効な画像領域を最大化するために、(エピポーラ線の向きに応じて)画像を水平方向または垂直方向にシフトすることがある。
        newImageSize - 整列後の新しい画像解像度。同じサイズを #initUndistortRectifyMap へ渡す必要がある(OpenCVのsamplesディレクトリにある stereo_calib.cpp のサンプルを参照)。(0,0) が渡された場合(デフォルト)、元の imageSize に設定される。より大きい値を設定すると、特に大きな放射状歪みがある場合に元画像のディテールを保持しやすくなる。
        balance - 最小焦点距離と最大焦点距離の間の範囲で新しい焦点距離を設定する。balance は [0, 1] の範囲。
      • fisheye_stereoRectify

        public static void fisheye_stereoRectify​(Mat K1,
                                                 Mat D1,
                                                 Mat K2,
                                                 Mat D2,
                                                 Size imageSize,
                                                 Mat R,
                                                 Mat tvec,
                                                 Mat R1,
                                                 Mat R2,
                                                 Mat P1,
                                                 Mat P2,
                                                 Mat Q,
                                                 int flags,
                                                 Size newImageSize)
        Stereo rectification for fisheye camera model
        引数:
        K1 - 1台目のカメラの内部行列。
        D1 - 1台目のカメラの歪みパラメータ。
        K2 - 2台目のカメラの内部行列。
        D2 - 2台目のカメラの歪みパラメータ。
        imageSize - ステレオキャリブレーションに使用する画像のサイズ。
        R - 1台目と2台目のカメラの座標系間の回転行列。
        tvec - カメラの座標系間の並進ベクトル。
        R1 - 1台目のカメラに対する出力の3x3整列変換(回転行列)。
        R2 - 2台目のカメラに対する出力の3x3整列変換(回転行列)。
        P1 - 1台目のカメラに対する、新しい(整列後の)座標系での出力の3x4投影行列。
        P2 - 2台目のカメラに対する、新しい(整列後の)座標系での出力の3x4投影行列。
        Q - 出力される \(4 \times 4\) の視差-深度変換行列 (reprojectImageTo3D を参照)。
        flags - 0 または REF: cv::CALIB_ZERO_DISPARITY を指定できる操作フラグ。このフラグが設定されている場合、関数は各カメラの主点が平行化(rectified)後のビューで同じピクセル座標を持つようにする。フラグが設定されていない場合、関数は有効な画像領域を最大化するために、(エピポーラ線の向きに応じて)画像を水平方向または垂直方向にシフトすることがある。
        newImageSize - 整列後の新しい画像解像度。同じサイズを #initUndistortRectifyMap へ渡す必要がある(OpenCVのsamplesディレクトリにある stereo_calib.cpp のサンプルを参照)。(0,0) が渡された場合(デフォルト)、元の imageSize に設定される。より大きい値を設定すると、特に大きな放射状歪みがある場合に元画像のディテールを保持しやすくなる。length. Balance は [0, 1] の範囲。
      • fisheye_stereoRectify

        public static void fisheye_stereoRectify​(Mat K1,
                                                 Mat D1,
                                                 Mat K2,
                                                 Mat D2,
                                                 Size imageSize,
                                                 Mat R,
                                                 Mat tvec,
                                                 Mat R1,
                                                 Mat R2,
                                                 Mat P1,
                                                 Mat P2,
                                                 Mat Q,
                                                 int flags)
        Stereo rectification for fisheye camera model
        引数:
        K1 - 1台目のカメラの内部行列。
        D1 - 1台目のカメラの歪みパラメータ。
        K2 - 2台目のカメラの内部行列。
        D2 - 2台目のカメラの歪みパラメータ。
        imageSize - ステレオキャリブレーションに使用する画像のサイズ。
        R - 1台目と2台目のカメラの座標系間の回転行列。
        tvec - カメラの座標系間の並進ベクトル。
        R1 - 1台目のカメラに対する出力の3x3整列変換(回転行列)。
        R2 - 2台目のカメラに対する出力の3x3整列変換(回転行列)。
        P1 - 1台目のカメラに対する、新しい(整列後の)座標系での出力の3x4投影行列。
        P2 - 2台目のカメラに対する、新しい(整列後の)座標系での出力の3x4投影行列。
        Q - 出力される \(4 \times 4\) の視差-深度変換行列 (reprojectImageTo3D を参照)。
        flags - 0 または REF: cv::CALIB_ZERO_DISPARITY を指定できる操作フラグ。このフラグが設定されている場合、関数は各カメラの主点が平行化(rectified)後のビューで同じピクセル座標を持つようにする。フラグが設定されていない場合、関数は有効な画像領域を最大化するために、(エピポーラ線の向きに応じて)画像を水平方向または垂直方向にシフトすることがある。 #initUndistortRectifyMap (OpenCV samples ディレクトリ内の stereo_calib.cpp サンプルを参照)。(0,0) が渡された場合(デフォルト)、元の imageSize に設定される。より大きな値を設定すると、特に大きな放射状歪みがある場合に、元画像のディテールを保持するのに役立つ。length。Balance は [0, 1] の範囲。
      • filterSpeckles

        public static void filterSpeckles​(Mat img,
                                          double newVal,
                                          int maxSpeckleSize,
                                          double maxDiff,
                                          Mat buf)
        Filters off small noise blobs (speckles) in the disparity map
        引数:
        img - 入力となる16ビット符号付きの視差画像
        newVal - スペックルを塗りつぶすために使用する視差値
        maxSpeckleSize - スペックルとみなす最大のスペックルサイズ。これより大きいブロブはアルゴリズムの影響を受けない
        maxDiff - 隣接する視差ピクセルを同じブロブにまとめる際の最大差分。StereoBM、StereoSGBM、そしておそらく他のアルゴリズムは、視差値が16倍された固定小数点形式の視差マップを返すため、この引数の値を指定する際にはこのスケール係数を考慮する必要があることに注意。
        buf - 関数内でのメモリ確保を避けるための省略可能な一時バッファ。
      • filterSpeckles

        public static void filterSpeckles​(Mat img,
                                          double newVal,
                                          int maxSpeckleSize,
                                          double maxDiff)
        Filters off small noise blobs (speckles) in the disparity map
        引数:
        img - 入力となる16ビット符号付きの視差画像
        newVal - スペックルを塗りつぶすために使用する視差値
        maxSpeckleSize - スペックルとみなす最大のスペックルサイズ。これより大きいブロブはアルゴリズムの影響を受けない
        maxDiff - 隣接する視差ピクセルを同じブロブにまとめる際の最大差分。StereoBM、StereoSGBM、そしておそらく他のアルゴリズムは、視差値が16倍された固定小数点形式の視差マップを返すため、この引数の値を指定する際にはこのスケール係数を考慮する必要があることに注意。
      • getValidDisparityROI

        public static Rect getValidDisparityROI​(Rect roi1,
                                                Rect roi2,
                                                int minDisparity,
                                                int numberOfDisparities,
                                                int blockSize)
      • validateDisparity

        public static void validateDisparity​(Mat disparity,
                                             Mat cost,
                                             int minDisparity,
                                             int numberOfDisparities,
                                             int disp12MaxDisp)
      • validateDisparity

        public static void validateDisparity​(Mat disparity,
                                             Mat cost,
                                             int minDisparity,
                                             int numberOfDisparities)
      • reprojectImageTo3D

        public static void reprojectImageTo3D​(Mat disparity,
                                              Mat _3dImage,
                                              Mat Q,
                                              boolean handleMissingValues,
                                              int ddepth)
        Reprojects a disparity image to 3D space.
        引数:
        disparity - 入力となるシングルチャンネルの8ビット符号なし、16ビット符号付き、32ビット符号付き、または32ビット浮動小数点の視差画像。8ビット/16ビット符号付き形式の値は小数部を持たないものとみなされる。視差がREF: StereoBM や REF: StereoSGBM、あるいは他のアルゴリズムで計算された16ビット符号付き形式の場合、ここで使用する前に16で割る必要がある(そしてfloatにスケーリングする)。
        _3dImage - disparityと同じサイズの3チャンネル浮動小数点出力画像。_3dImage(x,y)の各要素には、視差マップから計算された点(x,y)の3次元座標が格納される。REF: stereoRectify で得られたQを使用した場合、返される点は1台目のカメラの平行化座標系で表現される。
        Q - REF: stereoRectify で得られる \(4 \times 4\) の透視変換行列。
        handleMissingValues - 関数が欠損値(すなわち視差が計算されなかった点)を処理すべきかどうかを示す。handleMissingValues=true の場合、外れ値に対応する最小視差を持つピクセル(StereoMatcher::compute を参照)は、非常に大きなZ値(現在は10000に設定)を持つ3次元点に変換される。
        ddepth - 省略可能な出力配列のビット深度。-1の場合、出力画像はCV_32Fのビット深度になる。ddepthはCV_16S、CV_32S、CV_32Fに設定することもできる。この関数はシングルチャンネルの視差マップを、3次元曲面を表す3チャンネル画像に変換する。すなわち、各ピクセル(x,y)と対応する視差 d=disparity(x,y) に対して、次を計算する: \(\begin{bmatrix} X \\ Y \\ Z \\ W \end{bmatrix} = Q \begin{bmatrix} x \\ y \\ \texttt{disparity} (x,y) \\ 1 \end{bmatrix}.\) SEE: 疎な点集合 {(x,y,d),...} を3次元空間に再投影するには、perspectiveTransform を使用する。
      • reprojectImageTo3D

        public static void reprojectImageTo3D​(Mat disparity,
                                              Mat _3dImage,
                                              Mat Q,
                                              boolean handleMissingValues)
        Reprojects a disparity image to 3D space.
        引数:
        disparity - 入力となるシングルチャンネルの8ビット符号なし、16ビット符号付き、32ビット符号付き、または32ビット浮動小数点の視差画像。8ビット/16ビット符号付き形式の値は小数部を持たないものとみなされる。視差がREF: StereoBM や REF: StereoSGBM、あるいは他のアルゴリズムで計算された16ビット符号付き形式の場合、ここで使用する前に16で割る必要がある(そしてfloatにスケーリングする)。
        _3dImage - disparityと同じサイズの3チャンネル浮動小数点出力画像。_3dImage(x,y)の各要素には、視差マップから計算された点(x,y)の3次元座標が格納される。REF: stereoRectify で得られたQを使用した場合、返される点は1台目のカメラの平行化座標系で表現される。
        Q - REF: stereoRectify で得られる \(4 \times 4\) の透視変換行列。
        handleMissingValues - 関数が欠損値(すなわち視差が計算されなかった点)を処理すべきかどうかを示す。handleMissingValues=true の場合、外れ値に対応する最小視差を持つピクセル(StereoMatcher::compute を参照)は、非常に大きなZ値(現在は10000に設定)を持つ3次元点に変換される。ビット深度。ddepthはCV_16S、CV_32S、CV_32Fに設定することもできる。この関数はシングルチャンネルの視差マップを、3次元曲面を表す3チャンネル画像に変換する。すなわち、各ピクセル(x,y)と対応する視差 d=disparity(x,y) に対して、次を計算する: \(\begin{bmatrix} X \\ Y \\ Z \\ W \end{bmatrix} = Q \begin{bmatrix} x \\ y \\ \texttt{disparity} (x,y) \\ 1 \end{bmatrix}.\) SEE: 疎な点集合 {(x,y,d),...} を3次元空間に再投影するには、perspectiveTransform を使用する。
      • reprojectImageTo3D

        public static void reprojectImageTo3D​(Mat disparity,
                                              Mat _3dImage,
                                              Mat Q)
        Reprojects a disparity image to 3D space.
        引数:
        disparity - 入力となるシングルチャンネルの8ビット符号なし、16ビット符号付き、32ビット符号付き、または32ビット浮動小数点の視差画像。8ビット/16ビット符号付き形式の値は小数部を持たないものとみなされる。視差がREF: StereoBM や REF: StereoSGBM、あるいは他のアルゴリズムで計算された16ビット符号付き形式の場合、ここで使用する前に16で割る必要がある(そしてfloatにスケーリングする)。
        _3dImage - disparityと同じサイズの3チャンネル浮動小数点出力画像。_3dImage(x,y)の各要素には、視差マップから計算された点(x,y)の3次元座標が格納される。REF: stereoRectify で得られたQを使用した場合、返される点は1台目のカメラの平行化座標系で表現される。
        Q - REF: stereoRectify で得られる \(4 \times 4\) の透視変換行列。視差が計算されなかった点)。handleMissingValues=true の場合、外れ値に対応する最小視差を持つピクセル(StereoMatcher::compute を参照)は、非常に大きなZ値(現在は10000に設定)を持つ3次元点に変換される。ビット深度。ddepthはCV_16S、CV_32S、CV_32Fに設定することもできる。この関数はシングルチャンネルの視差マップを、3次元曲面を表す3チャンネル画像に変換する。すなわち、各ピクセル(x,y)と対応する視差 d=disparity(x,y) に対して、次を計算する: \(\begin{bmatrix} X \\ Y \\ Z \\ W \end{bmatrix} = Q \begin{bmatrix} x \\ y \\ \texttt{disparity} (x,y) \\ 1 \end{bmatrix}.\) SEE: 疎な点集合 {(x,y,d),...} を3次元空間に再投影するには、perspectiveTransform を使用する。