StructuredLightPattern.cs 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #if !UNITY_WEBGL
  2. using OpenCVForUnity.CoreModule;
  3. using OpenCVForUnity.UtilsModule;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Runtime.InteropServices;
  7. namespace OpenCVForUnity.Structured_lightModule
  8. {
  9. // C++: class StructuredLightPattern
  10. /**
  11. * Abstract base class for generating and decoding structured light patterns.
  12. */
  13. public class StructuredLightPattern : Algorithm
  14. {
  15. protected override void Dispose(bool disposing)
  16. {
  17. try
  18. {
  19. if (disposing)
  20. {
  21. }
  22. if (IsEnabledDispose)
  23. {
  24. if (nativeObj != IntPtr.Zero)
  25. structured_1light_StructuredLightPattern_delete(nativeObj);
  26. nativeObj = IntPtr.Zero;
  27. }
  28. }
  29. finally
  30. {
  31. base.Dispose(disposing);
  32. }
  33. }
  34. protected internal StructuredLightPattern(IntPtr addr) : base(addr) { }
  35. // internal usage only
  36. public static new StructuredLightPattern __fromPtr__(IntPtr addr) { return new StructuredLightPattern(addr); }
  37. //
  38. // C++: bool cv::structured_light::StructuredLightPattern::generate(vector_Mat& patternImages)
  39. //
  40. /**
  41. * Generates the structured light pattern to project.
  42. *
  43. * param patternImages The generated pattern: a vector<Mat>, in which each image is a CV_8U Mat at projector's resolution.
  44. * return automatically generated
  45. */
  46. public bool generate(List<Mat> patternImages)
  47. {
  48. ThrowIfDisposed();
  49. Mat patternImages_mat = new Mat();
  50. bool retVal = structured_1light_StructuredLightPattern_generate_10(nativeObj, patternImages_mat.nativeObj);
  51. Converters.Mat_to_vector_Mat(patternImages_mat, patternImages);
  52. patternImages_mat.release();
  53. return retVal;
  54. }
  55. //
  56. // C++: bool cv::structured_light::StructuredLightPattern::decode(vector_vector_Mat patternImages, Mat& disparityMap, vector_Mat blackImages = vector_Mat(), vector_Mat whiteImages = vector_Mat(), int flags = DECODE_3D_UNDERWORLD)
  57. //
  58. // Unknown type 'vector_vector_Mat' (I), skipping the function
  59. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  60. const string LIBNAME = "__Internal";
  61. #else
  62. const string LIBNAME = "opencvforunity";
  63. #endif
  64. // C++: bool cv::structured_light::StructuredLightPattern::generate(vector_Mat& patternImages)
  65. [DllImport(LIBNAME)]
  66. [return: MarshalAs(UnmanagedType.U1)]
  67. private static extern bool structured_1light_StructuredLightPattern_generate_10(IntPtr nativeObj, IntPtr patternImages_mat_nativeObj);
  68. // native support for java finalize()
  69. [DllImport(LIBNAME)]
  70. private static extern void structured_1light_StructuredLightPattern_delete(IntPtr nativeObj);
  71. }
  72. }
  73. #endif