private void SetBayerComboVisibility() { EPylonPixelType pixelType = Pylon.PixelTypeFromString(selectedStreamFormat.Symbol); bool isBayer8 = PylonHelper.IsBayer8(pixelType); cmbBayer8Conversion.Enabled = isBayer8; lblBayerConversion.Enabled = isBayer8; }
private void cmbBayerConversion_SelectedIndexChanged(object sender, EventArgs e) { EPylonPixelType pixelType = Pylon.PixelTypeFromString(selectedStreamFormat.Symbol); bool isBayer8 = PylonHelper.IsBayer8(pixelType); Bayer8Conversion selected = (Bayer8Conversion)cmbBayer8Conversion.SelectedIndex; if (selected == bayer8Conversion) { return; } bayer8Conversion = (Bayer8Conversion)cmbBayer8Conversion.SelectedIndex; specificChanged = true; }
/// <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 (deviceHandle == null || !deviceHandle.IsValid) { return(ImageDescriptor.Invalid); } firstOpen = false; // Get the configured framerate for recording support. resultingFramerate = PylonHelper.GetResultingFramerate(deviceHandle); SpecificInfo specific = summary.Specific as SpecificInfo; string streamFormatSymbol = specific.StreamFormat; bool hasWidth = Pylon.DeviceFeatureIsReadable(deviceHandle, "Width"); bool hasHeight = Pylon.DeviceFeatureIsReadable(deviceHandle, "Height"); bool hasPixelFormat = Pylon.DeviceFeatureIsReadable(deviceHandle, "PixelFormat"); bool canComputeImageDescriptor = hasWidth && hasHeight && hasPixelFormat; if (!canComputeImageDescriptor) { return(ImageDescriptor.Invalid); } int width = (int)Pylon.DeviceGetIntegerFeature(deviceHandle, "Width"); int height = (int)Pylon.DeviceGetIntegerFeature(deviceHandle, "Height"); string pixelFormat = Pylon.DeviceFeatureToString(deviceHandle, "PixelFormat"); EPylonPixelType pixelType = Pylon.PixelTypeFromString(pixelFormat); if (pixelType == EPylonPixelType.PixelType_Undefined) { return(ImageDescriptor.Invalid); } // Note: the image provider will perform the Bayer conversion itself and only output two formats. // - Y800 for anything monochrome. // - RGB32 for anything color. imageProvider.SetDebayering(specific.Bayer8Conversion); bool isBayer = Pylon.IsBayer(pixelType); bool isBayer8 = PylonHelper.IsBayer8(pixelType); bool bayerColor = (isBayer && !isBayer8) || (isBayer8 && specific.Bayer8Conversion == Bayer8Conversion.Color); bool color = !Pylon.IsMono(pixelType) || bayerColor; ImageFormat format = color ? ImageFormat.RGB32 : ImageFormat.Y800; finishline.Prepare(width, height, format, resultingFramerate); if (finishline.Enabled) { height = finishline.Height; resultingFramerate = finishline.ResultingFramerate; } int bufferSize = ImageFormatHelper.ComputeBufferSize(width, height, format); bool topDown = true; return(new ImageDescriptor(format, width, height, topDown, bufferSize)); }