Exemplo n.º 1
0
        private string SpecificInfoSerialize(CameraSummary summary)
        {
            SpecificInfo info = summary.Specific as SpecificInfo;

            if (info == null)
            {
                return(null);
            }

            XmlDocument doc     = new XmlDocument();
            XmlElement  xmlRoot = doc.CreateElement("FrameGenerator");

            XmlElement xmlFrameInterval = doc.CreateElement("FrameInterval");
            string     frameInterval    = string.Format("{0}", info.FrameInterval);

            xmlFrameInterval.InnerText = frameInterval;
            xmlRoot.AppendChild(xmlFrameInterval);

            XmlElement xmlFrameSize = doc.CreateElement("FrameSize");
            string     frameSize    = string.Format("{0};{1}", info.FrameSize.Width, info.FrameSize.Height);

            xmlFrameSize.InnerText = frameSize;
            xmlRoot.AppendChild(xmlFrameSize);

            doc.AppendChild(xmlRoot);

            return(doc.OuterXml);
        }
        public static void Write(SpecificInfo info, CameraProperty property)
        {
            if (!property.Supported || string.IsNullOrEmpty(property.Identifier))
            {
                return;
            }

            switch (property.Identifier)
            {
            case "width":
                info.Width = int.Parse(property.CurrentValue);
                break;

            case "height":
                info.Height = int.Parse(property.CurrentValue);
                break;

            case "framerate":
                info.Framerate = int.Parse(property.CurrentValue);
                break;

            default:
                log.ErrorFormat("Camera simulator property not supported: {0}.", property.Identifier);
                break;
            }
        }
Exemplo n.º 3
0
        public override bool Configure(CameraSummary summary)
        {
            bool needsReconnection = false;
            FormConfiguration form = new FormConfiguration(summary);

            if (form.ShowDialog() == DialogResult.OK)
            {
                if (form.AliasChanged)
                {
                    summary.UpdateAlias(form.Alias, form.PickedIcon);
                }

                if (form.SpecificChanged)
                {
                    SpecificInfo info = new SpecificInfo();
                    info.FrameInterval = form.FrameInterval;
                    info.FrameSize     = form.FrameSize;
                    summary.UpdateSpecific(info);
                    summary.UpdateDisplayRectangle(Rectangle.Empty);

                    needsReconnection = true;
                }

                CameraTypeManager.UpdatedCameraSummary(summary);
            }

            form.Dispose();
            return(needsReconnection);
        }
Exemplo n.º 4
0
        private SpecificInfo CreateSpecific()
        {
            SpecificInfo specific = new SpecificInfo();

            specific.FrameInterval = 20000;
            specific.FrameSize     = new Size(1920, 1080);
            return(specific);
        }
        public static Dictionary <string, CameraProperty> Read(SpecificInfo info)
        {
            Dictionary <string, CameraProperty> properties = new Dictionary <string, CameraProperty>();

            ReadInteger(properties, "width", "1", "4096", "1", false, info.Width.ToString());
            ReadInteger(properties, "height", "1", "4096", "1", false, info.Height.ToString());
            ReadInteger(properties, "framerate", "1", "9999", "1", true, info.Framerate.ToString());

            return(properties);
        }
Exemplo n.º 6
0
        private void PopulateCapabilities()
        {
            int  selectedFrameInterval = 0;
            Size selectedFrameSize     = Size.Empty;

            SpecificInfo info = summary.Specific as SpecificInfo;

            if (info != null)
            {
                selectedFrameInterval = info.FrameInterval;
                selectedFrameSize     = info.FrameSize;
            }
            else
            {
                selectedFrameInterval = defaultFrameInterval;
                selectedFrameSize     = defaultFrameSize.Value;
            }

            int sizeIndex = 0;

            foreach (FrameSize frameSize in frameSizes)
            {
                cmbFrameSize.Items.Add(frameSize);

                if (frameSize.Value == selectedFrameSize)
                {
                    cmbFrameSize.SelectedIndex = sizeIndex;
                }

                sizeIndex++;
            }

            int fpsIndex = 0;

            foreach (Framerate framerate in framerates)
            {
                cmbFramerate.Items.Add(framerate);

                if (framerate.FrameInterval == selectedFrameInterval)
                {
                    cmbFramerate.SelectedIndex = fpsIndex;
                }

                fpsIndex++;
            }
        }
Exemplo n.º 7
0
        public FormConfiguration(CameraSummary summary)
        {
            this.summary = summary;
            specific     = summary.Specific as SpecificInfo;

            InitializeComponent();

            tbAlias.Text            = summary.Alias;
            lblSystemName.Text      = summary.Name;
            btnIcon.BackgroundImage = summary.Icon;

            cameraProperties = CameraPropertyManager.Read(specific);
            PopulateStreamFormat();
            PopulateCameraControls();
            this.Text     = CameraLang.FormConfiguration_Title;
            btnApply.Text = CameraLang.Generic_Apply;
        }
