本文整理汇总了C#中OutputArray.ThrowIfDisposed方法的典型用法代码示例。如果您正苦于以下问题:C# OutputArray.ThrowIfDisposed方法的具体用法?C# OutputArray.ThrowIfDisposed怎么用?C# OutputArray.ThrowIfDisposed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OutputArray
的用法示例。
在下文中一共展示了OutputArray.ThrowIfDisposed方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SolvePnPRansac
/// <summary>
/// computes the camera pose from a few 3D points and the corresponding projections. The outliers are possible.
/// </summary>
/// <param name="objectPoints">Array of object points in the object coordinate space, 3xN/Nx3 1-channel or 1xN/Nx1 3-channel,
/// where N is the number of points. List<Point3f> can be also passed here.</param>
/// <param name="imagePoints">Array of corresponding image points, 2xN/Nx2 1-channel or 1xN/Nx1 2-channel, where N is the number of points.
/// List<Point2f> can be also passed here.</param>
/// <param name="cameraMatrix">Input 3x3 camera matrix</param>
/// <param name="distCoeffs">Input vector of distortion coefficients (k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6]]) of 4, 5, or 8 elements.
/// If the vector is null, the zero distortion coefficients are assumed.</param>
/// <param name="rvec">Output rotation vector that, together with tvec , brings points from the model coordinate system
/// to the camera coordinate system.</param>
/// <param name="tvec">Output translation vector.</param>
/// <param name="useExtrinsicGuess">If true, the function uses the provided rvec and tvec values as initial approximations
/// of the rotation and translation vectors, respectively, and further optimizes them.</param>
/// <param name="iterationsCount">Number of iterations.</param>
/// <param name="reprojectionError">Inlier threshold value used by the RANSAC procedure.
/// The parameter value is the maximum allowed distance between the observed and computed point projections to consider it an inlier.</param>
/// <param name="minInliersCount">Number of inliers. If the algorithm at some stage finds more inliers than minInliersCount , it finishes.</param>
/// <param name="inliers">Output vector that contains indices of inliers in objectPoints and imagePoints .</param>
/// <param name="flags">Method for solving a PnP problem</param>
public static void SolvePnPRansac(
InputArray objectPoints,
InputArray imagePoints,
InputArray cameraMatrix,
InputArray distCoeffs,
OutputArray rvec,
OutputArray tvec,
bool useExtrinsicGuess = false,
int iterationsCount = 100,
float reprojectionError = 8.0f,
int minInliersCount = 100,
OutputArray inliers = null,
SolvePnPFlag flags = SolvePnPFlag.Iterative)
{
if (objectPoints == null)
throw new ArgumentNullException("objectPoints");
if (imagePoints == null)
throw new ArgumentNullException("imagePoints");
if (cameraMatrix == null)
throw new ArgumentNullException("cameraMatrix");
if (rvec == null)
throw new ArgumentNullException("rvec");
if (tvec == null)
throw new ArgumentNullException("tvec");
objectPoints.ThrowIfDisposed();
imagePoints.ThrowIfDisposed();
cameraMatrix.ThrowIfDisposed();
distCoeffs.ThrowIfDisposed();
rvec.ThrowIfDisposed();
tvec.ThrowIfDisposed();
IntPtr distCoeffsPtr = ToPtr(distCoeffs);
NativeMethods.calib3d_solvePnPRansac_InputArray(
objectPoints.CvPtr, imagePoints.CvPtr, cameraMatrix.CvPtr, distCoeffsPtr,
rvec.CvPtr, tvec.CvPtr, useExtrinsicGuess ? 1 : 0, iterationsCount,
reprojectionError, minInliersCount, ToPtr(inliers), (int)flags);
rvec.Fix();
tvec.Fix();
if(inliers != null)
inliers.Fix();
}
示例2: SolvePnP
/// <summary>
/// Finds an object pose from 3D-2D point correspondences.
/// </summary>
/// <param name="objectPoints"> Array of object points in the object coordinate space, 3xN/Nx3 1-channel or 1xN/Nx1 3-channel,
/// where N is the number of points. vector<Point3f> can be also passed here.</param>
/// <param name="imagePoints">Array of corresponding image points, 2xN/Nx2 1-channel or 1xN/Nx1 2-channel,
/// where N is the number of points. vector<Point2f> can be also passed here.</param>
/// <param name="cameraMatrix">Input camera matrix</param>
/// <param name="distCoeffs">Input vector of distortion coefficients (k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6]]) of 4, 5, or 8 elements.
/// If the vector is null, the zero distortion coefficients are assumed.</param>
/// <param name="rvec">Output rotation vector that, together with tvec , brings points from the model coordinate system to the
/// camera coordinate system.</param>
/// <param name="tvec">Output translation vector.</param>
/// <param name="useExtrinsicGuess">If true, the function uses the provided rvec and tvec values as initial approximations of
/// the rotation and translation vectors, respectively, and further optimizes them.</param>
/// <param name="flags">Method for solving a PnP problem:</param>
public static void SolvePnP(
InputArray objectPoints,
InputArray imagePoints,
InputArray cameraMatrix,
InputArray distCoeffs,
OutputArray rvec, OutputArray tvec,
bool useExtrinsicGuess = false,
SolvePnPFlag flags = SolvePnPFlag.Iterative)
{
if (objectPoints == null)
throw new ArgumentNullException("objectPoints");
if (imagePoints == null)
throw new ArgumentNullException("imagePoints");
if (cameraMatrix == null)
throw new ArgumentNullException("cameraMatrix");
if (rvec == null)
throw new ArgumentNullException("rvec");
if (tvec == null)
throw new ArgumentNullException("tvec");
objectPoints.ThrowIfDisposed();
imagePoints.ThrowIfDisposed();
cameraMatrix.ThrowIfDisposed();
distCoeffs.ThrowIfDisposed();
rvec.ThrowIfDisposed();
tvec.ThrowIfDisposed();
IntPtr distCoeffsPtr = ToPtr(distCoeffs);
NativeMethods.calib3d_solvePnP_InputArray(
objectPoints.CvPtr, imagePoints.CvPtr, cameraMatrix.CvPtr, distCoeffsPtr,
rvec.CvPtr, tvec.CvPtr, useExtrinsicGuess ? 1 : 0, (int)flags);
rvec.Fix();
tvec.Fix();
}
示例3: ConvertMaps
/// <summary>
///
/// </summary>
/// <param name="map1"></param>
/// <param name="map2"></param>
/// <param name="dstmap1"></param>
/// <param name="dstmap2"></param>
/// <param name="dstmap1Type"></param>
/// <param name="nnInterpolation"></param>
public static void ConvertMaps(InputArray map1, InputArray map2, OutputArray dstmap1, OutputArray dstmap2, MatType dstmap1Type, bool nnInterpolation = false)
{
if (map1 == null)
throw new ArgumentNullException("map1");
if (map2 == null)
throw new ArgumentNullException("map2");
if (dstmap1 == null)
throw new ArgumentNullException("dstmap1");
if (dstmap2 == null)
throw new ArgumentNullException("dstmap2");
map1.ThrowIfDisposed();
map2.ThrowIfDisposed();
dstmap1.ThrowIfDisposed();
dstmap2.ThrowIfDisposed();
NativeMethods.imgproc_convertMaps(map1.CvPtr, map2.CvPtr, dstmap1.CvPtr, dstmap2.CvPtr, dstmap1Type, nnInterpolation ? 1 : 0);
dstmap1.Fix();
dstmap2.Fix();
}
示例4: WarpPerspective
/// <summary>
/// 画像の透視変換を行います.
/// </summary>
/// <param name="src">入力画像</param>
/// <param name="dst">サイズが dsize で src と同じタイプの出力画像</param>
/// <param name="m">3x3 の変換行列</param>
/// <param name="dsize">出力画像のサイズ</param>
/// <param name="flags">補間手法</param>
/// <param name="borderMode">ピクセル外挿手法.
/// borderMode=BORDER_TRANSPARENT の場合,入力画像中の「はずれ値」に対応する
/// 出力画像中のピクセルが,この関数では変更されないことを意味します</param>
/// <param name="borderValue">定数境界モードで利用されるピクセル値.</param>
#else
/// <summary>
/// Applies a perspective transformation to an image.
/// </summary>
/// <param name="src">input image.</param>
/// <param name="dst">output image that has the size dsize and the same type as src.</param>
/// <param name="m">3x3 transformation matrix.</param>
/// <param name="dsize">size of the output image.</param>
/// <param name="flags">combination of interpolation methods (INTER_LINEAR or INTER_NEAREST)
/// and the optional flag WARP_INVERSE_MAP, that sets M as the inverse transformation (dst -> src).</param>
/// <param name="borderMode">pixel extrapolation method (BORDER_CONSTANT or BORDER_REPLICATE).</param>
/// <param name="borderValue">value used in case of a constant border; by default, it equals 0.</param>
#endif
public static void WarpPerspective(InputArray src, OutputArray dst, float[,] m, Size dsize,
Interpolation flags = Interpolation.Linear, BorderType borderMode = BorderType.Constant,
Scalar? borderValue = null)
{
if (src == null)
throw new ArgumentNullException("src");
if (dst == null)
throw new ArgumentNullException("dst");
if (m == null)
throw new ArgumentNullException("m");
src.ThrowIfDisposed();
dst.ThrowIfDisposed();
CvScalar borderValue0 = borderValue.GetValueOrDefault(CvScalar.ScalarAll(0));
int mRow = m.GetLength(0);
int mCol = m.GetLength(1);
NativeMethods.imgproc_warpPerspective_MisArray(
src.CvPtr, dst.CvPtr, m, mRow, mCol, dsize, (int)flags, (int)borderMode, borderValue0);
dst.Fix();
}
示例5: WarpAffine
/// <summary>
/// Applies an affine transformation to an image.
/// </summary>
/// <param name="src">input image.</param>
/// <param name="dst">output image that has the size dsize and the same type as src.</param>
/// <param name="m">2x3 transformation matrix.</param>
/// <param name="dsize">size of the output image.</param>
/// <param name="flags">combination of interpolation methods and the optional flag
/// WARP_INVERSE_MAP that means that M is the inverse transformation (dst -> src) .</param>
/// <param name="borderMode">pixel extrapolation method; when borderMode=BORDER_TRANSPARENT,
/// it means that the pixels in the destination image corresponding to the "outliers"
/// in the source image are not modified by the function.</param>
/// <param name="borderValue">value used in case of a constant border; by default, it is 0.</param>
public static void WarpAffine(InputArray src, OutputArray dst, InputArray m, Size dsize,
Interpolation flags = Interpolation.Linear, BorderType borderMode = BorderType.Constant, Scalar? borderValue = null)
{
if (src == null)
throw new ArgumentNullException("src");
if (dst == null)
throw new ArgumentNullException("dst");
if (m == null)
throw new ArgumentNullException("m");
src.ThrowIfDisposed();
dst.ThrowIfDisposed();
m.ThrowIfDisposed();
CvScalar borderValue0 = borderValue.GetValueOrDefault(CvScalar.ScalarAll(0));
NativeMethods.imgproc_warpAffine(src.CvPtr, dst.CvPtr, m.CvPtr, dsize, (int)flags, (int)borderMode, borderValue0);
dst.Fix();
}
示例6: WarpPerspective
/// <summary>
/// 画像の透視変換を行います.
/// </summary>
/// <param name="src">入力画像</param>
/// <param name="dst">サイズが dsize で src と同じタイプの出力画像</param>
/// <param name="m">3x3 の変換行列</param>
/// <param name="dsize">出力画像のサイズ</param>
/// <param name="flags">補間手法</param>
/// <param name="borderMode">ピクセル外挿手法.
/// borderMode=BORDER_TRANSPARENT の場合,入力画像中の「はずれ値」に対応する
/// 出力画像中のピクセルが,この関数では変更されないことを意味します</param>
/// <param name="borderValue">定数境界モードで利用されるピクセル値.</param>
#else
/// <summary>
/// Applies a perspective transformation to an image.
/// </summary>
/// <param name="src">input image.</param>
/// <param name="dst">output image that has the size dsize and the same type as src.</param>
/// <param name="m">3x3 transformation matrix.</param>
/// <param name="dsize">size of the output image.</param>
/// <param name="flags">combination of interpolation methods (INTER_LINEAR or INTER_NEAREST)
/// and the optional flag WARP_INVERSE_MAP, that sets M as the inverse transformation (dst -> src).</param>
/// <param name="borderMode">pixel extrapolation method (BORDER_CONSTANT or BORDER_REPLICATE).</param>
/// <param name="borderValue">value used in case of a constant border; by default, it equals 0.</param>
#endif
public static void WarpPerspective(
InputArray src, OutputArray dst, InputArray m, Size dsize,
InterpolationFlags flags = InterpolationFlags.Linear,
BorderTypes borderMode = BorderTypes.Constant,
Scalar? borderValue = null)
{
if (src == null)
throw new ArgumentNullException(nameof(src));
if (dst == null)
throw new ArgumentNullException(nameof(dst));
if (m == null)
throw new ArgumentNullException(nameof(m));
src.ThrowIfDisposed();
dst.ThrowIfDisposed();
m.ThrowIfDisposed();
Scalar borderValue0 = borderValue.GetValueOrDefault(Scalar.All(0));
NativeMethods.imgproc_warpPerspective_MisInputArray(
src.CvPtr, dst.CvPtr, m.CvPtr, dsize, (int)flags, (int)borderMode, borderValue0);
GC.KeepAlive(src);
dst.Fix();
}