AlignExposures.cs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 AlignExposures
  9. /**
  10. * The base class for algorithms that align images of the same scene with different exposures
  11. */
  12. public class AlignExposures : 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_AlignExposures_delete(nativeObj);
  25. nativeObj = IntPtr.Zero;
  26. }
  27. }
  28. finally
  29. {
  30. base.Dispose(disposing);
  31. }
  32. }
  33. protected internal AlignExposures(IntPtr addr) : base(addr) { }
  34. // internal usage only
  35. public static new AlignExposures __fromPtr__(IntPtr addr) { return new AlignExposures(addr); }
  36. //
  37. // C++: void cv::AlignExposures::process(vector_Mat src, vector_Mat dst, Mat times, Mat response)
  38. //
  39. /**
  40. * Aligns images
  41. *
  42. * param src vector of input images
  43. * param dst vector of aligned images
  44. * param times vector of exposure time values for each image
  45. * param response 256x1 matrix with inverse camera response function for each pixel value, it should
  46. * have the same number of channels as images.
  47. */
  48. public virtual void process(List<Mat> src, List<Mat> dst, Mat times, Mat response)
  49. {
  50. ThrowIfDisposed();
  51. if (times != null) times.ThrowIfDisposed();
  52. if (response != null) response.ThrowIfDisposed();
  53. Mat src_mat = Converters.vector_Mat_to_Mat(src);
  54. Mat dst_mat = Converters.vector_Mat_to_Mat(dst);
  55. photo_AlignExposures_process_10(nativeObj, src_mat.nativeObj, dst_mat.nativeObj, times.nativeObj, response.nativeObj);
  56. }
  57. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  58. const string LIBNAME = "__Internal";
  59. #else
  60. const string LIBNAME = "opencvforunity";
  61. #endif
  62. // C++: void cv::AlignExposures::process(vector_Mat src, vector_Mat dst, Mat times, Mat response)
  63. [DllImport(LIBNAME)]
  64. private static extern void photo_AlignExposures_process_10(IntPtr nativeObj, IntPtr src_mat_nativeObj, IntPtr dst_mat_nativeObj, IntPtr times_nativeObj, IntPtr response_nativeObj);
  65. // native support for java finalize()
  66. [DllImport(LIBNAME)]
  67. private static extern void photo_AlignExposures_delete(IntPtr nativeObj);
  68. }
  69. }