Exemplo n.º 8
0
        /// <summary>
        /// Configure the device according to what is saved in the preferences.
        /// </summary>
        private void CreateAndConfigureDevice()
        {
            if (grabbing)
            {
                Stop();
            }

            device = new FrameGeneratorDevice();

            SpecificInfo specific = summary.Specific as SpecificInfo;

            if (specific == null)
            {
                return;
            }

            device.Configuration = new DeviceConfiguration(specific.ImageFormat, specific.Width, specific.Height, specific.Framerate);
        }
        public override string GetSummaryAsText(CameraSummary summary)
        {
            string result = "";
            string alias  = summary.Alias;

            SpecificInfo info = summary.Specific as SpecificInfo;

            if (info != null)
            {
                result = string.Format("{0} - {1}×{2} @ {3} fps ({4}).", alias, info.Width, info.Height, info.Framerate, info.ImageFormat);
            }
            else
            {
                result = string.Format("{0}", alias);
            }

            return(result);
        }
Exemplo n.º 10
0
        public override string GetSummaryAsText(CameraSummary summary)
        {
            string result = "";
            string alias  = summary.Alias;

            SpecificInfo info = summary.Specific as SpecificInfo;

            if (info != null)
            {
                Size  size = info.FrameSize;
                float fps  = 1000000.0f / info.FrameInterval;
                result = string.Format("{0} - {1}×{2} @ {3:0.##} fps.", alias, size.Width, size.Height, fps);
            }
            else
            {
                result = string.Format("{0}", alias);
            }

            return(result);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Configure the device according to what is saved in the preferences.
        /// </summary>
        private void CreateAndConfigureDevice()
        {
            if (grabbing)
            {
                Stop();
            }

            device = new FrameGeneratorDevice();

            SpecificInfo specific = summary.Specific as SpecificInfo;

            if (specific == null)
            {
                return;
            }

            DeviceConfiguration configuration = new DeviceConfiguration(specific.FrameSize.Width, specific.FrameSize.Height, specific.FrameInterval, ImageFormat.RGB24);

            device.Configuration = configuration;
        }
Exemplo n.º 12
0
        private SpecificInfo SpecificInfoDeserialize(string xml)
        {
            if (string.IsNullOrEmpty(xml))
            {
                return(null);
            }

            SpecificInfo info = null;

            try
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(new StringReader(xml));

                info = new SpecificInfo();

                int  frameInterval = 20000;
                Size frameSize     = Size.Empty;

                XmlNode xmlFrameInterval = doc.SelectSingleNode("/FrameGenerator/FrameInterval");
                if (xmlFrameInterval != null)
                {
                    frameInterval = int.Parse(xmlFrameInterval.InnerText, CultureInfo.InvariantCulture);
                }

                XmlNode xmlFrameSize = doc.SelectSingleNode("/FrameGenerator/FrameSize");
                if (xmlFrameSize != null)
                {
                    frameSize = XmlHelper.ParseSize(xmlFrameSize.InnerText);
                }

                info.FrameInterval = frameInterval;
                info.FrameSize     = frameSize;
            }
            catch (Exception e)
            {
                log.ErrorFormat(e.Message);
            }

            return(info);
        }
        private SpecificInfo SpecificInfoDeserialize(string xml)
        {
            if (string.IsNullOrEmpty(xml))
            {
                return(null);
            }

            SpecificInfo info = null;

            try
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(new StringReader(xml));

                info = new SpecificInfo();

                XmlNode xmlImageFormat = doc.SelectSingleNode("/FrameGenerator/ImageFormat");
                if (xmlImageFormat != null)
                {
                    info.ImageFormat = (ImageFormat)Enum.Parse(typeof(ImageFormat), xmlImageFormat.InnerText);
                }

                info.Width     = ParseInt(doc, "/FrameGenerator/Width", info.Width);
                info.Height    = ParseInt(doc, "/FrameGenerator/Height", info.Height);
                info.Framerate = ParseInt(doc, "/FrameGenerator/Framerate", info.Framerate);

                if (info.ImageFormat == ImageFormat.JPEG)
                {
                    info.Width -= (info.Width % 4);
                }
            }
            catch (Exception e)
            {
                log.ErrorFormat(e.Message);
            }

            return(info);
        }
        private string SpecificInfoSerialize(CameraSummary summary)
        {
            SpecificInfo info = summary.Specific as SpecificInfo;

            if (info == null)
            {
                return(null);
            }

            XmlDocument doc     = new XmlDocument();
            XmlElement  xmlRoot = doc.CreateElement("FrameGenerator");

            XmlElement xmlImageFormat = doc.CreateElement("ImageFormat");

            xmlImageFormat.InnerText = info.ImageFormat.ToString();
            xmlRoot.AppendChild(xmlImageFormat);

            WriteInt(doc, xmlRoot, "Width", info.Width);
            WriteInt(doc, xmlRoot, "Height", info.Height);
            WriteInt(doc, xmlRoot, "Framerate", info.Framerate);

            doc.AppendChild(xmlRoot);
            return(doc.OuterXml);
        }
Exemplo n.º 15
0
 public void Populate(SpecificInfo specific)
 {
 }