123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300 |
- using OpenCVForUnity.CoreModule;
- using OpenCVForUnity.Features2dModule;
- using OpenCVForUnity.UtilsModule;
- using System;
- using System.Collections.Generic;
- using System.Runtime.InteropServices;
- namespace OpenCVForUnity.Xfeatures2dModule
- {
- // C++: class LATCH
- /**
- * latch Class for computing the LATCH descriptor.
- * If you find this code useful, please add a reference to the following paper in your work:
- * Gil Levi and Tal Hassner, "LATCH: Learned Arrangements of Three Patch Codes", arXiv preprint arXiv:1501.03719, 15 Jan. 2015
- *
- * LATCH is a binary descriptor based on learned comparisons of triplets of image patches.
- *
- * bytes is the size of the descriptor - can be 64, 32, 16, 8, 4, 2 or 1
- * rotationInvariance - whether or not the descriptor should compansate for orientation changes.
- * half_ssd_size - the size of half of the mini-patches size. For example, if we would like to compare triplets of patches of size 7x7x
- * then the half_ssd_size should be (7-1)/2 = 3.
- * sigma - sigma value for GaussianBlur smoothing of the source image. Source image will be used without smoothing in case sigma value is 0.
- *
- * Note: the descriptor can be coupled with any keypoint extractor. The only demand is that if you use set rotationInvariance = True then
- * you will have to use an extractor which estimates the patch orientation (in degrees). Examples for such extractors are ORB and SIFT.
- *
- * Note: a complete example can be found under /samples/cpp/tutorial_code/xfeatures2D/latch_match.cpp
- */
- public class LATCH : Feature2D
- {
- protected override void Dispose(bool disposing)
- {
- try
- {
- if (disposing)
- {
- }
- if (IsEnabledDispose)
- {
- if (nativeObj != IntPtr.Zero)
- xfeatures2d_LATCH_delete(nativeObj);
- nativeObj = IntPtr.Zero;
- }
- }
- finally
- {
- base.Dispose(disposing);
- }
- }
- protected internal LATCH(IntPtr addr) : base(addr) { }
- // internal usage only
- public static new LATCH __fromPtr__(IntPtr addr) { return new LATCH(addr); }
- //
- // C++: static Ptr_LATCH cv::xfeatures2d::LATCH::create(int bytes = 32, bool rotationInvariance = true, int half_ssd_size = 3, double sigma = 2.0)
- //
- public static LATCH create(int bytes, bool rotationInvariance, int half_ssd_size, double sigma)
- {
- return LATCH.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(xfeatures2d_LATCH_create_10(bytes, rotationInvariance, half_ssd_size, sigma)));
- }
- public static LATCH create(int bytes, bool rotationInvariance, int half_ssd_size)
- {
- return LATCH.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(xfeatures2d_LATCH_create_11(bytes, rotationInvariance, half_ssd_size)));
- }
- public static LATCH create(int bytes, bool rotationInvariance)
- {
- return LATCH.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(xfeatures2d_LATCH_create_12(bytes, rotationInvariance)));
- }
- public static LATCH create(int bytes)
- {
- return LATCH.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(xfeatures2d_LATCH_create_13(bytes)));
- }
- public static LATCH create()
- {
- return LATCH.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(xfeatures2d_LATCH_create_14()));
- }
- //
- // C++: void cv::xfeatures2d::LATCH::setBytes(int bytes)
- //
- public void setBytes(int bytes)
- {
- ThrowIfDisposed();
- xfeatures2d_LATCH_setBytes_10(nativeObj, bytes);
- }
- //
- // C++: int cv::xfeatures2d::LATCH::getBytes()
- //
- public int getBytes()
- {
- ThrowIfDisposed();
- return xfeatures2d_LATCH_getBytes_10(nativeObj);
- }
- //
- // C++: void cv::xfeatures2d::LATCH::setRotationInvariance(bool rotationInvariance)
- //
- public void setRotationInvariance(bool rotationInvariance)
- {
- ThrowIfDisposed();
- xfeatures2d_LATCH_setRotationInvariance_10(nativeObj, rotationInvariance);
- }
- //
- // C++: bool cv::xfeatures2d::LATCH::getRotationInvariance()
- //
- public bool getRotationInvariance()
- {
- ThrowIfDisposed();
- return xfeatures2d_LATCH_getRotationInvariance_10(nativeObj);
- }
- //
- // C++: void cv::xfeatures2d::LATCH::setHalfSSDsize(int half_ssd_size)
- //
- public void setHalfSSDsize(int half_ssd_size)
- {
- ThrowIfDisposed();
- xfeatures2d_LATCH_setHalfSSDsize_10(nativeObj, half_ssd_size);
- }
- //
- // C++: int cv::xfeatures2d::LATCH::getHalfSSDsize()
- //
- public int getHalfSSDsize()
- {
- ThrowIfDisposed();
- return xfeatures2d_LATCH_getHalfSSDsize_10(nativeObj);
- }
- //
- // C++: void cv::xfeatures2d::LATCH::setSigma(double sigma)
- //
- public void setSigma(double sigma)
- {
- ThrowIfDisposed();
- xfeatures2d_LATCH_setSigma_10(nativeObj, sigma);
- }
- //
- // C++: double cv::xfeatures2d::LATCH::getSigma()
- //
- public double getSigma()
- {
- ThrowIfDisposed();
- return xfeatures2d_LATCH_getSigma_10(nativeObj);
- }
- //
- // C++: String cv::xfeatures2d::LATCH::getDefaultName()
- //
- public override string getDefaultName()
- {
- ThrowIfDisposed();
- string retVal = Marshal.PtrToStringAnsi(DisposableObject.ThrowIfNullIntPtr(xfeatures2d_LATCH_getDefaultName_10(nativeObj)));
- return retVal;
- }
- #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
- const string LIBNAME = "__Internal";
- #else
- const string LIBNAME = "opencvforunity";
- #endif
- // C++: static Ptr_LATCH cv::xfeatures2d::LATCH::create(int bytes = 32, bool rotationInvariance = true, int half_ssd_size = 3, double sigma = 2.0)
- [DllImport(LIBNAME)]
- private static extern IntPtr xfeatures2d_LATCH_create_10(int bytes, [MarshalAs(UnmanagedType.U1)] bool rotationInvariance, int half_ssd_size, double sigma);
- [DllImport(LIBNAME)]
- private static extern IntPtr xfeatures2d_LATCH_create_11(int bytes, [MarshalAs(UnmanagedType.U1)] bool rotationInvariance, int half_ssd_size);
- [DllImport(LIBNAME)]
- private static extern IntPtr xfeatures2d_LATCH_create_12(int bytes, [MarshalAs(UnmanagedType.U1)] bool rotationInvariance);
- [DllImport(LIBNAME)]
- private static extern IntPtr xfeatures2d_LATCH_create_13(int bytes);
- [DllImport(LIBNAME)]
- private static extern IntPtr xfeatures2d_LATCH_create_14();
- // C++: void cv::xfeatures2d::LATCH::setBytes(int bytes)
- [DllImport(LIBNAME)]
- private static extern void xfeatures2d_LATCH_setBytes_10(IntPtr nativeObj, int bytes);
- // C++: int cv::xfeatures2d::LATCH::getBytes()
- [DllImport(LIBNAME)]
- private static extern int xfeatures2d_LATCH_getBytes_10(IntPtr nativeObj);
- // C++: void cv::xfeatures2d::LATCH::setRotationInvariance(bool rotationInvariance)
- [DllImport(LIBNAME)]
- private static extern void xfeatures2d_LATCH_setRotationInvariance_10(IntPtr nativeObj, [MarshalAs(UnmanagedType.U1)] bool rotationInvariance);
- // C++: bool cv::xfeatures2d::LATCH::getRotationInvariance()
- [DllImport(LIBNAME)]
- [return: MarshalAs(UnmanagedType.U1)]
- private static extern bool xfeatures2d_LATCH_getRotationInvariance_10(IntPtr nativeObj);
- // C++: void cv::xfeatures2d::LATCH::setHalfSSDsize(int half_ssd_size)
- [DllImport(LIBNAME)]
- private static extern void xfeatures2d_LATCH_setHalfSSDsize_10(IntPtr nativeObj, int half_ssd_size);
- // C++: int cv::xfeatures2d::LATCH::getHalfSSDsize()
- [DllImport(LIBNAME)]
- private static extern int xfeatures2d_LATCH_getHalfSSDsize_10(IntPtr nativeObj);
- // C++: void cv::xfeatures2d::LATCH::setSigma(double sigma)
- [DllImport(LIBNAME)]
- private static extern void xfeatures2d_LATCH_setSigma_10(IntPtr nativeObj, double sigma);
- // C++: double cv::xfeatures2d::LATCH::getSigma()
- [DllImport(LIBNAME)]
- private static extern double xfeatures2d_LATCH_getSigma_10(IntPtr nativeObj);
- // C++: String cv::xfeatures2d::LATCH::getDefaultName()
- [DllImport(LIBNAME)]
- private static extern IntPtr xfeatures2d_LATCH_getDefaultName_10(IntPtr nativeObj);
- // native support for java finalize()
- [DllImport(LIBNAME)]
- private static extern void xfeatures2d_LATCH_delete(IntPtr nativeObj);
- }
- }
|