ToArray() public method

Convert the standard vector to an array of KeyPoint
public ToArray ( ) : MKeyPoint[]
return MKeyPoint[]
Esempio n. 1
0
 /// <summary>
 /// Detect the Lepetit keypoints from the image
 /// </summary>
 /// <param name="image">The image to extract Lepetit keypoints</param>
 /// <param name="maxCount">The maximum number of keypoints to be extracted, use 0 to ignore the max count</param>
 /// <param name="scaleCoords">Indicates if the coordinates should be scaled</param>
 /// <returns>The array of Lepetit keypoints</returns>
 public MKeyPoint[] DetectKeyPoints(Image<Gray, Byte> image, int maxCount, bool scaleCoords)
 {
     using (VectorOfKeyPoint kpts = new VectorOfKeyPoint())
      {
     CvLDetectorDetectKeyPoints(ref this, image, kpts, maxCount, scaleCoords);
     return kpts.ToArray();
      }
 }
Esempio n. 2
0
 /// <summary>
 /// Detect the Fast keypoints from the image
 /// </summary>
 /// <param name="image">The image to extract keypoints from</param>
 /// <returns>The array of fast keypoints</returns>
 public MKeyPoint[] DetectKeyPoints(Image<Gray, byte> image)
 {
     using (VectorOfKeyPoint keypoints = new VectorOfKeyPoint())
      {
     CvFASTKeyPoints(image, keypoints, Threshold, NonmaxSupression);
     return keypoints.ToArray();
      }
 }
Esempio n. 3
0
 /// <summary>
 /// Detect keypoints in the CudaImage
 /// </summary>
 /// <param name="img">The image where keypoints will be detected from</param>
 /// <param name="mask">The optional mask, can be null if not needed</param>
 /// <returns>An array of keypoints</returns>
 public MKeyPoint[] DetectKeyPoints(GpuMat img, GpuMat mask)
 {
    using (GpuMat tmp = DetectKeyPointsRaw(img, mask))
    using (VectorOfKeyPoint kpts = new VectorOfKeyPoint())
    {
       DownloadKeypoints(tmp, kpts);
       return kpts.ToArray();
    }
 }
Esempio n. 4
0
 /// <summary>
 /// Detect the SURF keypoints from the image
 /// </summary>
 /// <param name="image">The image to extract SURF features from</param>
 /// <param name="mask">The optional mask, can be null if not needed</param>
 /// <returns>An array of SURF key points</returns>
 public MKeyPoint[] DetectKeyPoints(Image<Gray, Byte> image, Image<Gray, byte> mask)
 {
     using (VectorOfKeyPoint kpts = new VectorOfKeyPoint())
      {
     CvSIFTDetectorDetectKeyPoints(_ptr, image, mask, kpts);
     return kpts.ToArray();
      }
 }
Esempio n. 5
0
        /// <summary>
        /// Detect image features from the given image
        /// </summary>
        /// <param name="image">The image to detect features from</param>
        /// <param name="mask">The optional mask, can be null if not needed</param>
        /// <returns>The Image features detected from the given image</returns>
        public ImageFeature[] DetectFeatures(Image<Gray, Byte> image, Image<Gray, byte> mask)
        {
            using (VectorOfKeyPoint pts = new VectorOfKeyPoint())
             using (VectorOfFloat descVec = new VectorOfFloat())
             {
            CvSIFTDetectorDetectFeature(_ptr, image, mask, pts, descVec);
            MKeyPoint[] kpts = pts.ToArray();
            float[] desc = descVec.ToArray();
            int n = kpts.Length;
            int sizeOfdescriptor = DescriptorSize;

            ImageFeature[] features = new ImageFeature[n];
            for (int i = 0; i < n; i++)
            {
               features[i].KeyPoint = kpts[i];
               float[] d = new float[sizeOfdescriptor];
               Array.Copy(desc, i * sizeOfdescriptor, d, 0, sizeOfdescriptor);
               features[i].Descriptor = d;
            }
            return features;
             }
        }
