当前位置: 首页>>代码示例>>C#>>正文


C# Window.ShowImage方法代码示例

本文整理汇总了C#中Window.ShowImage方法的典型用法代码示例。如果您正苦于以下问题:C# Window.ShowImage方法的具体用法?C# Window.ShowImage怎么用?C# Window.ShowImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Window的用法示例。


在下文中一共展示了Window.ShowImage方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FileStorageTest

        private static void FileStorageTest()
        {
            const string fileName = "foo.yml";

            try
            {
                using (var fs = new FileStorage(fileName, FileStorage.Mode.Write | FileStorage.Mode.FormatYaml))
                {
                    fs.Write("int", 123);
                    fs.Write("double", Math.PI);
                    using (var tempMat = new Mat("data/lenna.png"))
                    {
                        fs.Write("mat", tempMat);
                    }
                }

                using (var fs = new FileStorage(fileName, FileStorage.Mode.Read))
                {
                    Console.WriteLine("int: {0}", fs["int"].ReadInt());
                    Console.WriteLine("double: {0}", (double) fs["double"]);
                    using (var window = new Window("mat"))
                    {
                        window.ShowImage(fs["mat"].ReadMat());
                        Cv2.WaitKey();
                    }
                }
            }
            finally
            {
                File.Delete(fileName);
            }
        }
开发者ID:shimat,项目名称:opencvsharp,代码行数:32,代码来源:Program.cs

示例2: Run

        public void Run()
        {
            var capture = new VideoCapture();
            capture.Set(CaptureProperty.FrameWidth, 640);
            capture.Set(CaptureProperty.FrameHeight, 480);
            capture.Open(-1);
            if (!capture.IsOpened())
                throw new Exception("capture initialization failed");

            var fs = FrameSource.CreateCameraSource(-1);
            var sr = SuperResolution.CreateBTVL1();
            sr.SetInput(fs);

            using (var normalWindow = new Window("normal"))
            using (var srWindow = new Window("super resolution"))
            {
                var normalFrame = new Mat();
                var srFrame = new Mat();
                while (true)
                {
                    capture.Read(normalFrame);
                    sr.NextFrame(srFrame);
                    if (normalFrame.Empty() || srFrame.Empty())
                        break;
                    normalWindow.ShowImage(normalFrame);
                    srWindow.ShowImage(srFrame);
                    Cv2.WaitKey(100);
                }
            }
        }
开发者ID:0sv,项目名称:opencvsharp,代码行数:30,代码来源:SuperResolutionSample.cs

示例3: VideoCaptureSample

        private static void VideoCaptureSample()
        {
            var cap = new VideoCapture(0);

            if (!cap.IsOpened())
            {
                Console.WriteLine("Can't use camera.");
                return;
            }

            var frame = new Mat();
            cap.Grab();
            NativeMethods.videoio_VideoCapture_operatorRightShift_Mat(cap.CvPtr, frame.CvPtr);
            
            Window.ShowImages(frame);

            using (var window = new Window("window"))
            {
                while (true)
                {
                    cap.Read(frame);
                    window.ShowImage(frame);
                    int key = Cv2.WaitKey(50);
                    if (key == 'b')
                        break;
                }
            }
        }
开发者ID:leekihak,项目名称:opencvsharp,代码行数:28,代码来源:Program.cs

示例4: VideoCaptureSample

        private static void VideoCaptureSample()
        {
            var cap = new VideoCapture(0);

            if (!cap.IsOpened())
            {
                Console.WriteLine("Can't use camera.");
                return;
            }

            var frame = new Mat();

            using (var window = new Window("window"))
            {
                while (true)
                {
                    cap.Read(frame);
                    window.ShowImage(frame);
                    int key = Cv2.WaitKey(50);
                    if (key == 'b')
                        break;
                }
            }
        }
开发者ID:rayrrrr,项目名称:opencvsharp,代码行数:24,代码来源:Program.cs

示例5: Run

        public void Run()
        {
            const string OutVideoFile = "out.avi";

            // Opens MP4 file (ffmpeg is probably needed)
            VideoCapture capture = new VideoCapture(FilePath.Bach);

            // Read movie frames and write them to VideoWriter 
            Size dsize = new Size(640, 480);
            using (VideoWriter writer = new VideoWriter(OutVideoFile, -1, capture.Fps, dsize))
            {
                Console.WriteLine("Converting each movie frames...");
                Mat frame = new Mat();
                while(true)
                {
                    // Read image
                    capture.Read(frame);
                    if(frame.Empty())
                        break;

                    Console.CursorLeft = 0;
                    Console.Write("{0} / {1}", capture.PosFrames, capture.FrameCount);

                    // grayscale -> canny -> resize
                    Mat gray = new Mat();
                    Mat canny = new Mat();
                    Mat dst = new Mat();
                    Cv2.CvtColor(frame, gray, ColorConversion.BgrToGray);
                    Cv2.Canny(gray, canny, 100, 180);
                    Cv2.Resize(canny, dst, dsize, 0, 0, Interpolation.Linear);
                    // Write mat to VideoWriter
                    writer.Write(dst);
                } 
                Console.WriteLine();
            }

            // Watch result movie
            using (VideoCapture capture2 = new VideoCapture(OutVideoFile))
            using (Window window = new Window("result"))
            {
                int sleepTime = (int)(1000 / capture.Fps);

                Mat frame = new Mat();
                while (true)
                {
                    capture2.Read(frame);
                    if(frame.Empty())
                        break;

                    window.ShowImage(frame);
                    Cv2.WaitKey(sleepTime);
                }
            }
        }
开发者ID:jorik041,项目名称:opencvsharp,代码行数:54,代码来源:VideoWriterSample.cs

示例6: Run

        public void Run()
        {
            // Opens MP4 file (ffmpeg is probably needed)
            VideoCapture capture = new VideoCapture(FilePath.Movie.Bach);

            int sleepTime = (int)Math.Round(1000 / capture.Fps);

            using (Window window = new Window("capture"))
            {
                // Frame image buffer
                Mat image = new Mat();

                // When the movie playback reaches end, Mat.data becomes NULL.
                while (true)
                {
                    capture.Read(image); // same as cvQueryFrame
                    if(image.Empty())
                        break;

                    window.ShowImage(image);
                    Cv2.WaitKey(sleepTime);
                } 
            }
        }
开发者ID:0sv,项目名称:opencvsharp,代码行数:24,代码来源:VideoCaptureSample.cs


注:本文中的Window.ShowImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。