/// <summary>
        /// Find one best match for each query descriptor (if mask is empty).
        /// </summary>
        /// <param name="queryDescriptors"></param>
        /// <param name="masks"></param>
        /// <returns></returns>
        public DMatch[] Match(Mat queryDescriptors, Mat[] masks = null)
        {
            ThrowIfDisposed();
            if (queryDescriptors == null)
            {
                throw new ArgumentNullException(nameof(queryDescriptors));
            }

            var masksPtrs = new IntPtr[0];

            if (masks != null)
            {
                masksPtrs = EnumerableEx.SelectPtrs(masks);
            }

            using (var matchesVec = new VectorOfDMatch())
            {
                NativeMethods.features2d_DescriptorMatcher_match2(
                    ptr, queryDescriptors.CvPtr, matchesVec.CvPtr, masksPtrs, masksPtrs.Length);
                GC.KeepAlive(this);
                GC.KeepAlive(queryDescriptors);
                GC.KeepAlive(masks);
                return(matchesVec.ToArray());
            }
        }
Пример #2
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public DMatch[] ReadDMatches()
 {
     using (var valueVector = new VectorOfDMatch())
     {
         NativeMethods.core_FileNode_read_vectorOfDMatch(ptr, valueVector.CvPtr);
         return(valueVector.ToArray());
     }
 }
Пример #3
0
 /// <summary>
 /// Reads the node element as DMatch[]
 /// </summary>
 /// <returns></returns>
 public DMatch[] ReadDMatches()
 {
     using var valueVector = new VectorOfDMatch();
     NativeMethods.HandleException(
         NativeMethods.core_FileNode_read_vectorOfDMatch(ptr, valueVector.CvPtr));
     GC.KeepAlive(this);
     return(valueVector.ToArray());
 }
Пример #4
0
 /// <summary>
 /// Writes data to a file storage.
 /// </summary>
 /// <param name="val"></param>
 public FileStorage Add(IEnumerable <DMatch> val)
 {
     if (val == null)
     {
         throw new ArgumentNullException(nameof(val));
     }
     ThrowIfDisposed();
     using (var valVec = new VectorOfDMatch(val))
     {
         NativeMethods.core_FileStorage_shift_vectorOfDMatch(ptr, valVec.CvPtr);
     }
     GC.KeepAlive(this);
     return(this);
 }
Пример #5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="name"></param>
 /// <param name="value"></param>
 public void Write(string name, IEnumerable <DMatch> value)
 {
     if (name == null)
     {
         throw new ArgumentNullException(nameof(name));
     }
     if (value == null)
     {
         throw new ArgumentNullException(nameof(value));
     }
     using (var valueVector = new VectorOfDMatch(value))
     {
         NativeMethods.core_FileStorage_write_vectorOfDMatch(ptr, name, valueVector.CvPtr);
     }
 }
Пример #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="name"></param>
        /// <param name="value"></param>
        public void Write(string name, IEnumerable <DMatch> value)
        {
            ThrowIfDisposed();
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            using var valueVector = new VectorOfDMatch(value);
            NativeMethods.HandleException(
                NativeMethods.core_FileStorage_write_vectorOfDMatch(ptr, name, valueVector.CvPtr));
            GC.KeepAlive(this);
        }
Пример #7
0
 /// <summary>
 /// Find one best match for each query descriptor (if mask is empty).
 /// </summary>
 /// <param name="queryDescriptors"></param>
 /// <param name="trainDescriptors"></param>
 /// <param name="mask"></param>
 /// <returns></returns>
 public DMatch[] Match(Mat queryDescriptors, Mat trainDescriptors, Mat? mask = null)
 {
     ThrowIfDisposed();
     if (queryDescriptors == null)
         throw new ArgumentNullException(nameof(queryDescriptors));
     if (trainDescriptors == null)
         throw new ArgumentNullException(nameof(trainDescriptors));
     using var matchesVec = new VectorOfDMatch();
     NativeMethods.HandleException(
         NativeMethods.features2d_DescriptorMatcher_match1(
             ptr, queryDescriptors.CvPtr, trainDescriptors.CvPtr,
             matchesVec.CvPtr, Cv2.ToPtr(mask)));
     GC.KeepAlive(this);
     GC.KeepAlive(queryDescriptors);
     GC.KeepAlive(trainDescriptors);
     GC.KeepAlive(mask);
     return matchesVec.ToArray();
 }
 /// <summary>
 /// Find one best match for each query descriptor (if mask is empty).
 /// </summary>
 /// <param name="queryDescriptors"></param>
 /// <param name="trainDescriptors"></param>
 /// <param name="mask"></param>
 /// <returns></returns>
 public DMatch[] Match(Mat queryDescriptors, Mat trainDescriptors, Mat mask = null)
 {
     ThrowIfDisposed();
     if (queryDescriptors == null)
     {
         throw new ArgumentNullException("queryDescriptors");
     }
     if (trainDescriptors == null)
     {
         throw new ArgumentNullException("trainDescriptors");
     }
     using (var matchesVec = new VectorOfDMatch())
     {
         NativeMethods.features2d_DescriptorMatcher_match1(
             ptr, queryDescriptors.CvPtr, trainDescriptors.CvPtr,
             matchesVec.CvPtr, Cv2.ToPtr(mask));
         return(matchesVec.ToArray());
     }
 }
Пример #9
0
        /// <summary>
        /// Find one best match for each query descriptor (if mask is empty).
        /// </summary>
        /// <param name="queryDescriptors"></param>
        /// <param name="masks"></param>
        /// <returns></returns>
        public DMatch[] Match(Mat queryDescriptors, Mat[]? masks = null)
        {
            ThrowIfDisposed();
            if (queryDescriptors == null)
                throw new ArgumentNullException(nameof(queryDescriptors));

            var masksPtrs = new IntPtr[0];
            if (masks != null)
            {
                masksPtrs = masks.Select(x => x.CvPtr).ToArray();
            }

            using var matchesVec = new VectorOfDMatch();
            NativeMethods.HandleException(
                NativeMethods.features2d_DescriptorMatcher_match2(
                    ptr, queryDescriptors.CvPtr, matchesVec.CvPtr, masksPtrs, masksPtrs.Length));
            GC.KeepAlive(this);
            GC.KeepAlive(queryDescriptors);
            GC.KeepAlive(masks);
            return matchesVec.ToArray();
        }