Ejemplo n.º 1
0
        public override bool Initialize()
        {
            base.Initialize();

            _imageInput = GetProperty("ImageInput") as ImageProperty;
            _imageOutput = GetProperty("ImageOutput") as ImageProperty;
            return true;
        }
Ejemplo n.º 2
0
        public override bool Initialize()
        {
            base.Initialize();

            _inputImage = GetProperty("InputImage") as ImageProperty;
            _outputImage = GetProperty("OuputImage") as ImageProperty;
            return true;
        }
Ejemplo n.º 3
0
        public override bool Initialize()
        {
            base.Initialize();

            _imageInput = GetProperty("ImageInput") as ImageProperty;
            _kernelSize = GetProperty("KernelSize") as IntegerProperty;
            _imageOutput = GetProperty("ImageOutput") as ImageProperty;
            return true;
        }
Ejemplo n.º 4
0
        public override bool Initialize()
        {
            base.Initialize();

            _imageInput = GetProperty("ImageInput") as ImageProperty;
            _adjustValue = GetProperty("AdjustValue") as IntegerProperty;
            _imageOutput = GetProperty("ImageOutput") as ImageProperty;
            return true;
        }
Ejemplo n.º 5
0
        public override bool Initialize()
        {
            base.Initialize();

            _aoiProperty = GetProperty("AOI") as RectangleProperty;
            _inputImage = GetProperty("InputImage") as ImageProperty;
            _outputImage = GetProperty("OuputImage") as ImageProperty;
            _intensityProperty = GetProperty("Intensity") as DoubleProperty;
            return true;
        }
Ejemplo n.º 6
0
        public override bool Initialize()
        {
            base.Initialize();

            _imageInput = GetProperty("ImageInput") as ImageProperty;
            _redCoefficient = GetProperty("RedCoefficient") as DoubleProperty;
            _greenCoefficient = GetProperty("GreenCoefficient") as DoubleProperty;
            _blueCoefficient = GetProperty("BlueCoefficient") as DoubleProperty;
            _imageOutput = GetProperty("ImageOutput") as ImageProperty;
            return true;
        }
Ejemplo n.º 7
0
        public override bool Initialize()
        {
            base.Initialize();

            _imageInput = GetProperty("ImageInput") as ImageProperty;
            _kernelSize = GetProperty("KernelSize") as IntegerProperty;
            _spatialFactor = GetProperty("SpatialFactor") as IntegerProperty;
            _colorFactor = GetProperty("ColorFactor") as IntegerProperty;
            _colorPower = GetProperty("ColorPower") as DoubleProperty;
            _imageOutput = GetProperty("ImageOutput") as ImageProperty;
            return true;
        }
