OpenCvSharp.Feature2D.DetectAndCompute C# (CSharp) Method

DetectAndCompute() public method

Detects keypoints and computes the descriptors
public DetectAndCompute ( InputArray image, InputArray mask, KeyPoint &keypoints, OutputArray descriptors, bool useProvidedKeypoints = false ) : void
image InputArray
mask InputArray
keypoints KeyPoint
descriptors OutputArray
useProvidedKeypoints bool
return void
        public virtual void DetectAndCompute(
            InputArray image,
            InputArray mask,
            out KeyPoint[] keypoints,
            OutputArray descriptors,
            bool useProvidedKeypoints = false)
        {
            if (disposed)
                throw new ObjectDisposedException(GetType().Name);
            if (image == null)
                throw new ArgumentNullException(nameof(image));
            if (descriptors == null)
                throw new ArgumentNullException(nameof(descriptors));
            image.ThrowIfDisposed();
            if (mask != null)
                mask.ThrowIfDisposed();

            using (var keypointsVec = new VectorOfKeyPoint())
            {
                NativeMethods.features2d_Feature2D_detectAndCompute(
                    ptr, image.CvPtr, Cv2.ToPtr(mask), keypointsVec.CvPtr, descriptors.CvPtr, useProvidedKeypoints ? 1 : 0);
                keypoints = keypointsVec.ToArray();
            }

            GC.KeepAlive(image);
            GC.KeepAlive(mask);
            descriptors.Fix();
        }
    }