public object InterfaceControl(MIGInterfaceCommand request) { request.Response = ""; //default success value // if (request.Command == Command.CAMERA_GETPICTURE) { // get picture from camera <nodeid> // TODO: there is actually only single camera support if (cameraSource != IntPtr.Zero) { lock (this) { var pictureBuffer = CameraCaptureV4LInterop.GetFrame(cameraSource); var data = new byte[pictureBuffer.Size]; Marshal.Copy(pictureBuffer.Data, data, 0, pictureBuffer.Size); return(data); } } } else if (request.Command == Command.CAMERA_GETLUMINANCE) { // TODO: .... } else if (request.Command == Command.CAMERA_GETDEVICE) { //request.Response = JsonSerializeObject( cameraDevice ); } else if (request.Command == Command.CAMERA_SETDEVICE) { SetVideoInput(request.GetOption(0).Replace("|", "/"), uint.Parse(request.GetOption(1)), uint.Parse(request.GetOption(2)), uint.Parse(request.GetOption(3))); //request.Response = "OK"; // Utility.GetSimpleJson( ... ) } // return(request.Response); }
public object InterfaceControl(MIGInterfaceCommand request) { request.response = ""; //default success value // if (request.command == Command.CAMERA_GETPICTURE) { // get picture from camera <nodeid> // there is actually only single camera support though // TODO: check if file exists before opening it ("/dev/video0") if (_camerasource != IntPtr.Zero) { PictureBuffer pb = CameraCaptureV4LInterop.GetFrame(_camerasource); var data = new byte[pb.Size]; Marshal.Copy(pb.Data, data, 0, pb.Size); //System.IO.File.WriteAllBytes("html/test.jpg", data); return(data); } } else if (request.command == Command.CAMERA_GETLUMINANCE) { // TODO: .... } // return(request.response); }
public object InterfaceControl(MIGInterfaceCommand request) { request.Response = ""; //default success value // if (request.Command == Command.CAMERA_GETPICTURE) { // get picture from camera <nodeid> // TODO: there is actually only single camera support if (cameraSource != IntPtr.Zero) { lock (readPictureLock) { var pictureBuffer = CameraCaptureV4LInterop.GetFrame(cameraSource); var data = new byte[pictureBuffer.Size]; Marshal.Copy(pictureBuffer.Data, data, 0, pictureBuffer.Size); return(data); } } } else if (request.Command == Command.CAMERA_GETLUMINANCE) { // TODO: .... } else if (request.Command == Command.CAMERA_SETDEVICE) { this.GetOption("Configuration").Value = request.GetOption(0) + "," + request.GetOption(1) + "," + request.GetOption(2) + "," + request.GetOption(3); Connect(); } // return(request.Response); }
/// <summary> /// Connect to the automation interface/controller device. /// </summary> public bool Connect() { if (cameraSource != IntPtr.Zero) { Disconnect(); } if (this.GetOption("Configuration") != null && !string.IsNullOrEmpty(this.GetOption("Configuration").Value)) { var config = this.GetOption("Configuration").Value.Split(','); SetConfiguration(config[0], uint.Parse(config[1]), uint.Parse(config[2]), uint.Parse(config[3])); } cameraSource = CameraCaptureV4LInterop.OpenCameraStream(configuration.Device, configuration.Width, configuration.Height, configuration.Fps); if (InterfaceModulesChangedAction != null) { InterfaceModulesChangedAction(new InterfaceModulesChangedAction() { Domain = this.Domain }); } // InterfacePropertyChangedAction(new InterfacePropertyChangedAction() { Domain = this.Domain, SourceId = "AV0", SourceType = "Camera Input", Path = "Widget.DisplayModule", Value = "homegenie/generic/camerainput" }); // return(cameraSource != IntPtr.Zero); }
/// <summary> /// Disconnect the automation interface/controller device. /// </summary> public void Disconnect() { if (cameraSource != IntPtr.Zero) { CameraCaptureV4LInterop.CloseCameraStream(cameraSource); cameraSource = IntPtr.Zero; } }
/// <summary> /// Disconnect the automation interface/controller device. /// </summary> public void Disconnect() { Log.Debug($"{this.GetDomain()} Disconnecting"); if (this.cameraSource != IntPtr.Zero) { CameraCaptureV4LInterop.CloseCameraStream(this.cameraSource); this.cameraSource = IntPtr.Zero; } }
/// <summary> /// Connect to the automation interface/controller device. /// </summary> public bool Connect() { if (_camerasource != IntPtr.Zero) { Disconnect(); } _camerasource = CameraCaptureV4LInterop.OpenCameraStream("/dev/video0", 320, 240, 3); return(_camerasource != IntPtr.Zero); }
/// <summary> /// Connect to the automation interface/controller device. /// </summary> public bool Connect() { if (cameraSource != IntPtr.Zero) { Disconnect(); } if (this.GetOption("Configuration") != null && !string.IsNullOrEmpty(this.GetOption("Configuration").Value)) { var config = this.GetOption("Configuration").Value.Split(','); SetConfiguration(config[0], uint.Parse(config[1]), uint.Parse(config[2]), uint.Parse(config[3])); } cameraSource = CameraCaptureV4LInterop.OpenCameraStream(configuration.Device, configuration.Width, configuration.Height, configuration.Fps); OnInterfaceModulesChanged(this.GetDomain()); // TODO: Possibly move this event out of here... it's a HomeGenie specific event OnInterfacePropertyChanged(this.GetDomain(), "AV0", "Camera Input", "Widget.DisplayModule", "homegenie/generic/camerainput"); return(cameraSource != IntPtr.Zero); }
/// <summary> /// InterfaceControl /// </summary> /// <param name="request">request from web interface</param> /// <returns>object</returns> public object InterfaceControl(MigInterfaceCommand request) { string response = string.Empty; Commands command; Enum.TryParse <Commands>(request.Command.Replace(".", "_"), out command); switch (command) { case Commands.Camera_GetPicture: { // get picture from camera <nodeid> // TODO: there is actually only single camera support if (this.cameraSource != IntPtr.Zero) { lock (this.readPictureLock) { var pictureBuffer = CameraCaptureV4LInterop.GetFrame(this.cameraSource); var data = new byte[pictureBuffer.Size]; Marshal.Copy(pictureBuffer.Data, data, 0, pictureBuffer.Size); return(data); } } break; } case Commands.Camera_GetLuminance: // TODO: .... break; case Commands.Camera_SetDevice: this.GetOption("Configuration").Value = request.GetOption(0) + "," + request.GetOption(1) + "," + request.GetOption(2) + "," + request.GetOption(3); this.Connect(); break; } return(response); }
/// <summary> /// Connect to the automation interface/controller device. /// </summary> public bool Connect() { if (cameraSource != IntPtr.Zero) { Disconnect(); } /*SetVideoInput( * this.GetOption("Device"), * this.GetOption("Width"), * this.GetOption("Height"), * this.GetOption("Fps") * );*/ cameraSource = CameraCaptureV4LInterop.OpenCameraStream(videoInput.Device, videoInput.Width, videoInput.Height, videoInput.Fps); if (InterfaceModulesChangedAction != null) { InterfaceModulesChangedAction(new InterfaceModulesChangedAction() { Domain = this.Domain }); } return(cameraSource != IntPtr.Zero); }
/// <summary> /// Connect to the automation interface/controller device. /// </summary> /// <returns>boolean value indicating the status</returns> public bool Connect() { Log.Debug($"{this.GetDomain()} Connecting"); if (this.cameraSource != IntPtr.Zero) { Log.Debug($"{this.GetDomain()} invalid camera source"); this.Disconnect(); } if (this.GetOption("Configuration") != null && !string.IsNullOrEmpty(this.GetOption("Configuration").Value)) { var config = this.GetOption("Configuration").Value.Split(','); this.SetConfiguration(config[0], uint.Parse(config[1]), uint.Parse(config[2]), uint.Parse(config[3])); } Log.Debug($"{this.GetDomain()} Opening camera stream on {this.configuration.Device}"); this.cameraSource = CameraCaptureV4LInterop.OpenCameraStream(this.configuration.Device, this.configuration.Width, this.configuration.Height, this.configuration.Fps); this.OnInterfaceModulesChanged(this.GetDomain()); this.OnInterfacePropertyChanged(this.GetDomain(), "AV0", "Camera Input", "Widget.DisplayModule", "homegenie/generic/camerainput"); return(this.cameraSource != IntPtr.Zero); }