TextDetectorCNN.cs 3.4 KB

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