Пример #1
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 (device == null || featureControl == null)
            {
                return(ImageDescriptor.Invalid);
            }

            firstOpen          = false;
            resultingFramerate = (float)DahengHelper.GetResultingFramerate(device);

            width   = (int)featureControl.GetIntFeature("Width").GetValue();
            height  = (int)featureControl.GetIntFeature("Height").GetValue();
            isColor = DahengHelper.IsColor(featureControl);

            ImageFormat format = ImageFormat.RGB24;

            incomingBufferSize = ImageFormatHelper.ComputeBufferSize(width, height, format);
            incomingBuffer     = new byte[incomingBufferSize];

            int  outgoingBufferSize = ImageFormatHelper.ComputeBufferSize(width, height, format);
            bool topDown            = false;

            return(new ImageDescriptor(format, width, height, topDown, outgoingBufferSize));
        }
Пример #2
0
        public override string GetSummaryAsText(CameraSummary summary)
        {
            string       result = "";
            string       alias  = summary.Alias;
            SpecificInfo info   = summary.Specific as SpecificInfo;

            try
            {
                if (info != null &&
                    info.CameraProperties.ContainsKey("Width") &&
                    info.CameraProperties.ContainsKey("Height") &&
                    info.CameraProperties.ContainsKey("AcquisitionFrameRate"))
                {
                    int    width     = int.Parse(info.CameraProperties["Width"].CurrentValue, CultureInfo.InvariantCulture);
                    int    height    = int.Parse(info.CameraProperties["Height"].CurrentValue, CultureInfo.InvariantCulture);
                    double framerate = DahengHelper.GetResultingFramerate(info.Device);
                    if (framerate == 0)
                    {
                        framerate = double.Parse(info.CameraProperties["AcquisitionFrameRate"].CurrentValue, CultureInfo.InvariantCulture);
                    }

                    result = string.Format("{0} - {1}×{2} @ {3:0.##} fps.", alias, width, height, framerate);
                }
                else
                {
                    result = string.Format("{0}", alias);
                }
            }
            catch
            {
                result = string.Format("{0}", alias);
            }

            return(result);
        }
Пример #3
0
        private void UpdateResultingFramerate()
        {
            float resultingFramerate = (float)DahengHelper.GetResultingFramerate(device);

            if (resultingFramerate == 0)
            {
                lblResultingFramerate.Visible      = false;
                lblResultingFramerateValue.Visible = false;
                return;
            }

            lblResultingFramerateValue.Text = string.Format("{0:0.##}", resultingFramerate);

            bool discrepancy = false;

            if (cameraProperties.ContainsKey("AcquisitionFrameRate") && cameraProperties["AcquisitionFrameRate"].Supported)
            {
                float framerate;
                bool  parsed = float.TryParse(cameraProperties["AcquisitionFrameRate"].CurrentValue, NumberStyles.Any, CultureInfo.InvariantCulture, out framerate);
                if (parsed && Math.Abs(framerate - resultingFramerate) > 1)
                {
                    discrepancy = true;
                }
            }

            lblResultingFramerateValue.ForeColor = discrepancy ? Color.Red : Color.Black;
        }