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 (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> // 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> /// 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); }