コード例 #1
0
ファイル: ArucoInvoke.cs プロジェクト: ys20161205/emgucv
 /// <summary>
 ///  Pose estimation for a ChArUco board given some of their corners
 /// </summary>
 /// <param name="charucoCorners">vector of detected charuco corners</param>
 /// <param name="charucoIds">list of identifiers for each corner in charucoCorners</param>
 /// <param name="board">layout of ChArUco board.</param>
 /// <param name="cameraMatrix">input 3x3 floating-point camera matrix</param>
 /// <param name="distCoeffs">vector of distortion coefficients, 4, 5, 8 or 12 elements</param>
 /// <param name="rvec">Output vector (e.g. cv::Mat) corresponding to the rotation vector of the board</param>
 /// <param name="tvec">Output vector (e.g. cv::Mat) corresponding to the translation vector of the board.</param>
 /// <param name="useExtrinsicGuess">defines whether initial guess for rvec and  tvec will be used or not.</param>
 /// <returns>If pose estimation is valid, returns true, else returns false.</returns>
 public static bool EstimatePoseCharucoBoard(
     IInputArray charucoCorners,
     IInputArray charucoIds,
     CharucoBoard board,
     IInputArray cameraMatrix,
     IInputArray distCoeffs,
     IOutputArray rvec,
     IOutputArray tvec,
     bool useExtrinsicGuess = false)
 {
     using (InputArray iaCharucoCorners = charucoCorners.GetInputArray())
         using (InputArray iaCharucoIds = charucoIds.GetInputArray())
             using (InputArray iaCameraMatrix = cameraMatrix.GetInputArray())
                 using (InputArray iaDistCoeffs = distCoeffs.GetInputArray())
                     using (OutputArray oaRvec = rvec.GetOutputArray())
                         using (OutputArray oaTvec = tvec.GetOutputArray())
                         {
                             return(cveArucoEstimatePoseCharucoBoard(
                                        iaCharucoCorners,
                                        iaCharucoIds,
                                        board,
                                        iaCameraMatrix,
                                        iaDistCoeffs,
                                        oaRvec,
                                        oaTvec,
                                        useExtrinsicGuess));
                         }
 }
コード例 #2
0
ファイル: ArucoInvoke.cs プロジェクト: ys20161205/emgucv
 /// <summary>
 /// Calibrate a camera using Charuco corners.
 /// </summary>
 /// <param name="charucoCorners">Vector of detected charuco corners per frame</param>
 /// <param name="charucoIds">List of identifiers for each corner in charucoCorners per frame</param>
 /// <param name="board">Marker Board layout</param>
 /// <param name="imageSize">Size of the image used only to initialize the intrinsic camera matrix.</param>
 /// <param name="cameraMatrix">Output 3x3 floating-point camera matrix. </param>
 /// <param name="distCoeffs">Output vector of distortion coefficients (k1,k2,p1,p2[,k3[,k4,k5,k6],[s1,s2,s3,s4]]) of 4, 5, 8 or 12 elements</param>
 /// <param name="rvecs">Output vector of rotation vectors (see Rodrigues ) estimated for each board view (e.g. std::vector&lt;cv::Mat&gt;). That is, each k-th rotation vector together with the corresponding k-th translation vector (see the next output parameter description) brings the board pattern from the model coordinate space (in which object points are specified) to the world coordinate space, that is, a real position of the board pattern in the k-th pattern view (k=0.. M -1).</param>
 /// <param name="tvecs">Output vector of translation vectors estimated for each pattern view.</param>
 /// <param name="stdDeviationsIntrinsics">Output vector of standard deviations estimated for intrinsic parameters. Order of deviations values: (fx,fy,cx,cy,k1,k2,p1,p2,k3,k4,k5,k6,s1,s2,s3,s4,τx,τy) If one of parameters is not estimated, it's deviation is equals to zero.</param>
 /// <param name="stdDeviationsExtrinsics">Output vector of standard deviations estimated for extrinsic parameters. Order of deviations values: (R1,T1,…,RM,TM) where M is number of pattern views, Ri,Ti are concatenated 1x3 vectors.</param>
 /// <param name="perViewErrors">Output vector of average re-projection errors estimated for each pattern view.</param>
 /// <param name="flags">Flags Different flags for the calibration process</param>
 /// <param name="criteria">Termination criteria for the iterative optimization algorithm.</param>
 /// <returns>The final re-projection error.</returns>
 public static double CalibrateCameraCharuco(
     IInputArrayOfArrays charucoCorners,
     IInputArrayOfArrays charucoIds,
     CharucoBoard board,
     Size imageSize,
     IInputOutputArray cameraMatrix,
     IInputOutputArray distCoeffs,
     IOutputArray rvecs,
     IOutputArray tvecs,
     IOutputArray stdDeviationsIntrinsics,
     IOutputArray stdDeviationsExtrinsics,
     IOutputArray perViewErrors,
     CalibType flags,
     MCvTermCriteria criteria)
 {
     using (InputArray iaCharucoCorners = charucoCorners.GetInputArray())
         using (InputArray iaCharucoIds = charucoIds.GetInputArray())
             using (InputOutputArray ioaCameraMatrix = cameraMatrix.GetInputOutputArray())
                 using (InputOutputArray ioaDistCoeffs = distCoeffs.GetInputOutputArray())
                     using (OutputArray oaRvecs = rvecs == null ? OutputArray.GetEmpty() : rvecs.GetOutputArray())
                         using (OutputArray oaTvecs = tvecs == null ? OutputArray.GetEmpty() : tvecs.GetOutputArray())
                             using (OutputArray oaStdDeviationsIntrinsics = stdDeviationsIntrinsics == null ? OutputArray.GetEmpty() : stdDeviationsIntrinsics.GetOutputArray())
                                 using (OutputArray oaStdDeviationsExtrinsics = stdDeviationsExtrinsics == null ? OutputArray.GetEmpty() : stdDeviationsExtrinsics.GetOutputArray())
                                     using (OutputArray oaPerViewErrors = perViewErrors == null ? OutputArray.GetEmpty() : perViewErrors.GetOutputArray())
                                     {
                                         return(cveArucoCalibrateCameraCharuco(
                                                    iaCharucoCorners, iaCharucoIds, board.BoardPtr, ref imageSize,
                                                    ioaCameraMatrix, ioaDistCoeffs, oaRvecs, oaTvecs,
                                                    oaStdDeviationsIntrinsics, oaStdDeviationsExtrinsics, oaPerViewErrors,
                                                    flags, ref criteria));
                                     }
 }
