/// <summary> /// Compute the BRISK features on an image /// </summary> /// <param name="image"></param> /// <param name="mask"></param> /// <returns></returns> public KeyPoint[] Run(InputArray image, InputArray mask = null) { ThrowIfDisposed(); if (image == null) { throw new ArgumentNullException(nameof(image)); } image.ThrowIfDisposed(); using (VectorOfKeyPoint keyPointsVec = new VectorOfKeyPoint()) { NativeMethods.features2d_BRISK_run1(ptr, image.CvPtr, Cv2.ToPtr(mask), keyPointsVec.CvPtr); return(keyPointsVec.ToArray()); } }
/// <summary> /// 高速なマルチスケール Hesian 検出器を用いて keypoint を検出します. /// </summary> /// <param name="img"></param> /// <param name="mask"></param> /// <returns></returns> #else /// <summary> /// detects keypoints using fast multi-scale Hessian detector /// </summary> /// <param name="img"></param> /// <param name="mask"></param> /// <returns></returns> #endif public KeyPoint[] Run(InputArray img, Mat mask) { ThrowIfDisposed(); if (img == null) { throw new ArgumentNullException("img"); } img.ThrowIfDisposed(); using (VectorOfKeyPoint keypointsVec = new VectorOfKeyPoint()) { NativeMethods.nonfree_SURF_run1(ptr, img.CvPtr, Cv2.ToPtr(mask), keypointsVec.CvPtr); return(keypointsVec.ToArray()); } }
/// <summary> /// StarDetectorアルゴリズムによりキーポイントを取得する /// </summary> /// <param name="image">8ビット グレースケールの入力画像</param> /// <returns></returns> #else /// <summary> /// Retrieves keypoints using the StarDetector algorithm. /// </summary> /// <param name="image">The input 8-bit grayscale image</param> /// <returns></returns> #endif public KeyPoint[] Run(Mat image) { if (image == null) { throw new ArgumentNullException("image"); } image.ThrowIfDisposed(); IntPtr keypoints; NativeMethods.features2d_StarDetector_detect(ptr, image.CvPtr, out keypoints); using (VectorOfKeyPoint keypointsVec = new VectorOfKeyPoint(keypoints)) { return(keypointsVec.ToArray()); } }
/// <summary> /// Compute the descriptors for a set of keypoints in an image. /// </summary> /// <param name="image">The image.</param> /// <param name="keypoints">The input keypoints. Keypoints for which a descriptor cannot be computed are removed.</param> /// <param name="descriptors">Copmputed descriptors. Row i is the descriptor for keypoint i.</param>param> public virtual void Compute(Mat image, ref KeyPoint[] keypoints, Mat descriptors) { if (image == null) { throw new ArgumentNullException("image"); } if (descriptors == null) { throw new ArgumentNullException("descriptors"); } using (VectorOfKeyPoint keypointsVec = new VectorOfKeyPoint(keypoints)) { NativeMethods.features2d_DescriptorExtractor_compute1( ptr, image.CvPtr, keypointsVec.CvPtr, descriptors.CvPtr); keypoints = keypointsVec.ToArray(); } }
/// <summary> /// keypoint を検出し,その SURF ディスクリプタを計算します.[useProvidedKeypoints = true] /// </summary> /// <param name="img"></param> /// <param name="mask"></param> /// <param name="keypoints"></param> /// <param name="descriptors"></param> /// <param name="useProvidedKeypoints"></param> #else /// <summary> /// detects keypoints and computes the SURF descriptors for them. [useProvidedKeypoints = true] /// </summary> /// <param name="img"></param> /// <param name="mask"></param> /// <param name="keypoints"></param> /// <param name="descriptors"></param> /// <param name="useProvidedKeypoints"></param> #endif public void Run(InputArray img, InputArray mask, out KeyPoint[] keypoints, out float[] descriptors, bool useProvidedKeypoints = false) { ThrowIfDisposed(); if (img == null) { throw new ArgumentNullException("img"); } img.ThrowIfDisposed(); using (VectorOfKeyPoint keypointsVec = new VectorOfKeyPoint()) using (VectorOfFloat descriptorsVec = new VectorOfFloat()) { NativeMethods.nonfree_SURF_run2_vector(ptr, img.CvPtr, Cv2.ToPtr(mask), keypointsVec.CvPtr, descriptorsVec.CvPtr, useProvidedKeypoints ? 1 : 0); keypoints = keypointsVec.ToArray(); descriptors = descriptorsVec.ToArray(); } }
/// <summary> /// /// </summary> /// <param name="gaussPyr"></param> /// <param name="dogPyr"></param> /// <returns></returns> public KeyPoint[] FindScaleSpaceExtrema(IEnumerable <Mat> gaussPyr, IEnumerable <Mat> dogPyr) { ThrowIfDisposed(); if (gaussPyr == null) { throw new ArgumentNullException("gaussPyr"); } if (dogPyr == null) { throw new ArgumentNullException("dogPyr"); } IntPtr[] gaussPyrPtrs = EnumerableEx.SelectPtrs(gaussPyr); IntPtr[] dogPyrPtrs = EnumerableEx.SelectPtrs(dogPyr); using (VectorOfKeyPoint keyPointsVec = new VectorOfKeyPoint()) { NativeMethods.nonfree_SIFT_findScaleSpaceExtrema(ptr, gaussPyrPtrs, gaussPyrPtrs.Length, dogPyrPtrs, dogPyrPtrs.Length, keyPointsVec.CvPtr); return(keyPointsVec.ToArray()); } }
/// <summary> /// keypoint を検出し,その SURF ディスクリプタを計算します.[useProvidedKeypoints = true] /// </summary> /// <param name="img"></param> /// <param name="mask"></param> /// <param name="keypoints"></param> /// <param name="descriptors"></param> /// <param name="useProvidedKeypoints"></param> #else /// <summary> /// detects keypoints and computes the SURF descriptors for them. [useProvidedKeypoints = true] /// </summary> /// <param name="img"></param> /// <param name="mask"></param> /// <param name="keypoints"></param> /// <param name="descriptors"></param> /// <param name="useProvidedKeypoints"></param> #endif public void Run(InputArray img, InputArray mask, out KeyPoint[] keypoints, OutputArray descriptors, bool useProvidedKeypoints = false) { ThrowIfDisposed(); if (img == null) { throw new ArgumentNullException(nameof(img)); } if (descriptors == null) { throw new ArgumentNullException(nameof(descriptors)); } img.ThrowIfDisposed(); descriptors.ThrowIfNotReady(); using (VectorOfKeyPoint keypointsVec = new VectorOfKeyPoint()) { NativeMethods.nonfree_SURF_run2_OutputArray(ptr, img.CvPtr, Cv2.ToPtr(mask), keypointsVec.CvPtr, descriptors.CvPtr, useProvidedKeypoints ? 1 : 0); keypoints = keypointsVec.ToArray(); } }
/// <summary> /// Compute the BRISK features and descriptors on an image /// </summary> /// <param name="image"></param> /// <param name="mask"></param> /// <param name="keyPoints"></param> /// <param name="descriptors"></param> /// <param name="useProvidedKeypoints"></param> public void Run(InputArray image, InputArray mask, out KeyPoint[] keyPoints, OutputArray descriptors, bool useProvidedKeypoints = false) { ThrowIfDisposed(); if (image == null) { throw new ArgumentNullException("image"); } if (descriptors == null) { throw new ArgumentNullException("descriptors"); } image.ThrowIfDisposed(); descriptors.ThrowIfNotReady(); using (VectorOfKeyPoint keyPointsVec = new VectorOfKeyPoint()) { NativeMethods.features2d_BRISK_run2(ptr, image.CvPtr, Cv2.ToPtr(mask), keyPointsVec.CvPtr, descriptors.CvPtr, useProvidedKeypoints ? 1 : 0); keyPoints = keyPointsVec.ToArray(); } descriptors.Fix(); }
/// <summary> /// Computes an image descriptor using the set visual vocabulary. /// </summary> /// <param name="image">Image, for which the descriptor is computed.</param> /// <param name="keypoints">Keypoints detected in the input image.</param> /// <param name="imgDescriptor">Computed output image descriptor.</param> public void Compute2(Mat image, out KeyPoint[] keypoints, Mat imgDescriptor) { if (IsDisposed) { throw new ObjectDisposedException(GetType().Name); } if (image == null) { throw new ArgumentNullException(nameof(image)); } if (imgDescriptor == null) { throw new ArgumentNullException(nameof(imgDescriptor)); } using (var keypointsVec = new VectorOfKeyPoint()) { NativeMethods.features2d_BOWImgDescriptorExtractor_compute2( ptr, image.CvPtr, keypointsVec.CvPtr, imgDescriptor.CvPtr); keypoints = keypointsVec.ToArray(); } GC.KeepAlive(image); GC.KeepAlive(imgDescriptor); }