/* * This method is called to copy image data from the src frame to the dest frame. * * Depending on the value of m_bEnabled, this implementation applies a binarization or * copies the image data without modifying it. */ public override bool Transform(IFrame src, IFrame dest) { Stopwatch timer = Stopwatch.StartNew(); unsafe { // Check whether the destination frame is available //if (dest.Ptr == null) return false; //dest.CopyFrom(src); IntPtr ptr = (IntPtr)src.Ptr; //if the IntPtr casting was successful, if both pointers have the same address if (ptr.ToPointer() == src.Ptr) { //if input is Y800 format, or 8-bit bit-depth, if (src.FrameType.Subtype.Equals(TIS.Imaging.MediaSubtypes.Y800)) { Mat temp = new Mat(src.FrameType.Size, DepthType.Cv8U, 1, ptr, src.FrameType.BufferSize / src.FrameType.Height); temp.CopyTo(raw); temp.Dispose(); NewFrameHandler?.Invoke(this, new NewFrameEvent(raw)); } //if input is Y16 format or 16-bit bit-depth, else if (src.FrameType.Subtype.Equals(TIS.Imaging.MediaSubtypes.Y16)) { Mat temp = new Mat(src.FrameType.Size, DepthType.Cv16U, 1, ptr, src.FrameType.BufferSize / src.FrameType.Height); temp.CopyTo(raw); temp.Dispose(); NewFrameHandler?.Invoke(this, new NewFrameEvent(raw)); } } } timer.Stop(); TimeSpan timespan = timer.Elapsed; double fps = 1000 / timespan.TotalMilliseconds; timeelapse = fps.ToString(); return(true); }
public abstract void AddOnNewFrame(NewFrameHandler handler);
public override void AddOnNewFrame(NewFrameHandler handler) { newFrameHandlers.Add(handler); }