コード例 #1
0
ファイル: QRCodeDetector.cs プロジェクト: ersinkecis/EmguCV
 /// <summary>
 /// Decodes QR code in image once it's found by the detect() method.
 /// </summary>
 /// <param name="image">grayscale or color (BGR) image containing QR code.</param>
 /// <param name="points">Quadrangle vertices found by detect() method (or some other algorithm).</param>
 /// <param name="straightQrcode">The optional output image containing rectified and binarized QR code</param>
 /// <returns>UTF8-encoded output string or empty string if the code cannot be decoded.</returns>
 public String Decode(IInputArray image, IInputArray points, IOutputArray straightQrcode = null)
 {
     using (InputArray iaImage = image.GetInputArray())
         using (InputArray iaPoints = points.GetInputArray())
             using (OutputArray oaStraightQrcode = straightQrcode == null ? OutputArray.GetEmpty() : straightQrcode.GetOutputArray())
                 using (CvString decodedInfo = new CvString())
                 {
                     CvInvoke.cveQRCodeDetectorDecode(_ptr, iaImage, iaPoints, decodedInfo, oaStraightQrcode);
                     return(decodedInfo.ToString());
                 }
 }
コード例 #2
0
 /// <summary>
 /// Read point cloud from file
 /// </summary>
 /// <param name="file">The point cloud file</param>
 /// <param name="colors">The color of the points</param>
 /// <param name="normals">The normal of the points</param>
 /// <returns>The points</returns>
 public static Mat ReadCloud(String file, IOutputArray colors = null, IOutputArray normals = null)
 {
     using (CvString cs = new CvString(file))
         using (OutputArray oaColors = colors == null ? OutputArray.GetEmpty() : colors.GetOutputArray())
             using (OutputArray oaNormals = normals == null ? OutputArray.GetEmpty() : normals.GetOutputArray())
             {
                 Mat cloud = new Mat();
                 cveReadCloud(cs, cloud, oaColors, oaNormals);
                 return(cloud);
             }
 }
コード例 #3
0
 /// <summary>
 /// Decodes QR codes in image once it's found by the detect() method.
 /// </summary>
 /// <param name="img">Grayscale or color (BGR) image containing QR codes.</param>
 /// <param name="points">Vector of Quadrangle vertices found by detect() method (or some other algorithm).</param>
 /// <param name="decodedInfo">UTF8-encoded output vector of string or empty vector of string if the codes cannot be decoded.</param>
 /// <param name="straightQrcode">The optional output vector of images containing rectified and binarized QR codes</param>
 /// <returns>True if decoding is successful.</returns>
 public bool DecodeMulti(
     IInputArray img,
     IInputArray points,
     VectorOfCvString decodedInfo,
     IOutputArray straightQrcode = null)
 {
     using (InputArray iaImg = img.GetInputArray())
         using (InputArray iaPoints = points.GetInputArray())
             using (OutputArray oaStraightQrcode =
                        (straightQrcode == null ? OutputArray.GetEmpty() : straightQrcode.GetOutputArray()))
             {
                 return(CvInvoke.cveQRCodeDetectorDecodeMulti(_ptr, iaImg, iaPoints, decodedInfo, oaStraightQrcode));
             }
 }
コード例 #4
0
 /// <summary>
 /// Both detects and decodes barcode
 /// </summary>
 /// <param name="image">grayscale or color (BGR) image containing barcode.</param>
 /// <param name="decodedInfo">UTF8-encoded output vector of string(s) or empty vector of string if the codes cannot be decoded.</param>
 /// <param name="decodedType">vector of BarcodeType, specifies the type of these barcodes</param>
 /// <param name="points">Optional output vector of vertices of the found  barcode rectangle. Will be empty if not found.</param>
 /// <returns>True if barcode is detected and decoded.</returns>
 public bool DetectAndDecode(
     IInputArray image,
     VectorOfCvString decodedInfo,
     VectorOfInt decodedType,
     IOutputArray points = null)
 {
     using (InputArray iaImage = image.GetInputArray())
         using (OutputArray oaPoints = points == null ? OutputArray.GetEmpty() : points.GetOutputArray())
             return(BarcodeInvoke.cveBarcodeDetectorDetectAndDecode(
                        _ptr,
                        iaImage,
                        decodedInfo,
                        decodedType,
                        oaPoints));
 }
