void ConfigureVideoProfile(int outputPort) { var rational = new MmalRational(CameraConfig.Framerate); var macroblocks = (CameraConfig.Resolution.Width >> 4) * (CameraConfig.Resolution.Height >> 4); var macroblocksPSec = macroblocks * (rational.Num / rational.Den); var videoLevels = GetNormalLevelLimits(); var level = videoLevels.First(c => c.Level == CameraConfig.VideoLevel); if (macroblocks > level.MacroblocksLimit) { throw new PiCameraError("Resolution exceeds macroblock limit for selected profile and level."); } if (macroblocksPSec > level.MacroblocksPerSecLimit) { throw new PiCameraError("Resolution exceeds macroblocks/s limit for selected profile and level."); } var p = new MmalParameterVideoProfileS(CameraConfig.VideoProfile, CameraConfig.VideoLevel); var arr = new [] { p }; var param = new MmalParameterVideoProfileType(new MmalParameterHeaderType(MmalParametersVideo.MmalParameterProfile, Marshal.SizeOf <MmalParameterVideoProfileType>()), arr); var ptr = Marshal.AllocHGlobal(Marshal.SizeOf(param)); Marshal.StructureToPtr(param, ptr, false); try { MmalCheck(MmalPort.SetParameter(Outputs[outputPort].Ptr, (MmalParameterHeaderType *)ptr), "Unable to set video profile."); } finally { Marshal.FreeHGlobal(ptr); } }
internal static unsafe void SetFramerateRange(this IPort port, MmalRational fpsLow, MmalRational fpsHigh) { var str = new MmalParameterFpsRangeType( new MmalParameterHeaderType( MmalParametersCamera.MmalParameterFpsRange, Marshal.SizeOf <MmalParameterFpsRangeType>()), fpsLow, fpsHigh); MmalCheck(MmalPort.SetParameter(port.Ptr, &str.Hdr), "Unable to set framerate range for port."); }
public MmalVideoFormat(int width, int height, MmalRect crop, MmalRational frameRate, MmalRational par, int colorSpace) { Width = width; Height = height; Crop = crop; FrameRate = frameRate; Par = par; ColorSpace = colorSpace; }
public MmalParameterCameraSettingsType(MmalParameterHeaderType hdr, int exposure, MmalRational analogGain, MmalRational digitalGain, MmalRational awbRedGain, MmalRational awbBlueGain, int focusPosition) { Hdr = hdr; Exposure = exposure; AnalogGain = analogGain; DigitalGain = digitalGain; AwbRedGain = awbRedGain; AwbBlueGain = awbBlueGain; FocusPosition = focusPosition; }
internal static void SetBrightness(this MmalCameraComponent camera, int brightness) { MmalLog.Logger.LogDebug($"Setting brightness: {brightness}"); var value = new MmalRational(brightness, 100); if (brightness >= 0 && brightness <= 100) { camera.Control.SetParameter(MmalParameterBrightness, value); } else { throw new Exception("Invalid brightness value"); } }
internal static void SetContrast(this MmalCameraComponent camera, int contrast) { MmalLog.Logger.LogDebug($"Setting contrast: {contrast}"); var value = new MmalRational(contrast, 100); if (contrast >= -100 && contrast <= 100) { camera.Control.SetParameter(MmalParameterContrast, value); } else { throw new Exception("Invalid contrast value"); } }
internal static void SetSharpness(this MmalCameraComponent camera, int sharpness) { MmalLog.Logger.LogDebug($"Setting sharpness: {sharpness}"); var value = new MmalRational(sharpness, 100); if (sharpness >= -100 && sharpness <= 100) { camera.Control.SetParameter(MmalParameterSharpness, value); } else { throw new Exception("Invalid sharpness value"); } }
internal static void SetSaturation(this MmalCameraComponent camera, int saturation) { MmalLog.Logger.LogDebug($"Setting saturation: {saturation}"); var value = new MmalRational(saturation, 100); if (saturation >= -100 && saturation <= 100) { camera.Control.SetParameter(MmalParameterSaturation, value); } else { throw new Exception("Invalid saturation value"); } }
public MmalParameterAwbGainsType(MmalParameterHeaderType hdr, MmalRational rGain, MmalRational bGain) { Hdr = hdr; RGain = rGain; BGain = bGain; }
public MmalParameterFpsRangeType(MmalParameterHeaderType hdr, MmalRational fpsLow, MmalRational fpsHigh) { Hdr = hdr; FpsLow = fpsLow; FpsHigh = fpsHigh; }
public MmalParameterRationalType(MmalParameterHeaderType hdr, MmalRational value) { Hdr = hdr; Value = value; }