Ejemplo n.º 8
0
        private void AddTabItem(ImageProperty image)
        {
            DisplayTabItem item = new DisplayTabItem(image);

            Operation parentOperation = image.ParentOperation as Operation;
            foreach (OperationDisplayTabItem oitem in this.DisplayTabControl.Items) {
                if (oitem.Operation == parentOperation) {
                    TabControl control = oitem.Content as TabControl;
                    control.Items.Add(item);
                    item.SetParent(control);
                }
            }
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Finalize the Node.
 /// </summary>
 /// <returns>
 /// Success of the Operation.
 /// </returns>
 public override bool Finalize()
 {
     _isRunning = false;
     if (_device != null) {
         lock (_device) {
             _device.Finalize();
             _device = null;
         }
     }
     if (_imageProperty != null)
         _imageProperty = null;
     return base.Finalize();
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DisplayTabItem"/> class.
 /// </summary>
 /// <param name="imageProperty">The image property.</param>
 public DisplayTabItem(ImageProperty imageProperty)
     : base()
 {
     ScalingFactor = 1.0;
     InitializeComponent();
     _imageProperty = imageProperty;
     this.Style = new Style(GetType(), this.FindResource(typeof(TabItem)) as Style);
     this.Header = _imageProperty.ParentTool.Name + " - " + _imageProperty.Name;
     _imageProperty.ParentTool.PropertyChanged += HandleParentPropertyChanged;
     this.DataContext = this;
     this.HistogramGray.DataContext = Histogram;
     this.HistogramAllGray.DataContext = Histogram;
     this.HistogramRed.DataContext = Histogram;
     this.HistogramAllRed.DataContext = Histogram;
     this.HistogramGreen.DataContext = Histogram;
     this.HistogramAllGreen.DataContext = Histogram;
     this.HistogramBlue.DataContext = Histogram;
     this.HistogramAllBlue.DataContext = Histogram;
     this.IsUpdateHistogramEnabled = false;
     SetOverlayProperties(imageProperty);
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Initialze the Plugin.
        /// </summary>
        /// <returns>
        /// Success of the Operation.
        /// </returns>
        public override bool Initialize()
        {
            try {
                _imageProperty = GetProperty("Image") as ImageProperty;
                _deviceListProperty = GetProperty("Selected") as ListProperty;
                _resolutionListProperty = GetProperty("Resolution") as ListProperty;

                _resolutionListProperty.PropertyChanged += ResolutionListProperty_PropertyChanged;

                FilterInfoCollection videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
                VideoCapabilities[] videoCapabilities;

                foreach (FilterInfo device in videoDevices) {
                    if (device.Name == _deviceListProperty.Value as string) {
                        _videoDevice = new VideoCaptureDevice(device.MonikerString);
                        break;
                    }
                }

                if (_videoDevice == null) return false;

                videoCapabilities = _videoDevice.VideoCapabilities;
                _videoDevice.VideoResolution = videoCapabilities[_resolutionListProperty.Index];

                _videoDevice.NewFrame += _videoDevice_NewFrame;
                _videoDevice.Start();
                _isTerminated = false;
                return true;
            } catch (Exception ex) {
                Trace.WriteLine(ex.Message, ex.StackTrace, LogCategory.Error);
                return false;
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Converts to byte arry.
        /// </summary>
        /// <param name="imageProperty">The image property.</param>
        /// <returns></returns>
        private byte[] ConvertToByteArry(ImageProperty imageProperty)
        {
            if (imageProperty == null || imageProperty.Value == null)
                return null;

            ImageContainer container = (ImageContainer)imageProperty.Value;
            System.Drawing.Imaging.PixelFormat pixelFormat = PixelFormat.Format24bppRgb;

            EncoderParameters codecParams;

            if (container.BytesPerPixel == 1) {
                pixelFormat = PixelFormat.Format8bppIndexed;
                EncoderParameter encoderParameter = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 30L);
                EncoderParameter encoderParameter2 = new EncoderParameter(System.Drawing.Imaging.Encoder.ColorDepth, 8L);
                codecParams = new EncoderParameters(2);
                codecParams.Param[0] = encoderParameter;
                codecParams.Param[1] = encoderParameter2;
            } else {
                EncoderParameter encoderParameter = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 30L);
                codecParams = new EncoderParameters(1);
                codecParams.Param[0] = encoderParameter;
            }

            Bitmap bitmap = new Bitmap(container.Width, container.Height, pixelFormat);

            if (container.BytesPerPixel == 1) {
                ColorPalette palette = bitmap.Palette;
                for (int index = 0; index < 256; index++) {
                    Color color = Color.FromArgb(index, index, index);
                    palette.Entries[index] = color;
                }
                bitmap.Palette = palette;
            }

            BitmapData data = bitmap.LockBits(new Rectangle(0, 0, container.Width, container.Height), ImageLockMode.ReadWrite, pixelFormat);
            Marshal.Copy(container.Data, 0, data.Scan0, container.Data.Length);
            bitmap.UnlockBits(data);

            ImageCodecInfo[] availableCodecs = ImageCodecInfo.GetImageEncoders();
            ImageCodecInfo jpegCodecInfo = availableCodecs.FirstOrDefault(codec => codec.MimeType == "image/jpeg");

            if (jpegCodecInfo == null) {
                Trace.WriteLine("No available jpeg codec found!", LogCategory.Error);
                return null;
            }

            using (MemoryStream stream = new MemoryStream()) {

                bitmap.Save(stream, jpegCodecInfo, codecParams);
                return stream.ToArray();
            }
        }
Ejemplo n.º 13
0
 private void SetOverlayProperties(ImageProperty imageProperty)
 {
     if(imageProperty.Parent is Tool) {
         Tool parent = imageProperty.Parent as Tool;
         foreach(ns.Base.Plugins.Properties.Property child in parent.Childs.Where(c => c is ns.Base.Plugins.Properties.Property)) {
             if(child is RectangleProperty && !child.IsOutput) {
                 if (_rectangles == null) _rectangles = new List<OverlayRectangle>();
                 OverlayRectangle overlay = new OverlayRectangle(child as RectangleProperty, this.ImageCanvas);
                 _rectangles.Add(overlay);
                 this.ImageCanvas.Children.Add(overlay.Rectangle);
             }
         }
     }
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Updates the image.
        /// </summary>
        /// <param name="image">The image.</param>
        public void UpdateImage(ImageProperty image)
        {
            if (image.Value != null) {
                ImageContainer container = (ImageContainer)image.Value;
                this.ImageDisplay.Source = LoadImage(container.Data, container.Width, container.Height, container.Stride, container.BytesPerPixel);

                this.ImageDisplay.Width = container.Width;
                this.ImageDisplay.Height = container.Height;
                this.ImageCanvas.Width = container.Width;
                this.ImageCanvas.Height = container.Height;
            }
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Closes this instance.
 /// </summary>
 public void Close()
 {
     if (_imageProperty != null) {
         _imageProperty.ParentTool.PropertyChanged -= HandleParentPropertyChanged;
         _imageProperty = null;
     }
 }
Ejemplo n.º 16
0
        public override bool Initialize()
        {
            base.Initialize();

            _imageInput = GetProperty("ImageInput") as ImageProperty;

            _maxBlue = GetProperty("MaxBlue") as IntegerProperty;
            _minBlue = GetProperty("MinBlue") as IntegerProperty;
            _medianBlue = GetProperty("MedianBlue") as IntegerProperty;
            _meanBlue = GetProperty("MeanBlue") as DoubleProperty;
            _stdDevBlue = GetProperty("StdDevBlue") as DoubleProperty;

            _maxGreen = GetProperty("MaxGreen") as IntegerProperty;
            _minGreen = GetProperty("MinGreen") as IntegerProperty;
            _medianGreen = GetProperty("MedianGreen") as IntegerProperty;
            _meanGreen = GetProperty("MeanGreen") as DoubleProperty;
            _stdDevGreen = GetProperty("StdDevGreen") as DoubleProperty;

            _maxRed = GetProperty("MaxRed") as IntegerProperty;
            _minRed = GetProperty("MinRed") as IntegerProperty;
            _medianRed = GetProperty("MedianRed") as IntegerProperty;
            _meanRed = GetProperty("MeanRed") as DoubleProperty;
            _stdDevRed = GetProperty("StdDevRed") as DoubleProperty;
            return true;
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Initialze the Plugin.
        /// </summary>
        /// <returns>
        /// Success of the Operation.
        /// </returns>
        public override bool Initialize()
        {
            base.Initialize();

            bool result = false;
            _deviceProperty = GetProperty("Interface") as DeviceProperty;
            if (_deviceProperty == null) {
                Trace.WriteLine("Device interface is null!", LogCategory.Error);
                return false;
            }
            _deviceProperty.PropertyChanged -= DeviceProperty_PropertyChanged;
            _deviceProperty.PropertyChanged += DeviceProperty_PropertyChanged;
            _device = _deviceProperty.Value as ImageDevice;
            if (_device == null) {
                Trace.WriteLine("Device is null!", LogCategory.Error);
                return false;
            }
            _imageProperty = GetProperty(typeof(ImageProperty)) as ImageProperty;

            if (_device == null) {
                Trace.WriteLine("Device interface is null!", LogCategory.Error);
            } else {
                result = _device.Initialize();
                if (!result)
                    Trace.WriteLine("Could not initialize device!", LogCategory.Error);
            }

            _isRunning = result;
            return result;
        }
Ejemplo n.º 18
0
        private void RemoveTabItem(ImageProperty image)
        {
            DisplayTabItem target = null;
            Operation parentOperation = image.ParentOperation as Operation;
            foreach (OperationDisplayTabItem item in this.DisplayTabControl.Items) {
                if (item.Operation == parentOperation) {

                    foreach (DisplayTabItem child in ((TabControl)item.Content).Items) {
                        if (child.ImageProperty == image) {
                            target = child;
                            break;
                        }
                    }

                    ((TabControl)item.Content).Items.Remove(target);

                    break;
                }
            }
        }