Objdetect.cs 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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.ObjdetectModule
  8. {
  9. // C++: class Objdetect
  10. //javadoc: Objdetect
  11. public class Objdetect
  12. {
  13. // C++: enum <unnamed>
  14. public const int CASCADE_DO_CANNY_PRUNING = 1;
  15. public const int CASCADE_SCALE_IMAGE = 2;
  16. public const int CASCADE_FIND_BIGGEST_OBJECT = 4;
  17. public const int CASCADE_DO_ROUGH_SEARCH = 8;
  18. //
  19. // C++: void cv::groupRectangles(vector_Rect& rectList, vector_int& weights, int groupThreshold, double eps = 0.2)
  20. //
  21. //javadoc: groupRectangles(rectList, weights, groupThreshold, eps)
  22. public static void groupRectangles (MatOfRect rectList, MatOfInt weights, int groupThreshold, double eps)
  23. {
  24. if (rectList != null) rectList.ThrowIfDisposed ();
  25. if (weights != null) weights.ThrowIfDisposed ();
  26. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  27. Mat rectList_mat = rectList;
  28. Mat weights_mat = weights;
  29. objdetect_Objdetect_groupRectangles_10(rectList_mat.nativeObj, weights_mat.nativeObj, groupThreshold, eps);
  30. return;
  31. #else
  32. return;
  33. #endif
  34. }
  35. //javadoc: groupRectangles(rectList, weights, groupThreshold)
  36. public static void groupRectangles (MatOfRect rectList, MatOfInt weights, int groupThreshold)
  37. {
  38. if (rectList != null) rectList.ThrowIfDisposed ();
  39. if (weights != null) weights.ThrowIfDisposed ();
  40. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  41. Mat rectList_mat = rectList;
  42. Mat weights_mat = weights;
  43. objdetect_Objdetect_groupRectangles_11(rectList_mat.nativeObj, weights_mat.nativeObj, groupThreshold);
  44. return;
  45. #else
  46. return;
  47. #endif
  48. }
  49. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  50. const string LIBNAME = "__Internal";
  51. #else
  52. const string LIBNAME = "opencvforunity";
  53. #endif
  54. // C++: void cv::groupRectangles(vector_Rect& rectList, vector_int& weights, int groupThreshold, double eps = 0.2)
  55. [DllImport (LIBNAME)]
  56. private static extern void objdetect_Objdetect_groupRectangles_10 (IntPtr rectList_mat_nativeObj, IntPtr weights_mat_nativeObj, int groupThreshold, double eps);
  57. [DllImport (LIBNAME)]
  58. private static extern void objdetect_Objdetect_groupRectangles_11 (IntPtr rectList_mat_nativeObj, IntPtr weights_mat_nativeObj, int groupThreshold);
  59. }
  60. }