diff --git a/sw/airborne/boards/ardrone/board.c b/sw/airborne/boards/ardrone/board.c index cf802acc58..46b162fdae 100644 --- a/sw/airborne/boards/ardrone/board.c +++ b/sw/airborne/boards/ardrone/board.c @@ -34,6 +34,27 @@ #warning No battery voltage measurement available! Please add to your modules. #endif +#include "peripherals/video_device.h" + +struct video_device_t front_camera = { + .w = 1280, + .h = 720, + .dev_name = "/dev/video1", + .subdev_name = NULL, + .format = V4L2_PIX_FMT_UYVY, + .filters = NULL +}; + +struct video_device_t bottom_camera = { + .w = 320, + .h = 240, + .dev_name = "/dev/video2", + .subdev_name = NULL, + .format = V4L2_PIX_FMT_UYVY, + .filters = NULL +}; + + void board_init(void) { // First we try to kill the program.elf and its respawner if it is running diff --git a/sw/airborne/boards/ardrone2.h b/sw/airborne/boards/ardrone2.h index db17a0ac11..1e1c06d1df 100644 --- a/sw/airborne/boards/ardrone2.h +++ b/sw/airborne/boards/ardrone2.h @@ -3,10 +3,16 @@ #define BOARD_ARDRONE2 +#include "peripherals/video_device.h" + #ifndef UART1_DEV #define UART1_DEV /dev/ttyUSB0 #endif +/* Cameras */ +extern struct video_device_t bottom_camera; +extern struct video_device_t front_camera; + /* Default actuators driver */ #define DEFAULT_ACTUATORS "boards/ardrone/actuators.h" #define ActuatorDefaultSet(_x,_y) ActuatorArdroneSet(_x,_y) diff --git a/sw/airborne/boards/bebop.h b/sw/airborne/boards/bebop.h index 04158f6468..3938e23d57 100644 --- a/sw/airborne/boards/bebop.h +++ b/sw/airborne/boards/bebop.h @@ -25,6 +25,8 @@ #define BOARD_BEBOP +#include "peripherals/video_device.h" + /** uart connected to GPS internally */ #define UART1_DEV /dev/ttyPA1 @@ -34,6 +36,9 @@ #define ActuatorsDefaultInit() ActuatorsBebopInit() #define ActuatorsDefaultCommit() ActuatorsBebopCommit() +/* Cameras */ +extern struct video_device_t bottom_camera; +extern struct video_device_t front_camera; /* by default activate onboard baro */ #ifndef USE_BARO_BOARD diff --git a/sw/airborne/boards/bebop/video.c b/sw/airborne/boards/bebop/video.c index 4863542011..938ed75a42 100644 --- a/sw/airborne/boards/bebop/video.c +++ b/sw/airborne/boards/bebop/video.c @@ -37,6 +37,26 @@ #include #include +#include "boards/bebop.h" + +struct video_device_t bottom_camera = { + .w = 640, + .h = 480, + .dev_name = "/dev/video0", + .subdev_name = NULL, + .format = V4L2_PIX_FMT_UYVY, + .filters = NULL +}; + +struct video_device_t front_camera = { + .w = 1408, + .h = 2112, + .dev_name = "/dev/video1", + .subdev_name = "/dev/v4l-subdev1", + .format = V4L2_PIX_FMT_SGBRG10, + .filters = NULL //{DeMosaic, AEC, ABW} +}; + static bool_t write_reg(int fd, char *addr_val, uint8_t cnt) { char resp[cnt - 2]; diff --git a/sw/airborne/modules/computer_vision/lib/v4l/v4l2.h b/sw/airborne/modules/computer_vision/lib/v4l/v4l2.h index a42fb363e6..3d211a9448 100644 --- a/sw/airborne/modules/computer_vision/lib/v4l/v4l2.h +++ b/sw/airborne/modules/computer_vision/lib/v4l/v4l2.h @@ -33,7 +33,7 @@ #include #include "std.h" -#include "lib/vision/image.h" +#include "modules/computer_vision/lib/vision/image.h" #define V4L2_IMG_NONE 255 ///< There currently no image available diff --git a/sw/airborne/peripherals/video_device.h b/sw/airborne/peripherals/video_device.h new file mode 100644 index 0000000000..c45d4245db --- /dev/null +++ b/sw/airborne/peripherals/video_device.h @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2015 + * + * This file is part of Paparazzi. + * + * Paparazzi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * Paparazzi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with paparazzi; see the file COPYING. If not, see + * . + * + */ + +/** + * @file peripherals/video_device.h + * @brief v4l2 video device settings interface + * Works on Linux platforms + */ + +#ifndef VIDEO_DEVICE_H +#define VIDEO_DEVICE_H + +#include "std.h" +#include "modules/computer_vision/lib/v4l/v4l2.h" + +/** V4L2 device settings */ +struct video_device_t { + int w; ///< Width + int h; ///< Height + char* dev_name; ///< path to device + char* subdev_name; ///< path to sub device + uint32_t format; ///< Video format + void* filters; ///< filters to use +}; + + +#endif /* VIDEO_DEVICE_H */