/// <summary>
 /// Draw keypoint matches from two images on the output image.
 /// </summary>
 /// <param name="image1">The first image.</param>
 /// <param name="keyPoints1">The collection of keypoints from the first image.</param>
 /// <param name="image2">The second image.</param>
 /// <param name="keyPoints2">The collection of keypoints from the second image.</param>
 /// <param name="matches">The matches from the first image to the second image.</param>
 /// <param name="outImage">The image where the keypoint matches are to be drawn.</param>
 public static void DrawMatches(
     Arr image1, KeyPointCollection keyPoints1,
     Arr image2, KeyPointCollection keyPoints2,
     DMatchCollection matches, Arr outImage)
 {
     DrawMatches(image1, keyPoints1, image2, keyPoints2, matches, outImage, Scalar.All(-1));
 }
Exemplo n.º 2
0
        /// <summary>
        /// Converts a collection of keypoints to an array of points.
        /// </summary>
        /// <param name="keyPoints">The collection of keypoints to convert.</param>
        /// <returns>The array of converted keypoints.</returns>
        public static  Point2f[] Convert(KeyPointCollection keyPoints)
        {
            var points = new Point2f[keyPoints.Count];

            Convert(keyPoints, points);
            return(points);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Converts a collection of keypoints to an array of points.
 /// </summary>
 /// <param name="keyPoints">The collection of keypoints to convert.</param>
 /// <param name="points">The array of points that is the destination of the converted keypoints.</param>
 /// <param name="keyPointIndices">The optional array containing the keypoint indices to convert.</param>
 public static void Convert(KeyPointCollection keyPoints, Point2f[] points, int[] keyPointIndices)
 {
     using (var pointVector = new Point2fCollection())
         using (var indexVector = keyPointIndices != null ? new Int32Collection(keyPointIndices) : null)
         {
             Convert(keyPoints, pointVector, indexVector);
             pointVector.CopyTo(points);
         }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Detects keypoints in the specified input image.
        /// </summary>
        /// <param name="detector">The feature detector used to find image keypoints.</param>
        /// <param name="image">The image on which to detect keypoints.</param>
        /// <param name="mask">The optional operation mask used to specify where to look for keypoints.</param>
        /// <returns>The collection of detected keypoints.</returns>
        public static KeyPointCollection Detect(this IFeatureDetector detector, Arr image, Arr mask = null)
        {
            if (detector == null)
            {
                throw new ArgumentNullException("detector");
            }

            var keyPoints = new KeyPointCollection();

            detector.Detect(image, keyPoints, mask);
            return(keyPoints);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Converts an array of points to a collection of keypoints, where each
        /// keypoint is assigned the same size, response and orientation.
        /// </summary>
        /// <param name="points">The array of points to convert.</param>
        /// <param name="size">The shared size of the converted keypoints.</param>
        /// <param name="response">The shared response of the converted keypoints.</param>
        /// <param name="octave">The shared octave, or pyramid level, of the converted keypoints.</param>
        /// <param name="classId">The shared class id of the converted keypoints.</param>
        /// <returns>The collection of converted keypoints.</returns>
        public static KeyPointCollection Convert(
            Point2f[] points,
            float size     = 1,
            float response = 1,
            int octave     = 0,
            int classId    = -1)
        {
            var keyPoints = new KeyPointCollection();

            Convert(points, keyPoints, size, response, octave, classId);
            return(keyPoints);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Converts an array of points to a collection of keypoints, where each
 /// keypoint is assigned the same size, response and orientation.
 /// </summary>
 /// <param name="points">The array of points to convert.</param>
 /// <param name="keyPoints">The collection that is the destination of the converted keypoints.</param>
 /// <param name="size">The shared size of the converted keypoints.</param>
 /// <param name="response">The shared response of the converted keypoints.</param>
 /// <param name="octave">The shared octave, or pyramid level, of the converted keypoints.</param>
 /// <param name="classId">The shared class id of the converted keypoints.</param>
 public static void Convert(
     Point2f[] points,
     KeyPointCollection keyPoints,
     float size     = 1,
     float response = 1,
     int octave     = 0,
     int classId    = -1)
 {
     using (var vector = new Point2fCollection(points))
     {
         Convert(vector, keyPoints, size, response, octave, classId);
     }
 }
Exemplo n.º 7
0
 /// <summary>
 /// Converts a collection of points to a collection of keypoints, where each
 /// keypoint is assigned the same size, response and orientation.
 /// </summary>
 /// <param name="points">The collection of points to convert.</param>
 /// <param name="keyPoints">The collection that is the destination of the converted keypoints.</param>
 /// <param name="size">The shared size of the converted keypoints.</param>
 /// <param name="response">The shared response of the converted keypoints.</param>
 /// <param name="octave">The shared octave, or pyramid level, of the converted keypoints.</param>
 /// <param name="classId">The shared class id of the converted keypoints.</param>
 public static void Convert(
     Point2fCollection points,
     KeyPointCollection keyPoints,
     float size     = 1,
     float response = 1,
     int octave     = 0,
     int classId    = -1)
 {
     NativeMethods.cv_features2d_KeyPoint_convert_vector_Point2f(
         points,
         keyPoints,
         size,
         response,
         octave,
         classId);
 }
 /// <summary>
 /// Draw keypoint matches from two images on the output image.
 /// </summary>
 /// <param name="image1">The first image.</param>
 /// <param name="keyPoints1">The collection of keypoints from the first image.</param>
 /// <param name="image2">The second image.</param>
 /// <param name="keyPoints2">The collection of keypoints from the second image.</param>
 /// <param name="matches">The matches from the first image to the second image.</param>
 /// <param name="outImage">The image where the keypoint matches are to be drawn.</param>
 /// <param name="matchColor">The color used for drawing successful matches.</param>
 /// <param name="singlePointColor">The color used for drawing unmatched keypoints.</param>
 /// <param name="matchesMask">The optional mask specifying which matches are drawn.</param>
 /// <param name="flags">Optional operation flags specifying how the matches are to be drawn.</param>
 public static void DrawMatches(
     Arr image1, KeyPointCollection keyPoints1,
     Arr image2, KeyPointCollection keyPoints2,
     DMatchCollection matches, Arr outImage,
     Scalar matchColor,
     Scalar singlePointColor,
     ByteCollection matchesMask = null,
     DrawMatchesFlags flags     = DrawMatchesFlags.None)
 {
     NativeMethods.cv_features2d_drawMatches(
         image1, keyPoints1,
         image2, keyPoints2,
         matches, outImage,
         matchColor, singlePointColor,
         matchesMask ?? ByteCollection.Null, flags);
 }
Exemplo n.º 9
0
        /// <summary>
        /// Computes the descriptors for a set of keypoints in an image.
        /// </summary>
        /// <param name="extractor">The descriptor extractor used to compute keypoint descriptors.</param>
        /// <param name="image">The image from which to extract keypoint descriptors.</param>
        /// <param name="keyPoints">
        /// The keypoints for which to extract descriptors. Keypoints for which a
        /// descriptor cannot be computed are removed.
        /// </param>
        /// <returns>The array of descriptors computed for the specified set of keypoints.</returns>
        public static Mat Compute(this IDescriptorExtractor extractor, Arr image, KeyPointCollection keyPoints)
        {
            if (extractor == null)
            {
                throw new ArgumentNullException("extractor");
            }

            if (keyPoints == null)
            {
                throw new ArgumentNullException("keyPoints");
            }

            var descriptors = new Mat(keyPoints.Count, extractor.DescriptorSize, extractor.DescriptorType);

            extractor.Compute(image, keyPoints, descriptors);
            if (descriptors.Rows != keyPoints.Count)
            {
                descriptors = descriptors.GetSubRect(new Rect(0, 0, descriptors.Cols, keyPoints.Count));
            }

            return(descriptors);
        }
Exemplo n.º 10
0
 /// <summary>
 /// Converts a collection of keypoints to a collection of points.
 /// </summary>
 /// <param name="keyPoints">The collection of keypoints to convert.</param>
 /// <param name="points">The collection of points that is the destination of the converted keypoints.</param>
 /// <param name="keyPointIndices">The optional collection of the keypoint indices to convert.</param>
 public static void Convert(KeyPointCollection keyPoints, Point2fCollection points, Int32Collection keyPointIndices)
 {
     NativeMethods.cv_features2d_KeyPoint_convert_vector_KeyPoint(keyPoints, points, keyPointIndices ?? Int32Collection.Null);
 }
Exemplo n.º 11
0
 /// <summary>
 /// Converts a collection of keypoints to a collection of points.
 /// </summary>
 /// <param name="keyPoints">The collection of keypoints to convert.</param>
 /// <param name="points">The collection of points that is the destination of the converted keypoints.</param>
 public static void Convert(KeyPointCollection keyPoints, Point2fCollection points)
 {
     Convert(keyPoints, points, null);
 }
Exemplo n.º 12
0
 /// <summary>
 /// Detects keypoints in the specified input image.
 /// </summary>
 /// <param name="image">The image on which to detect keypoints.</param>
 /// <param name="keyPoints">The collection that will contain the set of detected keypoints.</param>
 /// <param name="mask">The optional operation mask used to specify where to look for keypoints.</param>
 public abstract void Detect(Arr image, KeyPointCollection keyPoints, Arr mask = null);
Exemplo n.º 13
0
 /// <summary>
 /// Retain the specified number of best keypoints, sorted by their response.
 /// </summary>
 /// <param name="keyPoints">The collection of keypoints to filter.</param>
 /// <param name="numPoints">The number of points to retain.</param>
 public static void RetainBest(KeyPointCollection keyPoints, int numPoints)
 {
     NativeMethods.cv_features2d_KeyPointsFilter_retainBest(keyPoints, numPoints);
 }
Exemplo n.º 14
0
 /// <summary>
 /// Remove duplicated keypoints.
 /// </summary>
 /// <param name="keyPoints">The collection of keypoints to filter.</param>
 public static void RemoveDuplicated(KeyPointCollection keyPoints)
 {
     NativeMethods.cv_features2d_KeyPointsFilter_removeDuplicated(keyPoints);
 }
Exemplo n.º 15
0
 /// <summary>
 /// Detects corners using the FAST algorithm.
 /// </summary>
 /// <param name="image">The image on which to detect keypoints.</param>
 /// <param name="keyPoints">The collection that will contain the set of detected keypoints.</param>
 /// <param name="threshold">
 /// The threshold applied to the difference between the intensity of each central pixel
 /// and the pixels lying in a circle around this pixel.
 /// </param>
 /// <param name="nonMaxSuppression">Specifies whether to apply non-maximum suppression on detected corners.</param>
 /// <param name="type">The type of pixel neighborhood.</param>
 public static void FAST(Arr image, KeyPointCollection keyPoints, int threshold, bool nonMaxSuppression, FastDetectorType type)
 {
     NativeMethods.cv_features2d_FASTX(image, keyPoints, threshold, nonMaxSuppression, type);
 }
Exemplo n.º 16
0
 /// <summary>
 /// Computes the descriptors for a set of keypoints in an image.
 /// </summary>
 /// <param name="image">The image from which to extract keypoint descriptors.</param>
 /// <param name="keyPoints">
 /// The keypoints for which to extract descriptors. Keypoints for which a
 /// descriptor cannot be computed are removed.
 /// </param>
 /// <param name="descriptors">
 /// The array of descriptors computed for the specified set of keypoints.
 /// </param>
 public override void Compute(Arr image, KeyPointCollection keyPoints, Arr descriptors)
 {
     NativeMethods.cv_features2d_BRISK_compute(this, image, keyPoints, descriptors);
 }
Exemplo n.º 17
0
 /// <summary>
 /// Detects keypoints in the specified input image.
 /// </summary>
 /// <param name="image">The image on which to detect keypoints.</param>
 /// <param name="keyPoints">The collection that will contain the set of detected keypoints.</param>
 /// <param name="mask">The optional operation mask used to specify where to look for keypoints.</param>
 public override void Detect(Arr image, KeyPointCollection keyPoints, Arr mask = null)
 {
     NativeMethods.cv_features2d_BRISK_detect(this, image, keyPoints, mask ?? Arr.Null);
 }
Exemplo n.º 18
0
 /// <summary>
 /// Computes the descriptors for a set of keypoints in an image.
 /// </summary>
 /// <param name="image">The image from which to extract keypoint descriptors.</param>
 /// <param name="keyPoints">
 /// The keypoints for which to extract descriptors. Keypoints for which a
 /// descriptor cannot be computed are removed.
 /// </param>
 /// <param name="descriptors">
 /// The array of descriptors computed for the specified set of keypoints.
 /// </param>
 public abstract void Compute(Arr image, KeyPointCollection keyPoints, Arr descriptors);
Exemplo n.º 19
0
 /// <summary>
 /// Draws a visual representation of detected keypoints in an image.
 /// </summary>
 /// <param name="image">The image on which the keypoints were detected.</param>
 /// <param name="keyPoints">The collection of keypoints to draw.</param>
 /// <param name="output">The image where the keypoints are to be drawn.</param>
 /// <param name="color">The color of the keypoints.</param>
 /// <param name="flags">Optional operation flags specifying how the keypoints are to be drawn.</param>
 public static void DrawKeypoints(Arr image, KeyPointCollection keyPoints, Arr output, Scalar color, DrawMatchesFlags flags = DrawMatchesFlags.None)
 {
     NativeMethods.cv_features2d_drawKeypoints(image, keyPoints, output, color, flags);
 }
Exemplo n.º 20
0
 /// <summary>
 /// Draws a visual representation of detected keypoints in an image.
 /// </summary>
 /// <param name="image">The image on which the keypoints were detected.</param>
 /// <param name="keyPoints">The collection of keypoints to draw.</param>
 /// <param name="output">The image where the keypoints are to be drawn.</param>
 public static void DrawKeypoints(Arr image, KeyPointCollection keyPoints, Arr output)
 {
     DrawKeypoints(image, keyPoints, output, Scalar.All(-1));
 }
Exemplo n.º 21
0
 /// <summary>
 /// Remove keypoints with sizes outside of the specified range.
 /// </summary>
 /// <param name="keyPoints">The collection of keypoints to filter.</param>
 /// <param name="minSize">The minimum size of the keypoints.</param>
 /// <param name="maxSize">The maximum size of the keypoints.</param>
 public static void RunByKeypointSize(KeyPointCollection keyPoints, float minSize, float maxSize = float.MaxValue)
 {
     NativeMethods.cv_features2d_KeyPointsFilter_runByKeypointSize(keyPoints, minSize, maxSize);
 }
Exemplo n.º 22
0
 /// <summary>
 /// Remove keypoints by checking whether they lie in the specified pixel operation mask.
 /// </summary>
 /// <param name="keyPoints">The collection of keypoints to filter.</param>
 /// <param name="mask">The operation mask used to filter the keypoints</param>
 public static void RunByPixelsMask(KeyPointCollection keyPoints, Arr mask)
 {
     NativeMethods.cv_features2d_KeyPointsFilter_runByPixelsMask(keyPoints, mask);
 }
Exemplo n.º 23
0
 /// <summary>
 /// Remove keypoints which lie within <paramref name="borderSize"/> of an image edge.
 /// </summary>
 /// <param name="keyPoints">The collection of keypoints to filter.</param>
 /// <param name="imageSize">The size of the input image.</param>
 /// <param name="borderSize">
 /// The minimum number of pixels by which keypoints should be
 /// away from the image edge.
 /// </param>
 public static void RunByImageBorder(KeyPointCollection keyPoints, Size imageSize, int borderSize)
 {
     NativeMethods.cv_features2d_KeyPointsFilter_runByImageBorder(keyPoints, imageSize, borderSize);
 }
Exemplo n.º 24
0
 /// <summary>
 /// Detects corners using the FAST algorithm.
 /// </summary>
 /// <param name="image">The image on which to detect keypoints.</param>
 /// <param name="keyPoints">The collection that will contain the set of detected keypoints.</param>
 /// <param name="threshold">
 /// The threshold applied to the difference between the intensity of each central pixel
 /// and the pixels lying in a circle around this pixel.
 /// </param>
 /// <param name="nonMaxSuppression">Specifies whether to apply non-maximum suppression on detected corners.</param>
 public static void FAST(Arr image, KeyPointCollection keyPoints, int threshold, bool nonMaxSuppression = true)
 {
     NativeMethods.cv_features2d_FAST(image, keyPoints, threshold, nonMaxSuppression);
 }