You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
2.5 KiB

  1. //----------------------------------------------------------------------------
  2. // Copyright (C) 2004-2015 by EMGU Corporation. All rights reserved.
  3. //----------------------------------------------------------------------------
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Diagnostics;
  7. using System.Runtime.InteropServices;
  8. using System.Text;
  9. using Emgu.CV;
  10. using Emgu.CV.CvEnum;
  11. using Emgu.CV.Structure;
  12. using Emgu.CV.Util;
  13. using Emgu.Util;
  14. using Emgu.CV.Features2D;
  15. namespace Emgu.CV.XFeatures2D
  16. {
  17. /// <summary>
  18. /// latch Class for computing the LATCH descriptor.
  19. /// If you find this code useful, please add a reference to the following paper in your work:
  20. /// Gil Levi and Tal Hassner, "LATCH: Learned Arrangements of Three Patch Codes", arXiv preprint arXiv:1501.03719, 15 Jan. 2015
  21. /// LATCH is a binary descriptor based on learned comparisons of triplets of image patches.
  22. /// </summary>
  23. public class LATCH : Feature2D
  24. {
  25. /// <summary>
  26. /// Create LATCH descriptor extractor
  27. /// </summary>
  28. /// <param name="bytes">The size of the descriptor - can be 64, 32, 16, 8, 4, 2 or 1</param>
  29. /// <param name="rotationInvariance">Whether or not the descriptor should compensate for orientation changes.</param>
  30. /// <param name="halfSsdSize">the size of half of the mini-patches size. For example, if we would like to compare triplets of patches of size 7x7x
  31. /// then the half_ssd_size should be (7-1)/2 = 3.</param>
  32. public LATCH(int bytes = 32, bool rotationInvariance = true, int halfSsdSize = 3)
  33. {
  34. _ptr = ContribInvoke.cveLATCHCreate(bytes, rotationInvariance, halfSsdSize, ref _feature2D);
  35. }
  36. /// <summary>
  37. /// Release all the unmanaged resource associated with BRIEF
  38. /// </summary>
  39. protected override void DisposeObject()
  40. {
  41. if (_ptr != IntPtr.Zero)
  42. {
  43. ContribInvoke.cveLATCHRelease(ref _ptr);
  44. }
  45. base.DisposeObject();
  46. }
  47. }
  48. public static partial class ContribInvoke
  49. {
  50. [DllImport(CvInvoke.ExternLibrary, CallingConvention = CvInvoke.CvCallingConvention)]
  51. internal extern static IntPtr cveLATCHCreate(
  52. int bytes,
  53. [MarshalAs(CvInvoke.BoolMarshalType)]
  54. bool rotationInvariance,
  55. int halfSsdSize,
  56. ref IntPtr extractor);
  57. [DllImport(CvInvoke.ExternLibrary, CallingConvention = CvInvoke.CvCallingConvention)]
  58. internal extern static void cveLATCHRelease(ref IntPtr extractor);
  59. }
  60. }