WhiteBalancer.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. using OpenCVForUnity.CoreModule;
  2. using OpenCVForUnity.UtilsModule;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Runtime.InteropServices;
  6. namespace OpenCVForUnity.XphotoModule
  7. {
  8. // C++: class WhiteBalancer
  9. /**
  10. * The base class for auto white balance algorithms.
  11. */
  12. public class WhiteBalancer : Algorithm
  13. {
  14. protected override void Dispose(bool disposing)
  15. {
  16. try
  17. {
  18. if (disposing)
  19. {
  20. }
  21. if (IsEnabledDispose)
  22. {
  23. if (nativeObj != IntPtr.Zero)
  24. xphoto_WhiteBalancer_delete(nativeObj);
  25. nativeObj = IntPtr.Zero;
  26. }
  27. }
  28. finally
  29. {
  30. base.Dispose(disposing);
  31. }
  32. }
  33. protected internal WhiteBalancer(IntPtr addr) : base(addr) { }
  34. // internal usage only
  35. public static new WhiteBalancer __fromPtr__(IntPtr addr) { return new WhiteBalancer(addr); }
  36. //
  37. // C++: void cv::xphoto::WhiteBalancer::balanceWhite(Mat src, Mat& dst)
  38. //
  39. /**
  40. * Applies white balancing to the input image
  41. *
  42. * param src Input image
  43. * param dst White balancing result
  44. * SEE: cvtColor, equalizeHist
  45. */
  46. public void balanceWhite(Mat src, Mat dst)
  47. {
  48. ThrowIfDisposed();
  49. if (src != null) src.ThrowIfDisposed();
  50. if (dst != null) dst.ThrowIfDisposed();
  51. xphoto_WhiteBalancer_balanceWhite_10(nativeObj, src.nativeObj, dst.nativeObj);
  52. }
  53. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  54. const string LIBNAME = "__Internal";
  55. #else
  56. const string LIBNAME = "opencvforunity";
  57. #endif
  58. // C++: void cv::xphoto::WhiteBalancer::balanceWhite(Mat src, Mat& dst)
  59. [DllImport(LIBNAME)]
  60. private static extern void xphoto_WhiteBalancer_balanceWhite_10(IntPtr nativeObj, IntPtr src_nativeObj, IntPtr dst_nativeObj);
  61. // native support for java finalize()
  62. [DllImport(LIBNAME)]
  63. private static extern void xphoto_WhiteBalancer_delete(IntPtr nativeObj);
  64. }
  65. }