コード例 #5
0
ファイル: WeChatQRCode.cs プロジェクト: zanker99/emgucv
 /// <summary>
 /// Both detects and decodes QR code.
 /// </summary>
 /// <param name="img">Supports grayscale or color (BGR) image</param>
 /// <param name="points">Optional output array of vertices of the found QR code quadrangle. Will be empty if not found.</param>
 /// <returns>The array of decoded string.</returns>
 public String[] DetectAndDecode(
     IInputArray img,
     IOutputArrayOfArrays points)
 {
     using (InputArray iaImg = img.GetInputArray())
         using (OutputArray oaPoints = points == null? OutputArray.GetEmpty() : points.GetOutputArray())
             using (VectorOfCvString result = new VectorOfCvString())
             {
                 WeChatQRCodeInvoke.cveWeChatQRCodeDetectAndDecode(
                     _ptr,
                     iaImg,
                     oaPoints,
                     result);
                 return(result.ToArray());
             }
 }
コード例 #6
0
ファイル: Calib3dInvoke.cs プロジェクト: zy850580380/emgucv
        public static Mat EstimateAffine2D(
            IInputArray from, IInputArray to,
            IOutputArray inliners = null,
            CvEnum.RobustEstimationAlgorithm method = CvEnum.RobustEstimationAlgorithm.Ransac, double ransacReprojThreshold = 3,
            int maxIters    = 2000, double confidence = 0.99,
            int refineIters = 10)
        {
            Mat affine = new Mat();

            using (InputArray iaFrom = from.GetInputArray())
                using (InputArray iaTo = to.GetInputArray())
                    using (OutputArray oaInliners = inliners == null ? OutputArray.GetEmpty() : inliners.GetOutputArray())
                    {
                        cveEstimateAffine2D(iaFrom, iaTo, oaInliners, method, ransacReprojThreshold, maxIters, confidence, refineIters, affine);
                    }
            return(affine);
        }
コード例 #7
0
ファイル: SparseOpticalFlow.cs プロジェクト: wtf3505/emgucv
 /// <summary>
 /// Calculates a sparse optical flow.
 /// </summary>
 /// <param name="opticalFlow">The sparse optical flow</param>
 /// <param name="prevImg">First input image.</param>
 /// <param name="nextImg">Second input image of the same size and the same type as prevImg.</param>
 /// <param name="prevPts">Vector of 2D points for which the flow needs to be found.</param>
 /// <param name="nextPts">Output vector of 2D points containing the calculated new positions of input features in the second image.</param>
 /// <param name="status">Output status vector. Each element of the vector is set to 1 if the flow for the corresponding features has been found.Otherwise, it is set to 0.</param>
 /// <param name="error">Optional output vector that contains error response for each point (inverse confidence).</param>
 public static void Calc(
     this ISparseOpticalFlow opticalFlow,
     IInputArray prevImg, IInputArray nextImg,
     IInputArray prevPts, IInputOutputArray nextPts,
     IOutputArray status,
     IOutputArray error = null
     )
 {
     using (InputArray iaPreImg = prevImg.GetInputArray())
         using (InputArray iaNextImg = nextImg.GetInputArray())
             using (InputArray iaPrevPts = prevPts.GetInputArray())
                 using (InputOutputArray ioaNextPts = nextPts.GetInputOutputArray())
                     using (OutputArray oaStatus = status.GetOutputArray())
                         using (OutputArray oaError = error == null ? OutputArray.GetEmpty() : error.GetOutputArray())
                             CvInvoke.cveSparseOpticalFlowCalc(
                                 opticalFlow.SparseOpticalFlowPtr,
                                 iaPreImg, iaNextImg,
                                 iaPrevPts, ioaNextPts,
                                 oaStatus, oaError
                                 );
 }
