Exemple #1
0
        public MainWindow()
        {
            InitializeComponent();
            DataContext = this;

            ConvertToGrayscale = false;
            CopyOriginal       = false;
            Threshold          = 50;
            SelectedChannel    = CPUImageProcessor.Channel.RGB;
            DataContext        = this;
            _cpuImageProcessor = new CPUImageProcessor {
                SelectedChannel = this.SelectedChannel
            };
            _ampImageProcessor    = new AmpImageProcessor();
            _openCLImageProcessor = new OpenCLImageProcessor("sobel.cl");

            Processors = new List <string>(new string[] { "CPU", "C++ AMP", "OpenCL" });
        }
Exemple #2
0
        public VideoWindow()
        {
            InitializeComponent();
            DataContext = this;

            videoElement.VideoCaptureDevice = MultimediaUtil.VideoInputDevices.FirstOrDefault();

            ConvertToGrayscale    = false;
            CopyOriginal          = false;
            Threshold             = 50;
            SelectedChannel       = CPUImageProcessor.Channel.RGB;
            DataContext           = this;
            _openCLImageProcessor = new OpenCLImageProcessor("sobel.cl");
            _cpuImageProcessor    = new CPUImageProcessor {
                SelectedChannel = this.SelectedChannel
            };
            _ampImageProcessor = new AmpImageProcessor();

            Processors = new List <string>(new string[] { "CPU", "C++ AMP", "OpenCL" });

            Task.Run(() =>
            {
                int[] pixelData = new int[_width * _height];
                var sw          = new Stopwatch();
                sw.Start();

                while (true)
                {
                    sw.Restart();
                    Dispatcher.Invoke(() => GetVideoFrame(ref pixelData));

                    var result = ProcessVideoFrame(pixelData);
                    Dispatcher.Invoke(() => SetProcessedVideoFrame(result));

                    if (sw.ElapsedMilliseconds != 0)
                    {
                        FPS = (int)(1000.0 / sw.ElapsedMilliseconds);
                    }
                }
            });
        }