Пример #1
0
        /// <summary>
        /// Basic marker detection
        /// </summary>
        /// <param name="image">input image</param>
        /// <param name="dictionary">indicates the type of markers that will be searched</param>
        /// <param name="corners">vector of detected marker corners.
        /// For each marker, its four corners are provided. For N detected markers,
        ///  the dimensions of this array is Nx4.The order of the corners is clockwise.</param>
        /// <param name="ids">vector of identifiers of the detected markers. The identifier is of type int.
        /// For N detected markers, the size of ids is also N. The identifiers have the same order than the markers in the imgPoints array.</param>
        /// <param name="parameters">marker detection parameters</param>
        /// <param name="rejectedImgPoints">contains the imgPoints of those squares whose inner code has not a
        /// correct codification.Useful for debugging purposes.</param>
        public static void DetectMarkers(InputArray image, Dictionary dictionary, out Point2f[][] corners,
                                         out int[] ids, DetectorParameters parameters, out Point2f[][] rejectedImgPoints)
        {
            if (image == null)
            {
                throw new ArgumentNullException(nameof(image));
            }
            if (dictionary.ObjectPtr == null)
            {
                throw new ArgumentException($"{nameof(dictionary)} is disposed", nameof(dictionary));
            }

            using var cornersVec           = new VectorOfVectorPoint2f();
            using var idsVec               = new VectorOfInt32();
            using var rejectedImgPointsVec = new VectorOfVectorPoint2f();

            NativeMethods.HandleException(
                NativeMethods.aruco_detectMarkers(
                    image.CvPtr, dictionary.ObjectPtr.CvPtr, cornersVec.CvPtr, idsVec.CvPtr, ref parameters.Native,
                    rejectedImgPointsVec.CvPtr));

            corners           = cornersVec.ToArray();
            ids               = idsVec.ToArray();
            rejectedImgPoints = rejectedImgPointsVec.ToArray();

            GC.KeepAlive(image);
            GC.KeepAlive(dictionary);
            GC.KeepAlive(parameters);
        }
Пример #2
0
        /// <summary>
        /// Basic marker detection
        /// </summary>
        /// <param name="image">input image</param>
        /// <param name="dictionary">indicates the type of markers that will be searched</param>
        /// <param name="corners">vector of detected marker corners.
        /// For each marker, its four corners are provided. For N detected markers,
        ///  the dimensions of this array is Nx4.The order of the corners is clockwise.</param>
        /// <param name="ids">vector of identifiers of the detected markers. The identifier is of type int.
        /// For N detected markers, the size of ids is also N. The identifiers have the same order than the markers in the imgPoints array.</param>
        /// <param name="parameters">marker detection parameters</param>
        /// <param name="rejectedImgPoints">contains the imgPoints of those squares whose inner code has not a
        /// correct codification.Useful for debugging purposes.</param>
        public static void DetectMarkers(InputArray image, Dictionary dictionary, out Point2f[][] corners, out int[] ids, DetectorParameters parameters, out Point2f[][] rejectedImgPoints)
        {
            if (image == null)
            {
                throw new ArgumentNullException("image");
            }

            using (var cornersVec = new VectorOfVectorPoint2f())
                using (var idsVec = new VectorOfInt32())
                    using (var rejectedImgPointsVec = new VectorOfVectorPoint2f())
                    {
                        NativeMethods.aruco_detectMarkers(image.CvPtr, dictionary.ptrObj.CvPtr, cornersVec.CvPtr, idsVec.CvPtr, parameters.ptrObj.CvPtr, rejectedImgPointsVec.CvPtr);

                        corners           = cornersVec.ToArray();
                        ids               = idsVec.ToArray();
                        rejectedImgPoints = rejectedImgPointsVec.ToArray();
                    }

            GC.KeepAlive(image);
            GC.KeepAlive(dictionary);
        }