コード例 #8
0
 /// <summary>
 /// Decomposes a projection matrix into a rotation matrix and a camera intrinsic matrix.
 /// </summary>
 /// <param name="projMatrix">3x4 input projection matrix P.</param>
 /// <param name="cameraMatrix">Output 3x3 camera intrinsic matrix A</param>
 /// <param name="rotMatrix">Output 3x3 external rotation matrix R.</param>
 /// <param name="transVect">Output 4x1 translation vector T.</param>
 /// <param name="rotMatrixX">Optional 3x3 rotation matrix around x-axis.</param>
 /// <param name="rotMatrixY">Optional 3x3 rotation matrix around y-axis.</param>
 /// <param name="rotMatrixZ">Optional 3x3 rotation matrix around z-axis.</param>
 /// <param name="eulerAngles">Optional three-element vector containing three Euler angles of rotation in degrees.</param>
 public static void DecomposeProjectionMatrix(
     IInputArray projMatrix,
     IOutputArray cameraMatrix,
     IOutputArray rotMatrix,
     IOutputArray transVect,
     IOutputArray rotMatrixX  = null,
     IOutputArray rotMatrixY  = null,
     IOutputArray rotMatrixZ  = null,
     IOutputArray eulerAngles = null)
 {
     using (InputArray iaProjMatrix = projMatrix.GetInputArray())
         using (OutputArray oaCameraMatrix = cameraMatrix.GetOutputArray())
             using (OutputArray oaRotMatrix = rotMatrix.GetOutputArray())
                 using (OutputArray oaTransVect = transVect.GetOutputArray())
                     using (OutputArray oaRotMatrixX = rotMatrixX == null ? OutputArray.GetEmpty() : rotMatrixX.GetOutputArray())
                         using (OutputArray oaRotMatrixY = rotMatrixY == null ? OutputArray.GetEmpty() : rotMatrixY.GetOutputArray())
                             using (OutputArray oaRotMatrixZ = rotMatrixZ == null ? OutputArray.GetEmpty() : rotMatrixZ.GetOutputArray())
                                 using (OutputArray oaEulerAngles = eulerAngles == null
         ? OutputArray.GetEmpty()
         : eulerAngles.GetOutputArray())
                                 {
                                     cveDecomposeProjectionMatrix(
                                         iaProjMatrix,
                                         oaCameraMatrix,
                                         oaRotMatrix,
                                         oaTransVect,
                                         oaRotMatrixX,
                                         oaRotMatrixY,
                                         oaRotMatrixZ,
                                         oaEulerAngles);
                                 }
 }
コード例 #9
0
ファイル: Fisheye.cs プロジェクト: zanker99/emgucv
 /// <summary>
 /// Projects points using fisheye model. The function computes projections of 3D points to the image plane given intrinsic and extrinsic camera parameters. Optionally, the function computes Jacobians - matrices of partial derivatives of image points coordinates (as functions of all the input parameters) with respect to the particular parameters, intrinsic and/or extrinsic.
 /// </summary>
 /// <param name="objectPoints">Array of object points, 1xN/Nx1 3-channel (or vector&lt;Point3f&gt; ), where N is the number of points in the view.</param>
 /// <param name="imagePoints">Output array of image points, 2xN/Nx2 1-channel or 1xN/Nx1 2-channel, or vector&lt;Point2f&gt;.</param>
 /// <param name="rvec">rotation vector</param>
 /// <param name="tvec">translation vector</param>
 /// <param name="K">Camera matrix</param>
 /// <param name="D">Input vector of distortion coefficients (k1,k2,k3,k4).</param>
 /// <param name="alpha">The skew coefficient.</param>
 /// <param name="jacobian">Optional output 2Nx15 jacobian matrix of derivatives of image points with respect to components of the focal lengths, coordinates of the principal point, distortion coefficients, rotation vector, translation vector, and the skew. In the old interface different components of the jacobian are returned via different output parameters.</param>
 public static void ProjectPoints(
     IInputArray objectPoints,
     IOutputArray imagePoints,
     IInputArray rvec,
     IInputArray tvec,
     IInputArray K,
     IInputArray D,
     double alpha          = 0,
     IOutputArray jacobian = null)
 {
     using (InputArray iaObjectPoints = objectPoints.GetInputArray())
         using (OutputArray oaImagePoints = imagePoints.GetOutputArray())
             using (InputArray iaRvec = rvec.GetInputArray())
                 using (InputArray iaTvec = tvec.GetInputArray())
                     using (InputArray iaK = K.GetInputArray())
                         using (InputArray iaD = D.GetInputArray())
                             using (OutputArray oaJacobian = jacobian == null ? OutputArray.GetEmpty() : jacobian.GetOutputArray())
                             {
                                 CvInvoke.cveFisheyeProjectPoints(iaObjectPoints, oaImagePoints, iaRvec, iaTvec, iaK, iaD, alpha, oaJacobian);
                             }
 }