Image2BlobParams.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. #if !UNITY_WSA_10_0
  2. using OpenCVForUnity.CoreModule;
  3. using OpenCVForUnity.UtilsModule;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Runtime.InteropServices;
  7. namespace OpenCVForUnity.DnnModule
  8. {
  9. // C++: class Image2BlobParams
  10. /**
  11. * Processing params of image to blob.
  12. *
  13. * It includes all possible image processing operations and corresponding parameters.
  14. *
  15. * SEE: blobFromImageWithParams
  16. *
  17. * <b>Note:</b>
  18. * The order and usage of {code scalefactor} and {code mean} are (input - mean) * scalefactor.
  19. * The order and usage of {code scalefactor}, {code size}, {code mean}, {code swapRB}, and {code ddepth} are consistent
  20. * with the function of REF: blobFromImage.
  21. */
  22. public class Image2BlobParams : DisposableOpenCVObject
  23. {
  24. protected override void Dispose(bool disposing)
  25. {
  26. try
  27. {
  28. if (disposing)
  29. {
  30. }
  31. if (IsEnabledDispose)
  32. {
  33. if (nativeObj != IntPtr.Zero)
  34. dnn_Image2BlobParams_delete(nativeObj);
  35. nativeObj = IntPtr.Zero;
  36. }
  37. }
  38. finally
  39. {
  40. base.Dispose(disposing);
  41. }
  42. }
  43. protected internal Image2BlobParams(IntPtr addr) : base(addr) { }
  44. public IntPtr getNativeObjAddr() { return nativeObj; }
  45. // internal usage only
  46. public static Image2BlobParams __fromPtr__(IntPtr addr) { return new Image2BlobParams(addr); }
  47. //
  48. // C++: cv::dnn::Image2BlobParams::Image2BlobParams()
  49. //
  50. public Image2BlobParams()
  51. {
  52. nativeObj = DisposableObject.ThrowIfNullIntPtr(dnn_Image2BlobParams_Image2BlobParams_10());
  53. }
  54. //
  55. // C++: cv::dnn::Image2BlobParams::Image2BlobParams(Scalar scalefactor, Size size = Size(), Scalar mean = Scalar(), bool swapRB = false, int ddepth = CV_32F, DataLayout datalayout = DNN_LAYOUT_NCHW, ImagePaddingMode mode = DNN_PMODE_NULL)
  56. //
  57. public Image2BlobParams(Scalar scalefactor, Size size, Scalar mean, bool swapRB, int ddepth)
  58. {
  59. nativeObj = DisposableObject.ThrowIfNullIntPtr(dnn_Image2BlobParams_Image2BlobParams_11(scalefactor.val[0], scalefactor.val[1], scalefactor.val[2], scalefactor.val[3], size.width, size.height, mean.val[0], mean.val[1], mean.val[2], mean.val[3], swapRB, ddepth));
  60. }
  61. public Image2BlobParams(Scalar scalefactor, Size size, Scalar mean, bool swapRB)
  62. {
  63. nativeObj = DisposableObject.ThrowIfNullIntPtr(dnn_Image2BlobParams_Image2BlobParams_14(scalefactor.val[0], scalefactor.val[1], scalefactor.val[2], scalefactor.val[3], size.width, size.height, mean.val[0], mean.val[1], mean.val[2], mean.val[3], swapRB));
  64. }
  65. public Image2BlobParams(Scalar scalefactor, Size size, Scalar mean)
  66. {
  67. nativeObj = DisposableObject.ThrowIfNullIntPtr(dnn_Image2BlobParams_Image2BlobParams_15(scalefactor.val[0], scalefactor.val[1], scalefactor.val[2], scalefactor.val[3], size.width, size.height, mean.val[0], mean.val[1], mean.val[2], mean.val[3]));
  68. }
  69. public Image2BlobParams(Scalar scalefactor, Size size)
  70. {
  71. nativeObj = DisposableObject.ThrowIfNullIntPtr(dnn_Image2BlobParams_Image2BlobParams_16(scalefactor.val[0], scalefactor.val[1], scalefactor.val[2], scalefactor.val[3], size.width, size.height));
  72. }
  73. public Image2BlobParams(Scalar scalefactor)
  74. {
  75. nativeObj = DisposableObject.ThrowIfNullIntPtr(dnn_Image2BlobParams_Image2BlobParams_17(scalefactor.val[0], scalefactor.val[1], scalefactor.val[2], scalefactor.val[3]));
  76. }
  77. //
  78. // C++: Scalar Image2BlobParams::scalefactor
  79. //
  80. public Scalar get_scalefactor()
  81. {
  82. ThrowIfDisposed();
  83. double[] tmpArray = new double[4];
  84. dnn_Image2BlobParams_get_1scalefactor_10(nativeObj, tmpArray);
  85. Scalar retVal = new Scalar(tmpArray);
  86. return retVal;
  87. }
  88. //
  89. // C++: void Image2BlobParams::scalefactor
  90. //
  91. public void set_scalefactor(Scalar scalefactor)
  92. {
  93. ThrowIfDisposed();
  94. dnn_Image2BlobParams_set_1scalefactor_10(nativeObj, scalefactor.val[0], scalefactor.val[1], scalefactor.val[2], scalefactor.val[3]);
  95. }
  96. //
  97. // C++: Size Image2BlobParams::size
  98. //
  99. public Size get_size()
  100. {
  101. ThrowIfDisposed();
  102. double[] tmpArray = new double[2];
  103. dnn_Image2BlobParams_get_1size_10(nativeObj, tmpArray);
  104. Size retVal = new Size(tmpArray);
  105. return retVal;
  106. }
  107. //
  108. // C++: void Image2BlobParams::size
  109. //
  110. public void set_size(Size size)
  111. {
  112. ThrowIfDisposed();
  113. dnn_Image2BlobParams_set_1size_10(nativeObj, size.width, size.height);
  114. }
  115. //
  116. // C++: Scalar Image2BlobParams::mean
  117. //
  118. public Scalar get_mean()
  119. {
  120. ThrowIfDisposed();
  121. double[] tmpArray = new double[4];
  122. dnn_Image2BlobParams_get_1mean_10(nativeObj, tmpArray);
  123. Scalar retVal = new Scalar(tmpArray);
  124. return retVal;
  125. }
  126. //
  127. // C++: void Image2BlobParams::mean
  128. //
  129. public void set_mean(Scalar mean)
  130. {
  131. ThrowIfDisposed();
  132. dnn_Image2BlobParams_set_1mean_10(nativeObj, mean.val[0], mean.val[1], mean.val[2], mean.val[3]);
  133. }
  134. //
  135. // C++: bool Image2BlobParams::swapRB
  136. //
  137. public bool get_swapRB()
  138. {
  139. ThrowIfDisposed();
  140. return dnn_Image2BlobParams_get_1swapRB_10(nativeObj);
  141. }
  142. //
  143. // C++: void Image2BlobParams::swapRB
  144. //
  145. public void set_swapRB(bool swapRB)
  146. {
  147. ThrowIfDisposed();
  148. dnn_Image2BlobParams_set_1swapRB_10(nativeObj, swapRB);
  149. }
  150. //
  151. // C++: int Image2BlobParams::ddepth
  152. //
  153. public int get_ddepth()
  154. {
  155. ThrowIfDisposed();
  156. return dnn_Image2BlobParams_get_1ddepth_10(nativeObj);
  157. }
  158. //
  159. // C++: void Image2BlobParams::ddepth
  160. //
  161. public void set_ddepth(int ddepth)
  162. {
  163. ThrowIfDisposed();
  164. dnn_Image2BlobParams_set_1ddepth_10(nativeObj, ddepth);
  165. }
  166. //
  167. // C++: DataLayout Image2BlobParams::datalayout
  168. //
  169. // Return type 'DataLayout' is not supported, skipping the function
  170. //
  171. // C++: void Image2BlobParams::datalayout
  172. //
  173. // Unknown type 'DataLayout' (I), skipping the function
  174. //
  175. // C++: ImagePaddingMode Image2BlobParams::paddingmode
  176. //
  177. // Return type 'ImagePaddingMode' is not supported, skipping the function
  178. //
  179. // C++: void Image2BlobParams::paddingmode
  180. //
  181. // Unknown type 'ImagePaddingMode' (I), skipping the function
  182. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  183. const string LIBNAME = "__Internal";
  184. #else
  185. const string LIBNAME = "opencvforunity";
  186. #endif
  187. // C++: cv::dnn::Image2BlobParams::Image2BlobParams()
  188. [DllImport(LIBNAME)]
  189. private static extern IntPtr dnn_Image2BlobParams_Image2BlobParams_10();
  190. // C++: cv::dnn::Image2BlobParams::Image2BlobParams(Scalar scalefactor, Size size = Size(), Scalar mean = Scalar(), bool swapRB = false, int ddepth = CV_32F, DataLayout datalayout = DNN_LAYOUT_NCHW, ImagePaddingMode mode = DNN_PMODE_NULL)
  191. [DllImport(LIBNAME)]
  192. private static extern IntPtr dnn_Image2BlobParams_Image2BlobParams_11(double scalefactor_val0, double scalefactor_val1, double scalefactor_val2, double scalefactor_val3, double size_width, double size_height, double mean_val0, double mean_val1, double mean_val2, double mean_val3, [MarshalAs(UnmanagedType.U1)] bool swapRB, int ddepth);
  193. [DllImport(LIBNAME)]
  194. private static extern IntPtr dnn_Image2BlobParams_Image2BlobParams_14(double scalefactor_val0, double scalefactor_val1, double scalefactor_val2, double scalefactor_val3, double size_width, double size_height, double mean_val0, double mean_val1, double mean_val2, double mean_val3, [MarshalAs(UnmanagedType.U1)] bool swapRB);
  195. [DllImport(LIBNAME)]
  196. private static extern IntPtr dnn_Image2BlobParams_Image2BlobParams_15(double scalefactor_val0, double scalefactor_val1, double scalefactor_val2, double scalefactor_val3, double size_width, double size_height, double mean_val0, double mean_val1, double mean_val2, double mean_val3);
  197. [DllImport(LIBNAME)]
  198. private static extern IntPtr dnn_Image2BlobParams_Image2BlobParams_16(double scalefactor_val0, double scalefactor_val1, double scalefactor_val2, double scalefactor_val3, double size_width, double size_height);
  199. [DllImport(LIBNAME)]
  200. private static extern IntPtr dnn_Image2BlobParams_Image2BlobParams_17(double scalefactor_val0, double scalefactor_val1, double scalefactor_val2, double scalefactor_val3);
  201. // C++: Scalar Image2BlobParams::scalefactor
  202. [DllImport(LIBNAME)]
  203. private static extern void dnn_Image2BlobParams_get_1scalefactor_10(IntPtr nativeObj, double[] retVal);
  204. // C++: void Image2BlobParams::scalefactor
  205. [DllImport(LIBNAME)]
  206. private static extern void dnn_Image2BlobParams_set_1scalefactor_10(IntPtr nativeObj, double scalefactor_val0, double scalefactor_val1, double scalefactor_val2, double scalefactor_val3);
  207. // C++: Size Image2BlobParams::size
  208. [DllImport(LIBNAME)]
  209. private static extern void dnn_Image2BlobParams_get_1size_10(IntPtr nativeObj, double[] retVal);
  210. // C++: void Image2BlobParams::size
  211. [DllImport(LIBNAME)]
  212. private static extern void dnn_Image2BlobParams_set_1size_10(IntPtr nativeObj, double size_width, double size_height);
  213. // C++: Scalar Image2BlobParams::mean
  214. [DllImport(LIBNAME)]
  215. private static extern void dnn_Image2BlobParams_get_1mean_10(IntPtr nativeObj, double[] retVal);
  216. // C++: void Image2BlobParams::mean
  217. [DllImport(LIBNAME)]
  218. private static extern void dnn_Image2BlobParams_set_1mean_10(IntPtr nativeObj, double mean_val0, double mean_val1, double mean_val2, double mean_val3);
  219. // C++: bool Image2BlobParams::swapRB
  220. [DllImport(LIBNAME)]
  221. [return: MarshalAs(UnmanagedType.U1)]
  222. private static extern bool dnn_Image2BlobParams_get_1swapRB_10(IntPtr nativeObj);
  223. // C++: void Image2BlobParams::swapRB
  224. [DllImport(LIBNAME)]
  225. private static extern void dnn_Image2BlobParams_set_1swapRB_10(IntPtr nativeObj, [MarshalAs(UnmanagedType.U1)] bool swapRB);
  226. // C++: int Image2BlobParams::ddepth
  227. [DllImport(LIBNAME)]
  228. private static extern int dnn_Image2BlobParams_get_1ddepth_10(IntPtr nativeObj);
  229. // C++: void Image2BlobParams::ddepth
  230. [DllImport(LIBNAME)]
  231. private static extern void dnn_Image2BlobParams_set_1ddepth_10(IntPtr nativeObj, int ddepth);
  232. // native support for java finalize()
  233. [DllImport(LIBNAME)]
  234. private static extern void dnn_Image2BlobParams_delete(IntPtr nativeObj);
  235. }
  236. }
  237. #endif