Esempio n. 6
0
 /// <summary>
 /// Detect the keypoints from the image
 /// </summary>
 /// <param name="image">The image to extract keypoints from</param>
 /// <param name="mask">The optional mask.</param>
 /// <returns>An array of key points</returns>
 public MKeyPoint[] Detect(IInputArray image, IInputArray mask = null)
 {
    using (VectorOfKeyPoint keypoints = new VectorOfKeyPoint())
    {
       DetectRaw(image, keypoints, mask);
       return keypoints.ToArray();
    }
 }
 /// <summary>
 /// Convert the raw keypoints and descriptors to ImageFeature
 /// </summary>
 /// <param name="keyPointsVec">The raw keypoints vector</param>
 /// <param name="descriptors">The raw descriptor matrix</param>
 /// <returns>An array of image features</returns>
 public static ImageFeature[] ConvertToImageFeature(VectorOfKeyPoint keyPointsVec, Matrix<float> descriptors)
 {
     if (keyPointsVec.Size == 0) return new ImageFeature[0];
      Debug.Assert(keyPointsVec.Size == descriptors.Rows, "Size of keypoints vector do not match the rows of the descriptors matrix.");
      int sizeOfdescriptor = descriptors.Cols;
      MKeyPoint[] keyPoints = keyPointsVec.ToArray();
      ImageFeature[] features = new ImageFeature[keyPoints.Length];
      MCvMat header = descriptors.MCvMat;
      long address = header.data.ToInt64();
      for (int i = 0; i < keyPoints.Length; i++, address += header.step)
      {
     features[i].KeyPoint = keyPoints[i];
     float[] desc = new float[sizeOfdescriptor];
     Marshal.Copy(new IntPtr(address), desc, 0, sizeOfdescriptor);
     features[i].Descriptor = desc;
      }
      return features;
 }
Esempio n. 8
0
 /// <summary>
 /// Detect the SURF keypoints from the image
 /// </summary>
 /// <param name="image">The image to extract SURF features from</param>
 /// <param name="mask">The optional mask, can be null if not needed</param>
 /// <returns>An array of SURF key points</returns>
 public MKeyPoint[] DetectKeyPoints(Image<Gray, Byte> image, Image<Gray, byte> mask)
 {
     using (VectorOfKeyPoint keypoints = new VectorOfKeyPoint())
      {
     CvSURFDetectorDetectKeyPoints(ref this, image, mask, keypoints);
     return keypoints.ToArray();
      }
 }
Esempio n. 9
0
        /// <summary>
        /// Detect image features from the given image
        /// </summary>
        /// <param name="image">The image to detect features from</param>
        /// <param name="mask">The optional mask, can be null if not needed</param>
        /// <returns>The Image features detected from the given image</returns>
        public ImageFeature[] DetectFeatures(Image<Gray, Byte> image, Image<Gray, byte> mask)
        {
            using (VectorOfKeyPoint pts = new VectorOfKeyPoint())
             using (VectorOfFloat descs = new VectorOfFloat())
             {
            CvSURFDetectorDetectFeature(ref this, image, mask, pts, descs);
            MKeyPoint[] kpts = pts.ToArray();
            int n = kpts.Length;
            long add = descs.StartAddress.ToInt64();

            ImageFeature[] features = new ImageFeature[n];
            int sizeOfdescriptor = extended == 0 ? 64 : 128;
            for (int i = 0; i < n; i++, add += sizeOfdescriptor * sizeof(float))
            {
               features[i].KeyPoint = kpts[i];
               float[] desc = new float[sizeOfdescriptor];
               Marshal.Copy(new IntPtr(add), desc, 0, sizeOfdescriptor);
               features[i].Descriptor = desc;
            }
            return features;
             }
        }
 /// <summary>
 /// Detect keypoints in the GpuImage
 /// </summary>
 /// <param name="img">The image where keypoints will be detected from</param>
 /// <param name="mask">The optional mask, can be null if not needed</param>
 /// <returns>An array of keypoints</returns>
 public MKeyPoint[] DetectKeyPoints(GpuImage<Gray, Byte> img, GpuImage<Gray, Byte> mask)
 {
     using (GpuMat<float> tmp = DetectKeyPointsRaw(img, mask))
      using (VectorOfKeyPoint kpts = new VectorOfKeyPoint())
      {
     DownloadKeypoints(tmp, kpts);
     return kpts.ToArray();
      }
 }
