/// <summary> /// Add the model descriptors /// </summary> /// <param name="modelDescriptors">The model discriptors</param> public void Add(Matrix <Byte> modelDescriptors) { if (!(_distanceType == DistanceType.Hamming || _distanceType == DistanceType.HammingLUT)) { throw new ArgumentException("Hamming distance type requires model descriptor to be Matrix<Byte>"); } DescriptorMatcherInvoke.CvDescriptorMatcherAdd(_ptr, modelDescriptors); }
/// <summary> /// Add the model descriptors /// </summary> /// <param name="modelDescriptors">The model discriptors</param> public void Add(Matrix <float> modelDescriptors) { if (!(_distanceType == DistanceType.L2F32 || _distanceType == DistanceType.L1F32)) { throw new ArgumentException("L1 / L2 distance type requires model descriptor to be Matrix<float>"); } DescriptorMatcherInvoke.CvDescriptorMatcherAdd(_ptr, modelDescriptors); }
/// <summary> /// Add the model descriptors /// </summary> /// <param name="modelDescriptors">The model descriptors</param> public void Add(IInputArray modelDescriptors) { using (InputArray iaModelDescriptors = modelDescriptors.GetInputArray()) DescriptorMatcherInvoke.CvDescriptorMatcherAdd(_descriptorMatcherPtr, iaModelDescriptors); }
/// <summary> /// Find the k-nearest match /// </summary> /// <param name="queryDescriptor">An n x m matrix of descriptors to be query for nearest neighbours. n is the number of descriptor and m is the size of the descriptor</param> /// <param name="k">Number of nearest neighbors to search for</param> /// <param name="mask">Can be null if not needed. An n x 1 matrix. If 0, the query descriptor in the corresponding row will be ignored.</param> /// <param name="matches">Matches. Each matches[i] is k or less matches for the same query descriptor.</param> public void KnnMatch(IInputArray queryDescriptor, VectorOfVectorOfDMatch matches, int k, IInputArray mask) { using (InputArray iaQueryDesccriptor = queryDescriptor.GetInputArray()) using (InputArray iaMask = mask == null ? InputArray.GetEmpty() : mask.GetInputArray()) DescriptorMatcherInvoke.CvDescriptorMatcherKnnMatch(_descriptorMatcherPtr, iaQueryDesccriptor, matches, k, iaMask); }
/// <summary> /// Find the k-nearest match for DistanceType of Hamming or HammingLUT /// </summary> /// <param name="queryDescriptor">An n x m matrix of descriptors to be query for nearest neighbours. n is the number of descriptor and m is the size of the descriptor</param> /// <param name="trainIdx">The resulting n x <paramref name="k"/> matrix of descriptor index from the training descriptors</param> /// <param name="distance">The resulting n x <paramref name="k"/> matrix of distance value from the training descriptors</param> /// <param name="k">Number of nearest neighbors to search for</param> /// <param name="mask">Can be null if not needed. An n x 1 matrix. If 0, the query descriptor in the corresponding row will be ignored.</param> public void KnnMatch(Matrix <Byte> queryDescriptor, Matrix <int> trainIdx, Matrix <float> distance, int k, Matrix <Byte> mask) { Debug.Assert(_distanceType == DistanceType.Hamming || _distanceType == DistanceType.HammingLUT); DescriptorMatcherInvoke.CvDescriptorMatcherKnnMatch(Ptr, queryDescriptor, trainIdx, distance, k, mask); }