/// <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.features2d_DescriptorMatcher_match1( ptr, queryDescriptors.CvPtr, trainDescriptors.CvPtr, matchesVec.CvPtr, Cv2.ToPtr(mask)); return(matchesVec.ToArray()); } }
/// <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); return(matchesVec.ToArray()); } }