コード例 #3
0
ファイル: ArucoInvoke.cs プロジェクト: ys20161205/emgucv
 /// <summary>
 /// Interpolate position of ChArUco board corners
 /// </summary>
 /// <param name="markerCorners">vector of already detected markers corners. For each marker, its four corners are provided, (e.g VectorOfVectorOfPointF ). For N detected markers, the dimensions of this array should be Nx4.The order of the corners should be clockwise.</param>
 /// <param name="markerIds">list of identifiers for each marker in corners</param>
 /// <param name="image">input image necesary for corner refinement. Note that markers are not detected and should be sent in corners and ids parameters.</param>
 /// <param name="board">layout of ChArUco board.</param>
 /// <param name="charucoCorners">interpolated chessboard corners</param>
 /// <param name="charucoIds">interpolated chessboard corners identifiers</param>
 /// <param name="cameraMatrix">optional 3x3 floating-point camera matrix</param>
 /// <param name="distCoeffs">optional vector of distortion coefficients, (k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]]) of 4, 5, 8 or 12 elements </param>
 /// <param name="minMarkers">number of adjacent markers that must be detected to return a charuco corner</param>
 /// <returns>The number of interpolated corners.</returns>
 public static int InterpolateCornersCharuco(
     IInputArrayOfArrays markerCorners,
     IInputArray markerIds,
     IInputArray image,
     CharucoBoard board,
     IOutputArray charucoCorners,
     IOutputArray charucoIds,
     IInputArray cameraMatrix = null,
     IInputArray distCoeffs   = null,
     int minMarkers           = 2)
 {
     using (InputArray iaMarkerCorners = markerCorners.GetInputArray())
         using (InputArray iaMarkerIds = markerIds.GetInputArray())
             using (InputArray iaImage = image.GetInputArray())
                 using (OutputArray oaCharucoCorners = charucoCorners.GetOutputArray())
                     using (OutputArray oaCharucoIds = charucoIds.GetOutputArray())
                         using (InputArray iaCameraMatrix = cameraMatrix == null ? InputArray.GetEmpty() : cameraMatrix.GetInputArray())
                             using (InputArray iaDistCoeffs = distCoeffs == null ? InputArray.GetEmpty() : distCoeffs.GetInputArray())
                             {
                                 return(cveArucoInterpolateCornersCharuco(
                                            iaMarkerCorners, iaMarkerIds, iaImage, board,
                                            oaCharucoCorners, oaCharucoIds,
                                            iaCameraMatrix, iaDistCoeffs,
                                            minMarkers));
                             }
 }
コード例 #4
0
ファイル: ArucoInvoke.cs プロジェクト: ys20161205/emgucv
 /// <summary>
 /// Calibrate a camera using Charuco corners.
 /// </summary>
 /// <param name="charucoCorners">Vector of detected charuco corners per frame</param>
 /// <param name="charucoIds">List of identifiers for each corner in charucoCorners per frame</param>
 /// <param name="board">Marker Board layout</param>
 /// <param name="imageSize">Size of the image used only to initialize the intrinsic camera matrix.</param>
 /// <param name="cameraMatrix">Output 3x3 floating-point camera matrix. </param>
 /// <param name="distCoeffs">Output vector of distortion coefficients (k1,k2,p1,p2[,k3[,k4,k5,k6],[s1,s2,s3,s4]]) of 4, 5, 8 or 12 elements</param>
 /// <param name="rvecs">Output vector of rotation vectors (see Rodrigues ) estimated for each board view (e.g. std::vector&lt;cv::Mat&gt;). That is, each k-th rotation vector together with the corresponding k-th translation vector (see the next output parameter description) brings the board pattern from the model coordinate space (in which object points are specified) to the world coordinate space, that is, a real position of the board pattern in the k-th pattern view (k=0.. M -1).</param>
 /// <param name="tvecs">Output vector of translation vectors estimated for each pattern view.</param>
 /// <param name="flags">Flags Different flags for the calibration process</param>
 /// <param name="criteria">Termination criteria for the iterative optimization algorithm.</param>
 /// <returns>The final re-projection error.</returns>
 public static double CalibrateCameraCharuco(
     IInputArrayOfArrays charucoCorners,
     IInputArrayOfArrays charucoIds,
     CharucoBoard board,
     Size imageSize,
     IInputOutputArray cameraMatrix,
     IInputOutputArray distCoeffs,
     IOutputArray rvecs,
     IOutputArray tvecs,
     CalibType flags,
     MCvTermCriteria criteria)
 {
     return(CalibrateCameraCharuco(charucoCorners, charucoIds, board, imageSize, cameraMatrix, distCoeffs,
                                   rvecs, tvecs, null, null, null, flags, criteria));
 }