123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577 |
- using OpenCVForUnity.CoreModule;
- using OpenCVForUnity.UtilsModule;
- using System;
- using System.Collections.Generic;
- using System.Runtime.InteropServices;
- namespace OpenCVForUnity.VideoModule
- {
- // C++: class DISOpticalFlow
- /**
- * DIS optical flow algorithm.
- *
- * This class implements the Dense Inverse Search (DIS) optical flow algorithm. More
- * details about the algorithm can be found at CITE: Kroeger2016 . Includes three presets with preselected
- * parameters to provide reasonable trade-off between speed and quality. However, even the slowest preset is
- * still relatively fast, use DeepFlow if you need better quality and don't care about speed.
- *
- * This implementation includes several additional features compared to the algorithm described in the paper,
- * including spatial propagation of flow vectors (REF: getUseSpatialPropagation), as well as an option to
- * utilize an initial flow approximation passed to REF: calc (which is, essentially, temporal propagation,
- * if the previous frame's flow field is passed).
- */
- public class DISOpticalFlow : DenseOpticalFlow
- {
- protected override void Dispose(bool disposing)
- {
- try
- {
- if (disposing)
- {
- }
- if (IsEnabledDispose)
- {
- if (nativeObj != IntPtr.Zero)
- video_DISOpticalFlow_delete(nativeObj);
- nativeObj = IntPtr.Zero;
- }
- }
- finally
- {
- base.Dispose(disposing);
- }
- }
- protected internal DISOpticalFlow(IntPtr addr) : base(addr) { }
- // internal usage only
- public static new DISOpticalFlow __fromPtr__(IntPtr addr) { return new DISOpticalFlow(addr); }
- // C++: enum <unnamed>
- public const int PRESET_ULTRAFAST = 0;
- public const int PRESET_FAST = 1;
- public const int PRESET_MEDIUM = 2;
- //
- // C++: int cv::DISOpticalFlow::getFinestScale()
- //
- /**
- * Finest level of the Gaussian pyramid on which the flow is computed (zero level
- * corresponds to the original image resolution). The final flow is obtained by bilinear upscaling.
- * SEE: setFinestScale
- * return automatically generated
- */
- public int getFinestScale()
- {
- ThrowIfDisposed();
- return video_DISOpticalFlow_getFinestScale_10(nativeObj);
- }
- //
- // C++: void cv::DISOpticalFlow::setFinestScale(int val)
- //
- /**
- * getFinestScale SEE: getFinestScale
- * param val automatically generated
- */
- public void setFinestScale(int val)
- {
- ThrowIfDisposed();
- video_DISOpticalFlow_setFinestScale_10(nativeObj, val);
- }
- //
- // C++: int cv::DISOpticalFlow::getPatchSize()
- //
- /**
- * Size of an image patch for matching (in pixels). Normally, default 8x8 patches work well
- * enough in most cases.
- * SEE: setPatchSize
- * return automatically generated
- */
- public int getPatchSize()
- {
- ThrowIfDisposed();
- return video_DISOpticalFlow_getPatchSize_10(nativeObj);
- }
- //
- // C++: void cv::DISOpticalFlow::setPatchSize(int val)
- //
- /**
- * getPatchSize SEE: getPatchSize
- * param val automatically generated
- */
- public void setPatchSize(int val)
- {
- ThrowIfDisposed();
- video_DISOpticalFlow_setPatchSize_10(nativeObj, val);
- }
- //
- // C++: int cv::DISOpticalFlow::getPatchStride()
- //
- /**
- * Stride between neighbor patches. Must be less than patch size. Lower values correspond
- * to higher flow quality.
- * SEE: setPatchStride
- * return automatically generated
- */
- public int getPatchStride()
- {
- ThrowIfDisposed();
- return video_DISOpticalFlow_getPatchStride_10(nativeObj);
- }
- //
- // C++: void cv::DISOpticalFlow::setPatchStride(int val)
- //
- /**
- * getPatchStride SEE: getPatchStride
- * param val automatically generated
- */
- public void setPatchStride(int val)
- {
- ThrowIfDisposed();
- video_DISOpticalFlow_setPatchStride_10(nativeObj, val);
- }
- //
- // C++: int cv::DISOpticalFlow::getGradientDescentIterations()
- //
- /**
- * Maximum number of gradient descent iterations in the patch inverse search stage. Higher values
- * may improve quality in some cases.
- * SEE: setGradientDescentIterations
- * return automatically generated
- */
- public int getGradientDescentIterations()
- {
- ThrowIfDisposed();
- return video_DISOpticalFlow_getGradientDescentIterations_10(nativeObj);
- }
- //
- // C++: void cv::DISOpticalFlow::setGradientDescentIterations(int val)
- //
- /**
- * getGradientDescentIterations SEE: getGradientDescentIterations
- * param val automatically generated
- */
- public void setGradientDescentIterations(int val)
- {
- ThrowIfDisposed();
- video_DISOpticalFlow_setGradientDescentIterations_10(nativeObj, val);
- }
- //
- // C++: int cv::DISOpticalFlow::getVariationalRefinementIterations()
- //
- /**
- * Number of fixed point iterations of variational refinement per scale. Set to zero to
- * disable variational refinement completely. Higher values will typically result in more smooth and
- * high-quality flow.
- * SEE: setGradientDescentIterations
- * return automatically generated
- */
- public int getVariationalRefinementIterations()
- {
- ThrowIfDisposed();
- return video_DISOpticalFlow_getVariationalRefinementIterations_10(nativeObj);
- }
- //
- // C++: void cv::DISOpticalFlow::setVariationalRefinementIterations(int val)
- //
- /**
- * getGradientDescentIterations SEE: getGradientDescentIterations
- * param val automatically generated
- */
- public void setVariationalRefinementIterations(int val)
- {
- ThrowIfDisposed();
- video_DISOpticalFlow_setVariationalRefinementIterations_10(nativeObj, val);
- }
- //
- // C++: float cv::DISOpticalFlow::getVariationalRefinementAlpha()
- //
- /**
- * Weight of the smoothness term
- * SEE: setVariationalRefinementAlpha
- * return automatically generated
- */
- public float getVariationalRefinementAlpha()
- {
- ThrowIfDisposed();
- return video_DISOpticalFlow_getVariationalRefinementAlpha_10(nativeObj);
- }
- //
- // C++: void cv::DISOpticalFlow::setVariationalRefinementAlpha(float val)
- //
- /**
- * getVariationalRefinementAlpha SEE: getVariationalRefinementAlpha
- * param val automatically generated
- */
- public void setVariationalRefinementAlpha(float val)
- {
- ThrowIfDisposed();
- video_DISOpticalFlow_setVariationalRefinementAlpha_10(nativeObj, val);
- }
- //
- // C++: float cv::DISOpticalFlow::getVariationalRefinementDelta()
- //
- /**
- * Weight of the color constancy term
- * SEE: setVariationalRefinementDelta
- * return automatically generated
- */
- public float getVariationalRefinementDelta()
- {
- ThrowIfDisposed();
- return video_DISOpticalFlow_getVariationalRefinementDelta_10(nativeObj);
- }
- //
- // C++: void cv::DISOpticalFlow::setVariationalRefinementDelta(float val)
- //
- /**
- * getVariationalRefinementDelta SEE: getVariationalRefinementDelta
- * param val automatically generated
- */
- public void setVariationalRefinementDelta(float val)
- {
- ThrowIfDisposed();
- video_DISOpticalFlow_setVariationalRefinementDelta_10(nativeObj, val);
- }
- //
- // C++: float cv::DISOpticalFlow::getVariationalRefinementGamma()
- //
- /**
- * Weight of the gradient constancy term
- * SEE: setVariationalRefinementGamma
- * return automatically generated
- */
- public float getVariationalRefinementGamma()
- {
- ThrowIfDisposed();
- return video_DISOpticalFlow_getVariationalRefinementGamma_10(nativeObj);
- }
- //
- // C++: void cv::DISOpticalFlow::setVariationalRefinementGamma(float val)
- //
- /**
- * getVariationalRefinementGamma SEE: getVariationalRefinementGamma
- * param val automatically generated
- */
- public void setVariationalRefinementGamma(float val)
- {
- ThrowIfDisposed();
- video_DISOpticalFlow_setVariationalRefinementGamma_10(nativeObj, val);
- }
- //
- // C++: bool cv::DISOpticalFlow::getUseMeanNormalization()
- //
- /**
- * Whether to use mean-normalization of patches when computing patch distance. It is turned on
- * by default as it typically provides a noticeable quality boost because of increased robustness to
- * illumination variations. Turn it off if you are certain that your sequence doesn't contain any changes
- * in illumination.
- * SEE: setUseMeanNormalization
- * return automatically generated
- */
- public bool getUseMeanNormalization()
- {
- ThrowIfDisposed();
- return video_DISOpticalFlow_getUseMeanNormalization_10(nativeObj);
- }
- //
- // C++: void cv::DISOpticalFlow::setUseMeanNormalization(bool val)
- //
- /**
- * getUseMeanNormalization SEE: getUseMeanNormalization
- * param val automatically generated
- */
- public void setUseMeanNormalization(bool val)
- {
- ThrowIfDisposed();
- video_DISOpticalFlow_setUseMeanNormalization_10(nativeObj, val);
- }
- //
- // C++: bool cv::DISOpticalFlow::getUseSpatialPropagation()
- //
- /**
- * Whether to use spatial propagation of good optical flow vectors. This option is turned on by
- * default, as it tends to work better on average and can sometimes help recover from major errors
- * introduced by the coarse-to-fine scheme employed by the DIS optical flow algorithm. Turning this
- * option off can make the output flow field a bit smoother, however.
- * SEE: setUseSpatialPropagation
- * return automatically generated
- */
- public bool getUseSpatialPropagation()
- {
- ThrowIfDisposed();
- return video_DISOpticalFlow_getUseSpatialPropagation_10(nativeObj);
- }
- //
- // C++: void cv::DISOpticalFlow::setUseSpatialPropagation(bool val)
- //
- /**
- * getUseSpatialPropagation SEE: getUseSpatialPropagation
- * param val automatically generated
- */
- public void setUseSpatialPropagation(bool val)
- {
- ThrowIfDisposed();
- video_DISOpticalFlow_setUseSpatialPropagation_10(nativeObj, val);
- }
- //
- // C++: static Ptr_DISOpticalFlow cv::DISOpticalFlow::create(int preset = DISOpticalFlow::PRESET_FAST)
- //
- /**
- * Creates an instance of DISOpticalFlow
- *
- * param preset one of PRESET_ULTRAFAST, PRESET_FAST and PRESET_MEDIUM
- * return automatically generated
- */
- public static DISOpticalFlow create(int preset)
- {
- return DISOpticalFlow.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(video_DISOpticalFlow_create_10(preset)));
- }
- /**
- * Creates an instance of DISOpticalFlow
- *
- * return automatically generated
- */
- public static DISOpticalFlow create()
- {
- return DISOpticalFlow.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(video_DISOpticalFlow_create_11()));
- }
- #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
- const string LIBNAME = "__Internal";
- #else
- const string LIBNAME = "opencvforunity";
- #endif
- // C++: int cv::DISOpticalFlow::getFinestScale()
- [DllImport(LIBNAME)]
- private static extern int video_DISOpticalFlow_getFinestScale_10(IntPtr nativeObj);
- // C++: void cv::DISOpticalFlow::setFinestScale(int val)
- [DllImport(LIBNAME)]
- private static extern void video_DISOpticalFlow_setFinestScale_10(IntPtr nativeObj, int val);
- // C++: int cv::DISOpticalFlow::getPatchSize()
- [DllImport(LIBNAME)]
- private static extern int video_DISOpticalFlow_getPatchSize_10(IntPtr nativeObj);
- // C++: void cv::DISOpticalFlow::setPatchSize(int val)
- [DllImport(LIBNAME)]
- private static extern void video_DISOpticalFlow_setPatchSize_10(IntPtr nativeObj, int val);
- // C++: int cv::DISOpticalFlow::getPatchStride()
- [DllImport(LIBNAME)]
- private static extern int video_DISOpticalFlow_getPatchStride_10(IntPtr nativeObj);
- // C++: void cv::DISOpticalFlow::setPatchStride(int val)
- [DllImport(LIBNAME)]
- private static extern void video_DISOpticalFlow_setPatchStride_10(IntPtr nativeObj, int val);
- // C++: int cv::DISOpticalFlow::getGradientDescentIterations()
- [DllImport(LIBNAME)]
- private static extern int video_DISOpticalFlow_getGradientDescentIterations_10(IntPtr nativeObj);
- // C++: void cv::DISOpticalFlow::setGradientDescentIterations(int val)
- [DllImport(LIBNAME)]
- private static extern void video_DISOpticalFlow_setGradientDescentIterations_10(IntPtr nativeObj, int val);
- // C++: int cv::DISOpticalFlow::getVariationalRefinementIterations()
- [DllImport(LIBNAME)]
- private static extern int video_DISOpticalFlow_getVariationalRefinementIterations_10(IntPtr nativeObj);
- // C++: void cv::DISOpticalFlow::setVariationalRefinementIterations(int val)
- [DllImport(LIBNAME)]
- private static extern void video_DISOpticalFlow_setVariationalRefinementIterations_10(IntPtr nativeObj, int val);
- // C++: float cv::DISOpticalFlow::getVariationalRefinementAlpha()
- [DllImport(LIBNAME)]
- private static extern float video_DISOpticalFlow_getVariationalRefinementAlpha_10(IntPtr nativeObj);
- // C++: void cv::DISOpticalFlow::setVariationalRefinementAlpha(float val)
- [DllImport(LIBNAME)]
- private static extern void video_DISOpticalFlow_setVariationalRefinementAlpha_10(IntPtr nativeObj, float val);
- // C++: float cv::DISOpticalFlow::getVariationalRefinementDelta()
- [DllImport(LIBNAME)]
- private static extern float video_DISOpticalFlow_getVariationalRefinementDelta_10(IntPtr nativeObj);
- // C++: void cv::DISOpticalFlow::setVariationalRefinementDelta(float val)
- [DllImport(LIBNAME)]
- private static extern void video_DISOpticalFlow_setVariationalRefinementDelta_10(IntPtr nativeObj, float val);
- // C++: float cv::DISOpticalFlow::getVariationalRefinementGamma()
- [DllImport(LIBNAME)]
- private static extern float video_DISOpticalFlow_getVariationalRefinementGamma_10(IntPtr nativeObj);
- // C++: void cv::DISOpticalFlow::setVariationalRefinementGamma(float val)
- [DllImport(LIBNAME)]
- private static extern void video_DISOpticalFlow_setVariationalRefinementGamma_10(IntPtr nativeObj, float val);
- // C++: bool cv::DISOpticalFlow::getUseMeanNormalization()
- [DllImport(LIBNAME)]
- [return: MarshalAs(UnmanagedType.U1)]
- private static extern bool video_DISOpticalFlow_getUseMeanNormalization_10(IntPtr nativeObj);
- // C++: void cv::DISOpticalFlow::setUseMeanNormalization(bool val)
- [DllImport(LIBNAME)]
- private static extern void video_DISOpticalFlow_setUseMeanNormalization_10(IntPtr nativeObj, [MarshalAs(UnmanagedType.U1)] bool val);
- // C++: bool cv::DISOpticalFlow::getUseSpatialPropagation()
- [DllImport(LIBNAME)]
- [return: MarshalAs(UnmanagedType.U1)]
- private static extern bool video_DISOpticalFlow_getUseSpatialPropagation_10(IntPtr nativeObj);
- // C++: void cv::DISOpticalFlow::setUseSpatialPropagation(bool val)
- [DllImport(LIBNAME)]
- private static extern void video_DISOpticalFlow_setUseSpatialPropagation_10(IntPtr nativeObj, [MarshalAs(UnmanagedType.U1)] bool val);
- // C++: static Ptr_DISOpticalFlow cv::DISOpticalFlow::create(int preset = DISOpticalFlow::PRESET_FAST)
- [DllImport(LIBNAME)]
- private static extern IntPtr video_DISOpticalFlow_create_10(int preset);
- [DllImport(LIBNAME)]
- private static extern IntPtr video_DISOpticalFlow_create_11();
- // native support for java finalize()
- [DllImport(LIBNAME)]
- private static extern void video_DISOpticalFlow_delete(IntPtr nativeObj);
- }
- }
|