SHARE
TWEET

Untitled

a guest Jan 11th, 2017 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class DescriptorManager {
  2.  
  3.     private static ORBDetector _detector;
  4.     public static ORBDetector Detector
  5.             => _detector ?? (_detector = new ORBDetector(numberOfFeatures: 700, scaleFactor: 1.2F, nLevels: 10, edgeThreshold: 0));
  6.  
  7.     public static Mat ExtractDescriptor(Mat mat) {
  8.         var descriptors = new Mat();
  9.         var keyPoints = new VectorOfKeyPoint();
  10.         Detector.DetectAndCompute(mat, null, keyPoints, descriptors,false);
  11.         descriptors.ConvertTo(descriptors, DepthType.Cv8U);
  12.         return descriptors;
  13.     }
  14.    
  15.     public static Mat ConcatDescriptors(IEnumerable<Mat> descriptors) {
  16.             var mat = descriptors.FirstOrDefault();
  17.             if (mat == null) return null;
  18.             descriptors = descriptors.Skip(1);
  19.             foreach(var descriptor in descriptors) {
  20.         var next = new Mat();
  21.                 CvInvoke.VConcat(mat, descriptor, next);
  22.                 next.ConvertTo(mat, DepthType.Cv8U);
  23.             }
  24.             mat.ConvertTo(mat, DepthType.Cv8U);
  25.             return mat;
  26.         }
  27. }
RAW Paste Data
Top