private FrameSet HandleSingleFrameProcessingBlocks(FrameSet frameSet, FrameSource frameSource, FramesReleaser framesReleaser, RsProcessingBlock videoProcessingBlock, Action <Frame> handleFrame) { // single frame filters List <Frame> processedFrames = new List <Frame>(); foreach (var frame in frameSet) { var currFrame = ApplyFilter(frame, frameSource, framesReleaser, videoProcessingBlock, handleFrame); // cache the pocessed frame processedFrames.Add(currFrame); if (frame != currFrame) { frame.Dispose(); } } // Combine the frames into a single frameset var newFrameSet = frameSource.AllocateCompositeFrame(framesReleaser, processedFrames.ToArray()); foreach (var f in processedFrames) { f.Dispose(); } return(newFrameSet); }
public override Frame Process(Frame frame, FrameSource frameSource, FramesReleaser releaser) { lock (_lock) { using (var frameset = FrameSet.FromFrame(frame)) { using (var depth = frameset.DepthFrame) { using (var texture = frameset.FirstOrDefault <VideoFrame>(_textureStream)) { _videoStreamFilter[depth.Profile.Stream].CopyProfile(depth); _videoStreamFilter[texture.Profile.Stream].CopyProfile(texture); if (_currVideoStreamFilter.Count == 0 || !_currVideoStreamFilter[depth.Profile.Stream].Equals(_videoStreamFilter[depth.Profile.Stream]) || !_currVideoStreamFilter[texture.Profile.Stream].Equals(_videoStreamFilter[texture.Profile.Stream])) { ResetProcessingBlock(); _currVideoStreamFilter[depth.Profile.Stream] = new RsVideoStreamRequest(depth); _currVideoStreamFilter[texture.Profile.Stream] = new RsVideoStreamRequest(texture); } var points = _pb.Calculate(depth, releaser); _pb.MapTexture(texture); return(frameSource.AllocateCompositeFrame(releaser, depth, points).AsFrame()); } } } } }
public override Frame Process(Frame frame, FrameSource frameSource) { if (frame.IsComposite) { using (var fs = FrameSet.FromFrame(frame)) using (var depth = fs.DepthFrame) { var v = ApplyFilter(depth, frameSource); // return v; // find and remove the original depth frame var frames = new List <Frame>(); foreach (var f in fs) { using (var p1 = f.Profile) if (p1.Stream == Stream.Depth && p1.Format == Format.Z16) { f.Dispose(); continue; } frames.Add(f); } frames.Add(v); var res = frameSource.AllocateCompositeFrame(frames); frames.ForEach(f => f.Dispose()); using (res) return(res.AsFrame()); } } if (frame is DepthFrame) { return(ApplyFilter(frame as DepthFrame, frameSource)); } return(frame); }