/// <summary> /// Initialises a new MMALCameraComponent. /// </summary> public MMALCameraComponent() : base(MMALParameters.MMAL_COMPONENT_DEFAULT_CAMERA) { if (this.CameraInfo == null) { this.SetSensorDefaults(); } if (this.Outputs.Count == 0) { throw new PiCameraError("Camera doesn't have any output ports."); } this.PreviewPort = this.Outputs[MMALCameraPreviewPort]; this.VideoPort = this.Outputs[MMALCameraVideoPort]; this.StillPort = this.Outputs[MMALCameraStillPort]; /* * Stereoscopic mode is only supported with the compute module as it requires two camera modules to work. * I have added the code in for consistency with Raspistill, however this project currently only supports one camera module * and therefore will not work if enabled. * See: https://www.raspberrypi.org/forums/viewtopic.php?p=600720 */ this.PreviewPort.SetStereoMode(MMALCameraConfig.StereoMode); this.VideoPort.SetStereoMode(MMALCameraConfig.StereoMode); this.StillPort.SetStereoMode(MMALCameraConfig.StereoMode); this.Control.SetParameter(MMALParametersCamera.MMAL_PARAMETER_CAMERA_NUM, 0); var eventRequest = new MMAL_PARAMETER_CHANGE_EVENT_REQUEST_T( new MMAL_PARAMETER_HEADER_T(MMALParametersCommon.MMAL_PARAMETER_CHANGE_EVENT_REQUEST, Marshal.SizeOf <MMAL_PARAMETER_CHANGE_EVENT_REQUEST_T>()), MMALParametersCamera.MMAL_PARAMETER_CAMERA_SETTINGS, 1); if (MMALCameraConfig.SetChangeEventRequest) { this.Control.SetChangeEventRequest(eventRequest); } }
internal static void SetChangeEventRequest(this IControlPort controlPort, MMAL_PARAMETER_CHANGE_EVENT_REQUEST_T value) { MMALCheck(MMALPort.mmal_port_parameter_set(controlPort.Ptr, &value.Hdr), "Unable to set camera event request."); }
public MMALCameraComponent() : base(MMALParameters.MMAL_COMPONENT_DEFAULT_CAMERA) { if (this.CameraInfo == null) { this.SetSensorDefaults(); } if (this.Outputs.Count == 0) { throw new PiCameraError("Camera doesn't have any output ports."); } this.Control.ObjName = "Control port"; this.PreviewPort = this.Outputs[MMALCameraPreviewPort]; this.PreviewPort.ObjName = "Preview port"; this.VideoPort = this.Outputs[MMALCameraVideoPort]; this.VideoPort.ObjName = "Video port"; this.StillPort = this.Outputs[MMALCameraStillPort]; this.StillPort.ObjName = "Still port"; /* * Stereoscopic mode is only supported with the compute module as it requires two camera modules to work. * I have added the code in for consistency with Raspistill, however this project currently only supports one camera module * and therefore will not work if enabled. * See: https://www.raspberrypi.org/forums/viewtopic.php?p=600720 */ this.PreviewPort.SetStereoMode(MMALCameraConfig.StereoMode); this.VideoPort.SetStereoMode(MMALCameraConfig.StereoMode); this.StillPort.SetStereoMode(MMALCameraConfig.StereoMode); this.Control.SetParameter(MMALParametersCamera.MMAL_PARAMETER_CAMERA_NUM, 0); var eventRequest = new MMAL_PARAMETER_CHANGE_EVENT_REQUEST_T(new MMAL_PARAMETER_HEADER_T(MMALParametersCommon.MMAL_PARAMETER_CHANGE_EVENT_REQUEST, Marshal.SizeOf <MMAL_PARAMETER_CHANGE_EVENT_REQUEST_T>()), MMALParametersCamera.MMAL_PARAMETER_CAMERA_SETTINGS, 1); if (MMALCameraConfig.SetChangeEventRequest) { this.Control.SetChangeEventRequest(eventRequest); } var camConfig = new MMAL_PARAMETER_CAMERA_CONFIG_T(new MMAL_PARAMETER_HEADER_T(MMALParametersCamera.MMAL_PARAMETER_CAMERA_CONFIG, Marshal.SizeOf <MMAL_PARAMETER_CAMERA_CONFIG_T>()), this.CameraInfo.MaxWidth, this.CameraInfo.MaxHeight, 0, 1, MMALCameraConfig.VideoResolution.Width, MMALCameraConfig.VideoResolution.Height, 3 + Math.Max(0, (MMALCameraConfig.VideoFramerate.Num - 30) / 10), 0, 0, MMALCameraConfig.ClockMode ); MMALLog.Logger.Debug("Camera config set"); this.SetCameraConfig(camConfig); this.Control.EnablePort((Action <MMALBufferImpl, MMALPortBase>)CameraControlCallback); this.Initialise(); MMALLog.Logger.Debug("Camera component configured."); }