/// <summary> /// Create a MOG foreground detector /// </summary> /// <param name="parameter">The MOG foreground detector parameters</param> public FGDetector(MCvGaussBGStatModelParams parameter) { IntPtr p = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(MCvGaussBGStatModelParams))); Marshal.StructureToPtr(parameter, p, false); _ptr = FGDetectorInvoke.CvCreateFGDetectorBase(CvEnum.ForgroundDetectorType.Mog, p); Marshal.FreeHGlobal(p); }
/// <summary> /// Create a MOG foreground detector /// </summary> /// <param name="parameter">The MOG foreground detector parameters</param> public FGDetector(MCvGaussBGStatModelParams parameter) { IntPtr p = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(MCvGaussBGStatModelParams))); Marshal.StructureToPtr(parameter, p, false); _ptr = FGDetectorInvoke.CvCreateFGDetectorBase(CvEnum.FORGROUND_DETECTOR_TYPE.MOG, p); Marshal.FreeHGlobal(p); }
/// <summary> /// Create a foreground detector of the specific type /// </summary> /// <param name="type">The type of the detector to be created. Should be either FGD ot FGD_SIMPLE</param> /// <param name="parameter">The FGD parameters</param> public FGDetector(CvEnum.ForgroundDetectorType type, MCvFGDStatModelParams parameter) { if (type == CvEnum.ForgroundDetectorType.Fgd || type == CvEnum.ForgroundDetectorType.FgdSimple) { IntPtr p = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(MCvFGDStatModelParams))); Marshal.StructureToPtr(parameter, p, false); _ptr = FGDetectorInvoke.CvCreateFGDetectorBase(type, p); Marshal.FreeHGlobal(p); } else { throw new ArgumentException("This constructor only accepts detector type of either FGD or FGD_SIMPLE"); } }
/// <summary> /// Release the foreground detector /// </summary> protected override void DisposeObject() { FGDetectorInvoke.CvFGDetectorRelease(_ptr); }
/// <summary> /// Update the foreground detector using the specific image /// </summary> /// <param name="image">The image which will be used to update the FGDetector</param> public void Update(Image <TColor, Byte> image) { FGDetectorInvoke.CvFGDetectorProcess(_ptr, image.Ptr); }
/// <summary> /// Create a foreground detector of the specific type /// </summary> /// <param name="type">The type of the detector to be created</param> public FGDetector(CvEnum.ForgroundDetectorType type) { _ptr = FGDetectorInvoke.CvCreateFGDetectorBase(type, IntPtr.Zero); }
/// <summary> /// Create a foreground detector of the specific type /// </summary> /// <param name="type">The type of the detector to be created</param> public FGDetector(CvEnum.FORGROUND_DETECTOR_TYPE type) { _ptr = FGDetectorInvoke.CvCreateFGDetectorBase(type, IntPtr.Zero); }