Ejemplo n.º 1
0
 /// <summary>
 /// Find best matches for each query descriptor which have distance less than
 /// maxDistance (in increasing order of distances).
 /// </summary>
 /// <param name="queryDescriptors"></param>
 /// <param name="trainDescriptors"></param>
 /// <param name="maxDistance"></param>
 /// <param name="mask"></param>
 /// <param name="compactResult"></param>
 /// <returns></returns>
 public DMatch[][] RadiusMatch(Mat queryDescriptors, Mat trainDescriptors,
                               float maxDistance, Mat mask = null, bool compactResult = false)
 {
     ThrowIfDisposed();
     if (queryDescriptors == null)
     {
         throw new ArgumentNullException(nameof(queryDescriptors));
     }
     if (trainDescriptors == null)
     {
         throw new ArgumentNullException(nameof(trainDescriptors));
     }
     using (var matchesVec = new VectorOfVectorDMatch())
     {
         NativeMethods.features2d_DescriptorMatcher_radiusMatch1(
             ptr, queryDescriptors.CvPtr, trainDescriptors.CvPtr,
             matchesVec.CvPtr, maxDistance, Cv2.ToPtr(mask), compactResult ? 1 : 0);
         return(matchesVec.ToArray());
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Find k best matches for each query descriptor (in increasing order of distances).
 /// compactResult is used when mask is not empty. If compactResult is false matches
 /// vector will have the same size as queryDescriptors rows. If compactResult is true
 /// matches vector will not contain matches for fully masked out query descriptors.
 /// </summary>
 /// <param name="queryDescriptors"></param>
 /// <param name="trainDescriptors"></param>
 /// <param name="k"></param>
 /// <param name="mask"></param>
 /// <param name="compactResult"></param>
 /// <returns></returns>
 public DMatch[][] KnnMatch(Mat queryDescriptors, Mat trainDescriptors,
                            int k, Mat mask = null, bool compactResult = false)
 {
     ThrowIfDisposed();
     if (queryDescriptors == null)
     {
         throw new ArgumentNullException("queryDescriptors");
     }
     if (trainDescriptors == null)
     {
         throw new ArgumentNullException("trainDescriptors");
     }
     using (VectorOfVectorDMatch matchesVec = new VectorOfVectorDMatch())
     {
         NativeMethods.features2d_DescriptorMatcher_knnMatch(
             ptr, queryDescriptors.CvPtr, trainDescriptors.CvPtr,
             matchesVec.CvPtr, k, Cv2.ToPtr(mask), compactResult ? 1 : 0);
         return(matchesVec.ToArray());
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Find best matches for each query descriptor which have distance less than
        /// maxDistance (in increasing order of distances).
        /// </summary>
        /// <param name="queryDescriptors"></param>
        /// <param name="maxDistance"></param>
        /// <param name="masks"></param>
        /// <param name="compactResult"></param>
        /// <returns></returns>
        public DMatch[][] RadiusMatch(Mat queryDescriptors, float maxDistance, Mat[] masks = null, bool compactResult = false)
        {
            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 VectorOfVectorDMatch())
            {
                NativeMethods.features2d_DescriptorMatcher_radiusMatch2(
                    ptr, queryDescriptors.CvPtr, matchesVec.CvPtr, maxDistance,
                    masksPtrs, masksPtrs.Length, compactResult ? 1 : 0);
                return(matchesVec.ToArray());
            }
        }