123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- using OpenCVForUnity.CoreModule;
- using OpenCVForUnity.UtilsModule;
- using System;
- using System.Collections.Generic;
- using System.Runtime.InteropServices;
- namespace OpenCVForUnity.ImgprocModule
- {
- // C++: class CLAHE
- /**
- * Base class for Contrast Limited Adaptive Histogram Equalization.
- */
- public class CLAHE : Algorithm
- {
- protected override void Dispose(bool disposing)
- {
- try
- {
- if (disposing)
- {
- }
- if (IsEnabledDispose)
- {
- if (nativeObj != IntPtr.Zero)
- imgproc_CLAHE_delete(nativeObj);
- nativeObj = IntPtr.Zero;
- }
- }
- finally
- {
- base.Dispose(disposing);
- }
- }
- protected internal CLAHE(IntPtr addr) : base(addr) { }
- // internal usage only
- public static new CLAHE __fromPtr__(IntPtr addr) { return new CLAHE(addr); }
- //
- // C++: void cv::CLAHE::apply(Mat src, Mat& dst)
- //
- /**
- * Equalizes the histogram of a grayscale image using Contrast Limited Adaptive Histogram Equalization.
- *
- * param src Source image of type CV_8UC1 or CV_16UC1.
- * param dst Destination image.
- */
- public void apply(Mat src, Mat dst)
- {
- ThrowIfDisposed();
- if (src != null) src.ThrowIfDisposed();
- if (dst != null) dst.ThrowIfDisposed();
- imgproc_CLAHE_apply_10(nativeObj, src.nativeObj, dst.nativeObj);
- }
- //
- // C++: void cv::CLAHE::setClipLimit(double clipLimit)
- //
- /**
- * Sets threshold for contrast limiting.
- *
- * param clipLimit threshold value.
- */
- public void setClipLimit(double clipLimit)
- {
- ThrowIfDisposed();
- imgproc_CLAHE_setClipLimit_10(nativeObj, clipLimit);
- }
- //
- // C++: double cv::CLAHE::getClipLimit()
- //
- public double getClipLimit()
- {
- ThrowIfDisposed();
- return imgproc_CLAHE_getClipLimit_10(nativeObj);
- }
- //
- // C++: void cv::CLAHE::setTilesGridSize(Size tileGridSize)
- //
- /**
- * Sets size of grid for histogram equalization. Input image will be divided into
- * equally sized rectangular tiles.
- *
- * param tileGridSize defines the number of tiles in row and column.
- */
- public void setTilesGridSize(Size tileGridSize)
- {
- ThrowIfDisposed();
- imgproc_CLAHE_setTilesGridSize_10(nativeObj, tileGridSize.width, tileGridSize.height);
- }
- //
- // C++: Size cv::CLAHE::getTilesGridSize()
- //
- public Size getTilesGridSize()
- {
- ThrowIfDisposed();
- double[] tmpArray = new double[2];
- imgproc_CLAHE_getTilesGridSize_10(nativeObj, tmpArray);
- Size retVal = new Size(tmpArray);
- return retVal;
- }
- //
- // C++: void cv::CLAHE::collectGarbage()
- //
- public void collectGarbage()
- {
- ThrowIfDisposed();
- imgproc_CLAHE_collectGarbage_10(nativeObj);
- }
- #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
- const string LIBNAME = "__Internal";
- #else
- const string LIBNAME = "opencvforunity";
- #endif
- // C++: void cv::CLAHE::apply(Mat src, Mat& dst)
- [DllImport(LIBNAME)]
- private static extern void imgproc_CLAHE_apply_10(IntPtr nativeObj, IntPtr src_nativeObj, IntPtr dst_nativeObj);
- // C++: void cv::CLAHE::setClipLimit(double clipLimit)
- [DllImport(LIBNAME)]
- private static extern void imgproc_CLAHE_setClipLimit_10(IntPtr nativeObj, double clipLimit);
- // C++: double cv::CLAHE::getClipLimit()
- [DllImport(LIBNAME)]
- private static extern double imgproc_CLAHE_getClipLimit_10(IntPtr nativeObj);
- // C++: void cv::CLAHE::setTilesGridSize(Size tileGridSize)
- [DllImport(LIBNAME)]
- private static extern void imgproc_CLAHE_setTilesGridSize_10(IntPtr nativeObj, double tileGridSize_width, double tileGridSize_height);
- // C++: Size cv::CLAHE::getTilesGridSize()
- [DllImport(LIBNAME)]
- private static extern void imgproc_CLAHE_getTilesGridSize_10(IntPtr nativeObj, double[] retVal);
- // C++: void cv::CLAHE::collectGarbage()
- [DllImport(LIBNAME)]
- private static extern void imgproc_CLAHE_collectGarbage_10(IntPtr nativeObj);
- // native support for java finalize()
- [DllImport(LIBNAME)]
- private static extern void imgproc_CLAHE_delete(IntPtr nativeObj);
- }
- }
|