Beispiel #1
0
        public VideoWriterDisposable(OpenCV.Net.VideoWriter writer, IDisposable disposable)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }

            Writer   = writer;
            resource = disposable;
        }
Beispiel #2
0
        protected override VideoWriterDisposable CreateWriter(string fileName, IplImage input)
        {
            if (string.IsNullOrEmpty(Path.GetExtension(fileName)))
            {
                throw new InvalidOperationException("The specified video file path must have a valid container extension (e.g. .avi).");
            }

            var frameSize  = FrameSize.Width > 0 && FrameSize.Height > 0 ? FrameSize : input.Size;
            var fourCCText = FourCC;
            var fourCC     = fourCCText.Length != 4 ? 0 : OpenCV.Net.VideoWriter.FourCC(fourCCText[0], fourCCText[1], fourCCText[2], fourCCText[3]);

            writerFrameSize = frameSize;
            lock (SyncRoot)
            {
                var writer = new OpenCV.Net.VideoWriter(fileName, fourCC, FrameRate, frameSize, input.Channels > 1);
                return(new VideoWriterDisposable(writer, Disposable.Create(() =>
                {
                    lock (SyncRoot)
                    {
                        writer.Close();
                    }
                })));
            }
        }