Tonemap.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. using OpenCVForUnity.CoreModule;
  2. using OpenCVForUnity.UtilsModule;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Runtime.InteropServices;
  6. namespace OpenCVForUnity.PhotoModule
  7. {
  8. // C++: class Tonemap
  9. /**
  10. * Base class for tonemapping algorithms - tools that are used to map HDR image to 8-bit range.
  11. */
  12. public class Tonemap : 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. photo_Tonemap_delete(nativeObj);
  25. nativeObj = IntPtr.Zero;
  26. }
  27. }
  28. finally
  29. {
  30. base.Dispose(disposing);
  31. }
  32. }
  33. protected internal Tonemap(IntPtr addr) : base(addr) { }
  34. // internal usage only
  35. public static new Tonemap __fromPtr__(IntPtr addr) { return new Tonemap(addr); }
  36. //
  37. // C++: void cv::Tonemap::process(Mat src, Mat& dst)
  38. //
  39. /**
  40. * Tonemaps image
  41. *
  42. * param src source image - CV_32FC3 Mat (float 32 bits 3 channels)
  43. * param dst destination image - CV_32FC3 Mat with values in [0, 1] range
  44. */
  45. public void process(Mat src, Mat dst)
  46. {
  47. ThrowIfDisposed();
  48. if (src != null) src.ThrowIfDisposed();
  49. if (dst != null) dst.ThrowIfDisposed();
  50. photo_Tonemap_process_10(nativeObj, src.nativeObj, dst.nativeObj);
  51. }
  52. //
  53. // C++: float cv::Tonemap::getGamma()
  54. //
  55. public float getGamma()
  56. {
  57. ThrowIfDisposed();
  58. return photo_Tonemap_getGamma_10(nativeObj);
  59. }
  60. //
  61. // C++: void cv::Tonemap::setGamma(float gamma)
  62. //
  63. public void setGamma(float gamma)
  64. {
  65. ThrowIfDisposed();
  66. photo_Tonemap_setGamma_10(nativeObj, gamma);
  67. }
  68. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  69. const string LIBNAME = "__Internal";
  70. #else
  71. const string LIBNAME = "opencvforunity";
  72. #endif
  73. // C++: void cv::Tonemap::process(Mat src, Mat& dst)
  74. [DllImport(LIBNAME)]
  75. private static extern void photo_Tonemap_process_10(IntPtr nativeObj, IntPtr src_nativeObj, IntPtr dst_nativeObj);
  76. // C++: float cv::Tonemap::getGamma()
  77. [DllImport(LIBNAME)]
  78. private static extern float photo_Tonemap_getGamma_10(IntPtr nativeObj);
  79. // C++: void cv::Tonemap::setGamma(float gamma)
  80. [DllImport(LIBNAME)]
  81. private static extern void photo_Tonemap_setGamma_10(IntPtr nativeObj, float gamma);
  82. // native support for java finalize()
  83. [DllImport(LIBNAME)]
  84. private static extern void photo_Tonemap_delete(IntPtr nativeObj);
  85. }
  86. }