TextDetectorCNN.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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.TextModule
  8. {
  9. // C++: class TextDetectorCNN
  10. //javadoc: TextDetectorCNN
  11. public class TextDetectorCNN : TextDetector
  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. text_TextDetectorCNN_delete (nativeObj);
  22. nativeObj = IntPtr.Zero;
  23. }
  24. } finally {
  25. base.Dispose (disposing);
  26. }
  27. #else
  28. return;
  29. #endif
  30. }
  31. protected internal TextDetectorCNN (IntPtr addr)
  32. : base (addr)
  33. {
  34. }
  35. // internal usage only
  36. public static new TextDetectorCNN __fromPtr__ (IntPtr addr)
  37. {
  38. return new TextDetectorCNN (addr);
  39. }
  40. //
  41. // C++: static Ptr_TextDetectorCNN cv::text::TextDetectorCNN::create(String modelArchFilename, String modelWeightsFilename)
  42. //
  43. //javadoc: TextDetectorCNN::create(modelArchFilename, modelWeightsFilename)
  44. public static TextDetectorCNN create (string modelArchFilename, string modelWeightsFilename)
  45. {
  46. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  47. TextDetectorCNN retVal = TextDetectorCNN.__fromPtr__ (text_TextDetectorCNN_create_10 (modelArchFilename, modelWeightsFilename));
  48. return retVal;
  49. #else
  50. return null;
  51. #endif
  52. }
  53. //
  54. // C++: void cv::text::TextDetectorCNN::detect(Mat inputImage, vector_Rect& Bbox, vector_float& confidence)
  55. //
  56. //javadoc: TextDetectorCNN::detect(inputImage, Bbox, confidence)
  57. public override void detect (Mat inputImage, MatOfRect Bbox, MatOfFloat confidence)
  58. {
  59. ThrowIfDisposed ();
  60. if (inputImage != null)
  61. inputImage.ThrowIfDisposed ();
  62. if (Bbox != null)
  63. Bbox.ThrowIfDisposed ();
  64. if (confidence != null)
  65. confidence.ThrowIfDisposed ();
  66. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  67. Mat Bbox_mat = Bbox;
  68. Mat confidence_mat = confidence;
  69. text_TextDetectorCNN_detect_10 (nativeObj, inputImage.nativeObj, Bbox_mat.nativeObj, confidence_mat.nativeObj);
  70. return;
  71. #else
  72. return;
  73. #endif
  74. }
  75. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  76. const string LIBNAME = "__Internal";
  77. #else
  78. const string LIBNAME = "opencvforunity";
  79. #endif
  80. // C++: static Ptr_TextDetectorCNN cv::text::TextDetectorCNN::create(String modelArchFilename, String modelWeightsFilename)
  81. [DllImport (LIBNAME)]
  82. private static extern IntPtr text_TextDetectorCNN_create_10 (string modelArchFilename, string modelWeightsFilename);
  83. // C++: void cv::text::TextDetectorCNN::detect(Mat inputImage, vector_Rect& Bbox, vector_float& confidence)
  84. [DllImport (LIBNAME)]
  85. private static extern void text_TextDetectorCNN_detect_10 (IntPtr nativeObj, IntPtr inputImage_nativeObj, IntPtr Bbox_mat_nativeObj, IntPtr confidence_mat_nativeObj);
  86. // native support for java finalize()
  87. [DllImport (LIBNAME)]
  88. private static extern void text_TextDetectorCNN_delete (IntPtr nativeObj);
  89. }
  90. }
  91. #endif