GrayCodePattern.cs 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. 
  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 GrayCodePattern
  10. //javadoc: GrayCodePattern
  11. public class GrayCodePattern : StructuredLightPattern
  12. {
  13. protected override void Dispose (bool disposing)
  14. {
  15. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  16. try {
  17. if (disposing) {
  18. }
  19. if (IsEnabledDispose) {
  20. if (nativeObj != IntPtr.Zero)
  21. structured_1light_GrayCodePattern_delete (nativeObj);
  22. nativeObj = IntPtr.Zero;
  23. }
  24. } finally {
  25. base.Dispose (disposing);
  26. }
  27. #else
  28. return;
  29. #endif
  30. }
  31. protected internal GrayCodePattern (IntPtr addr) : base (addr)
  32. {
  33. }
  34. // internal usage only
  35. public static new GrayCodePattern __fromPtr__ (IntPtr addr)
  36. {
  37. return new GrayCodePattern (addr);
  38. }
  39. //
  40. // C++: static Ptr_GrayCodePattern cv::structured_light::GrayCodePattern::create(int width, int height)
  41. //
  42. //javadoc: GrayCodePattern::create(width, height)
  43. public static GrayCodePattern create (int width, int height)
  44. {
  45. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  46. GrayCodePattern retVal = GrayCodePattern.__fromPtr__ (structured_1light_GrayCodePattern_create_10 (width, height));
  47. return retVal;
  48. #else
  49. return null;
  50. #endif
  51. }
  52. //
  53. // C++: bool cv::structured_light::GrayCodePattern::getProjPixel(vector_Mat patternImages, int x, int y, Point& projPix)
  54. //
  55. //javadoc: GrayCodePattern::getProjPixel(patternImages, x, y, projPix)
  56. public bool getProjPixel (List<Mat> patternImages, int x, int y, Point projPix)
  57. {
  58. ThrowIfDisposed ();
  59. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  60. Mat patternImages_mat = Converters.vector_Mat_to_Mat (patternImages);
  61. double[] projPix_out = new double[2];
  62. bool retVal = structured_1light_GrayCodePattern_getProjPixel_10 (nativeObj, patternImages_mat.nativeObj, x, y, projPix_out);
  63. if (projPix != null) {
  64. projPix.x = projPix_out [0];
  65. projPix.y = projPix_out [1];
  66. }
  67. return retVal;
  68. #else
  69. return false;
  70. #endif
  71. }
  72. //
  73. // C++: size_t cv::structured_light::GrayCodePattern::getNumberOfPatternImages()
  74. //
  75. //javadoc: GrayCodePattern::getNumberOfPatternImages()
  76. public long getNumberOfPatternImages ()
  77. {
  78. ThrowIfDisposed ();
  79. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  80. long retVal = structured_1light_GrayCodePattern_getNumberOfPatternImages_10 (nativeObj);
  81. return retVal;
  82. #else
  83. return -1;
  84. #endif
  85. }
  86. //
  87. // C++: void cv::structured_light::GrayCodePattern::getImagesForShadowMasks(Mat& blackImage, Mat& whiteImage)
  88. //
  89. //javadoc: GrayCodePattern::getImagesForShadowMasks(blackImage, whiteImage)
  90. public void getImagesForShadowMasks (Mat blackImage, Mat whiteImage)
  91. {
  92. ThrowIfDisposed ();
  93. if (blackImage != null)
  94. blackImage.ThrowIfDisposed ();
  95. if (whiteImage != null)
  96. whiteImage.ThrowIfDisposed ();
  97. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  98. structured_1light_GrayCodePattern_getImagesForShadowMasks_10 (nativeObj, blackImage.nativeObj, whiteImage.nativeObj);
  99. return;
  100. #else
  101. return;
  102. #endif
  103. }
  104. //
  105. // C++: void cv::structured_light::GrayCodePattern::setBlackThreshold(size_t value)
  106. //
  107. //javadoc: GrayCodePattern::setBlackThreshold(value)
  108. public void setBlackThreshold (long value)
  109. {
  110. ThrowIfDisposed ();
  111. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  112. structured_1light_GrayCodePattern_setBlackThreshold_10 (nativeObj, value);
  113. return;
  114. #else
  115. return;
  116. #endif
  117. }
  118. //
  119. // C++: void cv::structured_light::GrayCodePattern::setWhiteThreshold(size_t value)
  120. //
  121. //javadoc: GrayCodePattern::setWhiteThreshold(value)
  122. public void setWhiteThreshold (long value)
  123. {
  124. ThrowIfDisposed ();
  125. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  126. structured_1light_GrayCodePattern_setWhiteThreshold_10 (nativeObj, value);
  127. return;
  128. #else
  129. return;
  130. #endif
  131. }
  132. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  133. const string LIBNAME = "__Internal";
  134. #else
  135. const string LIBNAME = "opencvforunity";
  136. #endif
  137. // C++: static Ptr_GrayCodePattern cv::structured_light::GrayCodePattern::create(int width, int height)
  138. [DllImport (LIBNAME)]
  139. private static extern IntPtr structured_1light_GrayCodePattern_create_10 (int width, int height);
  140. // C++: bool cv::structured_light::GrayCodePattern::getProjPixel(vector_Mat patternImages, int x, int y, Point& projPix)
  141. [DllImport (LIBNAME)]
  142. private static extern bool structured_1light_GrayCodePattern_getProjPixel_10 (IntPtr nativeObj, IntPtr patternImages_mat_nativeObj, int x, int y, double[] projPix_out);
  143. // C++: size_t cv::structured_light::GrayCodePattern::getNumberOfPatternImages()
  144. [DllImport (LIBNAME)]
  145. private static extern long structured_1light_GrayCodePattern_getNumberOfPatternImages_10 (IntPtr nativeObj);
  146. // C++: void cv::structured_light::GrayCodePattern::getImagesForShadowMasks(Mat& blackImage, Mat& whiteImage)
  147. [DllImport (LIBNAME)]
  148. private static extern void structured_1light_GrayCodePattern_getImagesForShadowMasks_10 (IntPtr nativeObj, IntPtr blackImage_nativeObj, IntPtr whiteImage_nativeObj);
  149. // C++: void cv::structured_light::GrayCodePattern::setBlackThreshold(size_t value)
  150. [DllImport (LIBNAME)]
  151. private static extern void structured_1light_GrayCodePattern_setBlackThreshold_10 (IntPtr nativeObj, long value);
  152. // C++: void cv::structured_light::GrayCodePattern::setWhiteThreshold(size_t value)
  153. [DllImport (LIBNAME)]
  154. private static extern void structured_1light_GrayCodePattern_setWhiteThreshold_10 (IntPtr nativeObj, long value);
  155. // native support for java finalize()
  156. [DllImport (LIBNAME)]
  157. private static extern void structured_1light_GrayCodePattern_delete (IntPtr nativeObj);
  158. }
  159. }