Ejemplo n.º 1
0
        private static void ReadGain(Device device, Dictionary <string, CameraProperty> properties)
        {
            CameraProperty p = ReadFloatProperty(device, "Gain");

            if (!p.Supported)
            {
                p = ReadIntegerProperty(device, "GainRaw", null);
            }

            string autoIdentifier = "GainAuto";

            p.AutomaticIdentifier = autoIdentifier;
            p.CanBeAutomatic      = false;
            p.Automatic           = false;
            bool autoReadable = BaumerHelper.NodeIsReadable(device, p.AutomaticIdentifier);

            if (autoReadable)
            {
                p.CanBeAutomatic = true;
                string autoValue = BaumerHelper.GetString(device, p.AutomaticIdentifier);
                p.Automatic = autoValue == GetAutoTrue(autoIdentifier);
            }

            properties.Add("gain", p);
        }
Ejemplo n.º 2
0
        private static void ReadExposure(Device device, Dictionary <string, CameraProperty> properties)
        {
            CameraProperty p = ReadFloatProperty(device, "ExposureTime");

            if (!p.Supported)
            {
                p = ReadFloatProperty(device, "ExposureTimeAbs");
            }

            string autoIdentifier = "ExposureAuto";

            p.AutomaticIdentifier = autoIdentifier;
            p.CanBeAutomatic      = false;
            p.Automatic           = false;
            bool autoReadable = BaumerHelper.NodeIsReadable(device, p.AutomaticIdentifier);

            if (autoReadable)
            {
                p.CanBeAutomatic = true;
                string autoValue = BaumerHelper.GetString(device, p.AutomaticIdentifier);
                p.Automatic = autoValue == GetAutoTrue(autoIdentifier);
            }

            properties.Add("exposure", p);
        }
Ejemplo n.º 3
0
        private void PopulateStreamFormat()
        {
            lblColorSpace.Text = CameraLang.FormConfiguration_Properties_StreamFormat;

            bool readable = BaumerHelper.NodeIsReadable(device, "PixelFormat");

            if (!readable)
            {
                cmbFormat.Enabled = false;
                return;
            }

            List <string> streamFormats = new List <string>();
            NodeMap       mapFormats    = device.RemoteNodeList["PixelFormat"].EnumNodeList;

            for (ulong i = 0; i < mapFormats.Count; i++)
            {
                var node = mapFormats[i];
                if (node.IsReadable)
                {
                    streamFormats.Add(node.Value);
                }
            }

            if (streamFormats.Count == 0)
            {
                cmbFormat.Enabled = false;
                return;
            }

            // Sort correctly so that for example "Mono8" appears before "Mono10".
            // The selection is based on the string itself, not its index in the list.
            streamFormats.Sort(new AlphanumComparator());

            string currentValue = BaumerHelper.GetString(device, "PixelFormat");

            cmbFormat.Items.Clear();
            foreach (var streamFormat in streamFormats)
            {
                cmbFormat.Items.Add(streamFormat);
                if (currentValue == streamFormat)
                {
                    selectedStreamFormat    = streamFormat;
                    cmbFormat.SelectedIndex = cmbFormat.Items.Count - 1;
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Configure device and report frame format that will be used during streaming.
        /// This method must return a proper ImageDescriptor so we can pre-allocate buffers.
        /// </summary>
        public ImageDescriptor Prepare()
        {
            Open();

            if (!baumerProvider.IsOpen)
            {
                return(ImageDescriptor.Invalid);
            }

            firstOpen = false;
            Device device = baumerProvider.Device;

            // Get the configured framerate for recording support.
            resultingFramerate = BaumerHelper.GetResultingFramerate(device);

            bool hasWidth                  = BaumerHelper.NodeIsReadable(device, "Width");
            bool hasHeight                 = BaumerHelper.NodeIsReadable(device, "Height");
            bool hasPixelFormat            = BaumerHelper.NodeIsReadable(device, "PixelFormat");
            bool canComputeImageDescriptor = hasWidth && hasHeight && hasPixelFormat;

            if (!canComputeImageDescriptor)
            {
                return(ImageDescriptor.Invalid);
            }

            int    width       = BaumerHelper.GetInteger(device, "Width");
            int    height      = BaumerHelper.GetInteger(device, "Height");
            string pixelFormat = BaumerHelper.GetString(device, "PixelFormat");

            // We output in three possible formats: Y800, RGB24 or JPEG.
            // The output format depends on the stream format and the options.
            // Mono or raw -> Y800, Otherwise -> RGB24.

            // Camera-side JPEG compression.
            compression = specific.Compression;
            if (BaumerHelper.SupportsJPEG(device))
            {
                if (BaumerHelper.FormatCanCompress(device, pixelFormat))
                {
                    BaumerHelper.SetJPEG(device, compression);
                }
                else
                {
                    BaumerHelper.SetJPEG(device, false);
                    compression = false;
                }
            }
            else
            {
                compression = false;
            }

            // Debayering.
            demosaicing = specific.Demosaicing;
            if (demosaicing)
            {
                if (imgProcessor.NodeList.GetNodePresent("DemosaicingMethod"))
                {
                    // Options: NearestNeighbor, Bilinear3x3, Baumer5x5
                    imgProcessor.NodeList["DemosaicingMethod"].Value = "NearestNeighbor";
                }
                else
                {
                    demosaicing = false;
                }
            }

            imageFormat     = BaumerHelper.ConvertImageFormat(pixelFormat, compression, demosaicing);
            frameBufferSize = ImageFormatHelper.ComputeBufferSize(width, height, imageFormat);
            frameBuffer     = new byte[frameBufferSize];

            finishline.Prepare(width, height, imageFormat, resultingFramerate);
            if (finishline.Enabled)
            {
                height             = finishline.Height;
                resultingFramerate = finishline.ResultingFramerate;
            }

            int  outgoingBufferSize = ImageFormatHelper.ComputeBufferSize(width, height, imageFormat);
            bool topDown            = true;

            return(new ImageDescriptor(imageFormat, width, height, topDown, outgoingBufferSize));
        }