123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295 |
- using OpenCVForUnity.CoreModule;
- using OpenCVForUnity.UtilsModule;
- using OpenCVForUnity.VideoModule;
- using System;
- using System.Collections.Generic;
- using System.Runtime.InteropServices;
- namespace OpenCVForUnity.BgsegmModule
- {
- // C++: class BackgroundSubtractorCNT
- /**
- * Background subtraction based on counting.
- *
- * About as fast as MOG2 on a high end system.
- * More than twice faster than MOG2 on cheap hardware (benchmarked on Raspberry Pi3).
- *
- * %Algorithm by Sagi Zeevi ( https://github.com/sagi-z/BackgroundSubtractorCNT )
- */
- public class BackgroundSubtractorCNT : BackgroundSubtractor
- {
- protected override void Dispose(bool disposing)
- {
- try
- {
- if (disposing)
- {
- }
- if (IsEnabledDispose)
- {
- if (nativeObj != IntPtr.Zero)
- bgsegm_BackgroundSubtractorCNT_delete(nativeObj);
- nativeObj = IntPtr.Zero;
- }
- }
- finally
- {
- base.Dispose(disposing);
- }
- }
- protected internal BackgroundSubtractorCNT(IntPtr addr) : base(addr) { }
- // internal usage only
- public static new BackgroundSubtractorCNT __fromPtr__(IntPtr addr) { return new BackgroundSubtractorCNT(addr); }
- //
- // C++: void cv::bgsegm::BackgroundSubtractorCNT::apply(Mat image, Mat& fgmask, double learningRate = -1)
- //
- public override void apply(Mat image, Mat fgmask, double learningRate)
- {
- ThrowIfDisposed();
- if (image != null) image.ThrowIfDisposed();
- if (fgmask != null) fgmask.ThrowIfDisposed();
- bgsegm_BackgroundSubtractorCNT_apply_10(nativeObj, image.nativeObj, fgmask.nativeObj, learningRate);
- }
- public override void apply(Mat image, Mat fgmask)
- {
- ThrowIfDisposed();
- if (image != null) image.ThrowIfDisposed();
- if (fgmask != null) fgmask.ThrowIfDisposed();
- bgsegm_BackgroundSubtractorCNT_apply_11(nativeObj, image.nativeObj, fgmask.nativeObj);
- }
- //
- // C++: void cv::bgsegm::BackgroundSubtractorCNT::getBackgroundImage(Mat& backgroundImage)
- //
- public override void getBackgroundImage(Mat backgroundImage)
- {
- ThrowIfDisposed();
- if (backgroundImage != null) backgroundImage.ThrowIfDisposed();
- bgsegm_BackgroundSubtractorCNT_getBackgroundImage_10(nativeObj, backgroundImage.nativeObj);
- }
- //
- // C++: int cv::bgsegm::BackgroundSubtractorCNT::getMinPixelStability()
- //
- /**
- * Returns number of frames with same pixel color to consider stable.
- * return automatically generated
- */
- public int getMinPixelStability()
- {
- ThrowIfDisposed();
- return bgsegm_BackgroundSubtractorCNT_getMinPixelStability_10(nativeObj);
- }
- //
- // C++: void cv::bgsegm::BackgroundSubtractorCNT::setMinPixelStability(int value)
- //
- /**
- * Sets the number of frames with same pixel color to consider stable.
- * param value automatically generated
- */
- public void setMinPixelStability(int value)
- {
- ThrowIfDisposed();
- bgsegm_BackgroundSubtractorCNT_setMinPixelStability_10(nativeObj, value);
- }
- //
- // C++: int cv::bgsegm::BackgroundSubtractorCNT::getMaxPixelStability()
- //
- /**
- * Returns maximum allowed credit for a pixel in history.
- * return automatically generated
- */
- public int getMaxPixelStability()
- {
- ThrowIfDisposed();
- return bgsegm_BackgroundSubtractorCNT_getMaxPixelStability_10(nativeObj);
- }
- //
- // C++: void cv::bgsegm::BackgroundSubtractorCNT::setMaxPixelStability(int value)
- //
- /**
- * Sets the maximum allowed credit for a pixel in history.
- * param value automatically generated
- */
- public void setMaxPixelStability(int value)
- {
- ThrowIfDisposed();
- bgsegm_BackgroundSubtractorCNT_setMaxPixelStability_10(nativeObj, value);
- }
- //
- // C++: bool cv::bgsegm::BackgroundSubtractorCNT::getUseHistory()
- //
- /**
- * Returns if we're giving a pixel credit for being stable for a long time.
- * return automatically generated
- */
- public bool getUseHistory()
- {
- ThrowIfDisposed();
- return bgsegm_BackgroundSubtractorCNT_getUseHistory_10(nativeObj);
- }
- //
- // C++: void cv::bgsegm::BackgroundSubtractorCNT::setUseHistory(bool value)
- //
- /**
- * Sets if we're giving a pixel credit for being stable for a long time.
- * param value automatically generated
- */
- public void setUseHistory(bool value)
- {
- ThrowIfDisposed();
- bgsegm_BackgroundSubtractorCNT_setUseHistory_10(nativeObj, value);
- }
- //
- // C++: bool cv::bgsegm::BackgroundSubtractorCNT::getIsParallel()
- //
- /**
- * Returns if we're parallelizing the algorithm.
- * return automatically generated
- */
- public bool getIsParallel()
- {
- ThrowIfDisposed();
- return bgsegm_BackgroundSubtractorCNT_getIsParallel_10(nativeObj);
- }
- //
- // C++: void cv::bgsegm::BackgroundSubtractorCNT::setIsParallel(bool value)
- //
- /**
- * Sets if we're parallelizing the algorithm.
- * param value automatically generated
- */
- public void setIsParallel(bool value)
- {
- ThrowIfDisposed();
- bgsegm_BackgroundSubtractorCNT_setIsParallel_10(nativeObj, value);
- }
- #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
- const string LIBNAME = "__Internal";
- #else
- const string LIBNAME = "opencvforunity";
- #endif
- // C++: void cv::bgsegm::BackgroundSubtractorCNT::apply(Mat image, Mat& fgmask, double learningRate = -1)
- [DllImport(LIBNAME)]
- private static extern void bgsegm_BackgroundSubtractorCNT_apply_10(IntPtr nativeObj, IntPtr image_nativeObj, IntPtr fgmask_nativeObj, double learningRate);
- [DllImport(LIBNAME)]
- private static extern void bgsegm_BackgroundSubtractorCNT_apply_11(IntPtr nativeObj, IntPtr image_nativeObj, IntPtr fgmask_nativeObj);
- // C++: void cv::bgsegm::BackgroundSubtractorCNT::getBackgroundImage(Mat& backgroundImage)
- [DllImport(LIBNAME)]
- private static extern void bgsegm_BackgroundSubtractorCNT_getBackgroundImage_10(IntPtr nativeObj, IntPtr backgroundImage_nativeObj);
- // C++: int cv::bgsegm::BackgroundSubtractorCNT::getMinPixelStability()
- [DllImport(LIBNAME)]
- private static extern int bgsegm_BackgroundSubtractorCNT_getMinPixelStability_10(IntPtr nativeObj);
- // C++: void cv::bgsegm::BackgroundSubtractorCNT::setMinPixelStability(int value)
- [DllImport(LIBNAME)]
- private static extern void bgsegm_BackgroundSubtractorCNT_setMinPixelStability_10(IntPtr nativeObj, int value);
- // C++: int cv::bgsegm::BackgroundSubtractorCNT::getMaxPixelStability()
- [DllImport(LIBNAME)]
- private static extern int bgsegm_BackgroundSubtractorCNT_getMaxPixelStability_10(IntPtr nativeObj);
- // C++: void cv::bgsegm::BackgroundSubtractorCNT::setMaxPixelStability(int value)
- [DllImport(LIBNAME)]
- private static extern void bgsegm_BackgroundSubtractorCNT_setMaxPixelStability_10(IntPtr nativeObj, int value);
- // C++: bool cv::bgsegm::BackgroundSubtractorCNT::getUseHistory()
- [DllImport(LIBNAME)]
- [return: MarshalAs(UnmanagedType.U1)]
- private static extern bool bgsegm_BackgroundSubtractorCNT_getUseHistory_10(IntPtr nativeObj);
- // C++: void cv::bgsegm::BackgroundSubtractorCNT::setUseHistory(bool value)
- [DllImport(LIBNAME)]
- private static extern void bgsegm_BackgroundSubtractorCNT_setUseHistory_10(IntPtr nativeObj, [MarshalAs(UnmanagedType.U1)] bool value);
- // C++: bool cv::bgsegm::BackgroundSubtractorCNT::getIsParallel()
- [DllImport(LIBNAME)]
- [return: MarshalAs(UnmanagedType.U1)]
- private static extern bool bgsegm_BackgroundSubtractorCNT_getIsParallel_10(IntPtr nativeObj);
- // C++: void cv::bgsegm::BackgroundSubtractorCNT::setIsParallel(bool value)
- [DllImport(LIBNAME)]
- private static extern void bgsegm_BackgroundSubtractorCNT_setIsParallel_10(IntPtr nativeObj, [MarshalAs(UnmanagedType.U1)] bool value);
- // native support for java finalize()
- [DllImport(LIBNAME)]
- private static extern void bgsegm_BackgroundSubtractorCNT_delete(IntPtr nativeObj);
- }
- }
|