Esempio n. 11
0
      public void TestCudaOrbDetector()
      {
         if (!CudaInvoke.HasCuda)
            return;
         using(Image<Bgr, Byte> img = new Image<Bgr, byte>("box.png"))
         using (GpuMat cudaImage = new GpuMat(img))
         using (GpuMat grayCudaImage = new GpuMat()) 
         using (CudaORBDetector detector = new CudaORBDetector(500))
         using (VectorOfKeyPoint kpts = new VectorOfKeyPoint())
         using (GpuMat keyPointMat = new GpuMat())
         using (GpuMat descriptorMat = new GpuMat())
         {
            CudaInvoke.CvtColor(cudaImage, grayCudaImage, ColorConversion.Bgr2Gray);
            detector.DetectAsync(grayCudaImage, keyPointMat);
            detector.Convert(keyPointMat, kpts);
            //detector.ComputeRaw(grayCudaImage, null, keyPointMat, descriptorMat);
            //detector.DownloadKeypoints(keyPointMat, kpts);

            foreach (MKeyPoint kpt in kpts.ToArray())
            {
               img.Draw(new CircleF(kpt.Point, 3.0f), new Bgr(0, 255, 0), 1);
            }

            //ImageViewer.Show(img);
         }
      }
Esempio n. 12
0
      public void TestCudaFASTDetector()
      {
         if (!CudaInvoke.HasCuda)
            return;
         using (Image<Bgr, Byte> img = new Image<Bgr, byte>("box.png"))
         using (CudaImage<Bgr, Byte> CudaImage = new CudaImage<Bgr, byte>(img))
         using (CudaImage<Gray, Byte> grayCudaImage = CudaImage.Convert<Gray, Byte>())
         using (CudaFastFeatureDetector featureDetector = new CudaFastFeatureDetector(10, true, FastDetector.DetectorType.Type9_16, 1000 ))
         using (VectorOfKeyPoint kpts = new VectorOfKeyPoint())
         using (GpuMat keyPointsMat = new GpuMat())
         {
            featureDetector.DetectAsync(grayCudaImage, keyPointsMat);
            featureDetector.Convert(keyPointsMat, kpts);
            //featureDetector.DetectKeyPointsRaw(grayCudaImage, null, keyPointsMat);

            //featureDetector.DownloadKeypoints(keyPointsMat, kpts);

            foreach (MKeyPoint kpt in kpts.ToArray())
            {
               img.Draw(new CircleF(kpt.Point, 3.0f), new Bgr(0, 255, 0), 1);
            }

            //ImageViewer.Show(img);
         }
      }
Esempio n. 13
0
 /// <summary>
 /// Detect the MSER keypoints from the image
 /// </summary>
 /// <param name="image">The image to extract MSER keypoints from</param>
 /// <param name="mask">The optional mask, can be null if not needed</param>
 /// <returns>An array of MSER key points</returns>
 public MKeyPoint[] DetectKeyPoints(Image<Gray, Byte> image, Image<Gray, byte> mask)
 {
     using (VectorOfKeyPoint kpts = new VectorOfKeyPoint())
      {
     CvMSERKeyPoints(image, mask, kpts, ref this);
     return kpts.ToArray();
      }
 }
Esempio n. 14
0
 /// <summary>
 /// Detect the keypoints in the image
 /// </summary>
 /// <param name="image">The image from which the key point will be detected from</param>
 /// <returns>The key pionts in the image</returns>
 public MKeyPoint[] DetectKeyPoints(Image<Gray, Byte> image)
 {
     using (VectorOfKeyPoint kpts = new VectorOfKeyPoint())
      {
     CvStarDetectorDetectKeyPoints(ref this, image, kpts);
     return kpts.ToArray();
      }
 }