public void RgbtoYuvBytes() { var yuvBytes = MMALColor.RGBToYUVBytes(Color.Blue); var fromYuvBytes = MMALColor.FromYUVBytes(yuvBytes.Item1, yuvBytes.Item2, yuvBytes.Item3); Assert.True(fromYuvBytes.R == Color.Blue.R && fromYuvBytes.G == Color.Blue.G && fromYuvBytes.B == Color.Blue.B); }
public void SetThenGetColourFx(bool enable, byte u, byte v) { var color = MMALColor.FromYUVBytes(0, u, v); var colFx = new ColourEffects(enable, color); MMALCameraConfig.ColourFx = colFx; Fixture.MMALCamera.ConfigureCameraSettings(); var uv = MMALColor.RGBToYUVBytes(Fixture.MMALCamera.Camera.GetColourFx().Color); Assert.True(Fixture.MMALCamera.Camera.GetColourFx().Enable == enable && uv.Item2 == u && uv.Item3 == v); }
internal static void SetAnnotateSettings(this MMALCameraComponent camera) { if (MMALCameraConfig.Annotate != null) { MMALLog.Logger.Debug("Setting annotate"); var sb = new StringBuilder(); var showShutter = 0; var showAnalogGain = 0; var showLens = 0; var showCaf = 0; var showMotion = 0; var showFrame = 0; var enableTextBackground = 0; var textSize = (byte)0; var customTextColor = 0; var customTextY = (byte)0; var customTextU = (byte)0; var customTextV = (byte)0; var customBackgroundColor = 0; var customBackgroundY = (byte)0; var customBackgroundU = (byte)0; var customBackgroundV = (byte)0; if (!string.IsNullOrEmpty(MMALCameraConfig.Annotate.CustomText)) { sb.Append(MMALCameraConfig.Annotate.CustomText + " "); } if (MMALCameraConfig.Annotate.ShowTimeText) { sb.Append(DateTime.Now.ToString("HH:mm") + " "); } if (MMALCameraConfig.Annotate.ShowDateText) { sb.Append(DateTime.Now.ToString("dd/MM/yyyy") + " "); } if (MMALCameraConfig.Annotate.ShowShutterSettings) { showShutter = 1; } if (MMALCameraConfig.Annotate.ShowGainSettings) { showAnalogGain = 1; } if (MMALCameraConfig.Annotate.ShowLensSettings) { showLens = 1; } if (MMALCameraConfig.Annotate.ShowCafSettings) { showCaf = 1; } if (MMALCameraConfig.Annotate.ShowMotionSettings) { showMotion = 1; } if (MMALCameraConfig.Annotate.ShowFrameNumber) { showFrame = 1; } if (MMALCameraConfig.Annotate.ShowBlackBackground) { enableTextBackground = 1; } textSize = Convert.ToByte(MMALCameraConfig.Annotate.TextSize); if (MMALCameraConfig.Annotate.TextColour != Color.Empty) { customTextColor = 1; var yuv = MMALColor.RGBToYUVBytes(MMALCameraConfig.Annotate.TextColour); customTextY = yuv.Item1; customTextU = yuv.Item2; customTextV = yuv.Item3; } if (MMALCameraConfig.Annotate.BgColour != Color.Empty) { customBackgroundColor = 1; var yuv = MMALColor.RGBToYUVBytes(MMALCameraConfig.Annotate.BgColour); customBackgroundY = yuv.Item1; customBackgroundU = yuv.Item2; customBackgroundV = yuv.Item3; } string t = sb.ToString() + char.MinValue; var text = Encoding.ASCII.GetBytes(t); var str = new MMAL_PARAMETER_CAMERA_ANNOTATE_V3_T( new MMAL_PARAMETER_HEADER_T(MMAL_PARAMETER_ANNOTATE, Marshal.SizeOf <MMAL_PARAMETER_CAMERA_ANNOTATE_V3_T>() + t.Length), 1, showShutter, showAnalogGain, showLens, showCaf, showMotion, showFrame, enableTextBackground, customBackgroundColor, customBackgroundY, customBackgroundU, customBackgroundV, 0, customTextColor, customTextY, customTextU, customTextV, textSize, text); var ptr = Marshal.AllocHGlobal(Marshal.SizeOf <MMAL_PARAMETER_CAMERA_ANNOTATE_V3_T>()); Marshal.StructureToPtr(str, ptr, false); try { MMALCheck(MMALPort.mmal_port_parameter_set(camera.Control.Ptr, (MMAL_PARAMETER_HEADER_T *)ptr), "Unable to set annotate"); } finally { Marshal.FreeHGlobal(ptr); } } }