aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Video/DisplaySettingEffect.cs
blob: 5bf660556f512b79a51cb54a146d56ceb525c9c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
namespace Tango.Video.DirectCapture
{
    using System;
    using System.ComponentModel;
    using System.Text;
    using System.Windows;
    using System.Windows.Media;
    using System.Windows.Media.Effects;

    public class DisplaySettingEffect : ShaderEffect
    {
        public static readonly DependencyProperty BrightnessLevelProperty = DependencyProperty.Register("BrightnessLevel", typeof(double), typeof(DisplaySettingEffect), new UIPropertyMetadata(1.0, ShaderEffect.PixelShaderConstantCallback(1)));
        public static readonly DependencyProperty ContrastLevelProperty = DependencyProperty.Register("ContrastLevel", typeof(double), typeof(DisplaySettingEffect), new UIPropertyMetadata(1.0, ShaderEffect.PixelShaderConstantCallback(0)));
        public static readonly DependencyProperty Input1Property = ShaderEffect.RegisterPixelShaderSamplerProperty("Input1", typeof(DisplaySettingEffect), 0);
        public static readonly DependencyProperty SaturationLevelProperty = DependencyProperty.Register("SaturationLevel", typeof(double), typeof(DisplaySettingEffect), new UIPropertyMetadata(1.0, ShaderEffect.PixelShaderConstantCallback(2)));

        /// <summary>
        /// Initializes a new instance of the <see cref="DisplaySettingEffect"/> class.
        /// </summary>
        public DisplaySettingEffect()
            : base()
        {
            PixelShader pixelShader = new PixelShader();
            pixelShader.UriSource = new Uri("pack://application:,,,/Twine.Video;component/DisplaySettingEffect.ps", UriKind.RelativeOrAbsolute);
            this.PixelShader = pixelShader;

            this.UpdateShaderValue(Input1Property);
            this.UpdateShaderValue(ContrastLevelProperty);
            this.UpdateShaderValue(Input1Property);
            this.UpdateShaderValue(BrightnessLevelProperty);
            this.UpdateShaderValue(Input1Property);
            this.UpdateShaderValue(SaturationLevelProperty);
        }

        /// <summary>
        /// Gets or sets the brightness level.
        /// </summary>
        public double BrightnessLevel
        {
            get
            {
                return (double)base.GetValue(BrightnessLevelProperty);
            }
            set
            {
                base.SetValue(BrightnessLevelProperty, value);
            }
        }

        /// <summary>
        /// Gets or sets the contrast level.
        /// </summary>
        public double ContrastLevel
        {
            get
            {
                return (double)base.GetValue(ContrastLevelProperty);
            }
            set
            {
                base.SetValue(ContrastLevelProperty, value);
            }
        }

        /// <summary>
        /// Gets or sets the saturation level.
        /// </summary>
        public double SaturationLevel
        {
            get
            {
                return (double)base.GetValue(SaturationLevelProperty);
            }
            set
            {
                base.SetValue(SaturationLevelProperty, value);
            }
        }

        /// <summary>
        /// Gets or sets the input.
        /// </summary>
        [Browsable(false)]
        public Brush Input1
        {
            get
            {
                return (Brush)base.GetValue(Input1Property);
            }
            set
            {
                base.SetValue(Input1Property, value);
            }
        }
    }
}
quot;image")); else videoCapture.open(parser.get<int>("camera")); videoCapture >> inputFrame; if(inputFrame.empty()) { std::cout << "Failed to open media source\n"; return 0; } ////////////////////////////////////////////////////////////////////////////// // Program start in a try/catch safety context (Retina may throw errors) try { // create a retina instance with default parameters setup, uncomment the initialisation you wanna test cv::Ptr<cv::bioinspired::Retina> myRetina; // if the last parameter is 'log', then activate log sampling (favour foveal vision and subsamples peripheral vision) if (useLogSampling) { myRetina = cv::bioinspired::Retina::create(inputFrame.size(), true, cv::bioinspired::RETINA_COLOR_BAYER, true, 2.0, 10.0); } else// -> else allocate "classical" retina : myRetina = cv::bioinspired::Retina::create(inputFrame.size()); // save default retina parameters file in order to let you see this and maybe modify it and reload using method "setup" myRetina->write("RetinaDefaultParameters.xml"); // load parameters if file exists myRetina->setup("RetinaSpecificParameters.xml"); myRetina->clearBuffers(); // declare retina output buffers cv::UMat retinaOutput_parvo; cv::UMat retinaOutput_magno; // processing loop with stop condition int64 totalTime = 0; int64 totalFrames = 0; while(true) { // if using video stream, then, grabbing a new frame, else, input remains the same if (videoCapture.isOpened()) videoCapture>>inputFrame; if(inputFrame.empty()) break; // run retina filter int64 frameTime = cv::getTickCount(); myRetina->run(inputFrame); // Retrieve and display retina output frameTime = cv::getTickCount() - frameTime; totalTime += frameTime; totalFrames++; myRetina->getParvo(retinaOutput_parvo); myRetina->getMagno(retinaOutput_magno); cv::imshow("retina input", inputFrame); cv::imshow("Retina Parvo", retinaOutput_parvo); cv::imshow("Retina Magno", retinaOutput_magno); int key = cv::waitKey(5); if(key == 'q') break; } std::cout << "\nMean frame processing time: " << (totalTime / cv::getTickFrequency()) / totalFrames << " s" << std::endl; std::cout << "Retina demo end" << std::endl; } catch(const cv::Exception& e) { std::cerr<<"Error using Retina : "<<e.what()<<std::endl; } return 0; }