Skip to content

Commit

Permalink
Merge branch 'computervisionframework' Closes #1328
Browse files Browse the repository at this point in the history
Conflicts:
	conf/airframes/BR/bebop_indi.xml
	sw/airborne/modules/computer_vision/viewvideo.c
  • Loading branch information
dewagter committed Sep 4, 2015
2 parents 635e8fc + cf7b87a commit 0bb6810
Show file tree
Hide file tree
Showing 20 changed files with 577 additions and 250 deletions.
12 changes: 7 additions & 5 deletions conf/airframes/BR/bebop_default.xml
Expand Up @@ -30,16 +30,18 @@
<!--load name="logger_file.xml">
<define name="FILE_LOGGER_PATH" value="/data/ftp/internal_000"/>
</load-->
<load name="video_rtp_stream.xml">
<define name="VIEWVIDEO_FPS" value="60"/>
<define name="VIEWVIDEO_QUALITY_FACTOR" value="80"/>
<define name="VIEWVIDEO_DOWNSIZE_FACTOR" value="1"/>
<load name="video_thread.xml">
<define name="VIEWVIDEO_FPS" value="4"/>
<define name="VIEWVIDEO_DEVICE" value="/dev/video0"/>
<define name="VIEWVIDEO_SUBDEV" value="/dev/v4l-subdev0"/>
<define name="VIEWVIDEO_DEVICE_SIZE" value="320,240"/>
<define name="VIEWVIDEO_DEVICE_SIZE" value="640,480"/>
<define name="VIEWVIDEO_DEVICE_BUFFERS" value="60"/>
<define name="VIEWVIDEO_SHOT_PATH" value="/data/ftp/internal_000/images"/>
</load>
<load name="video_rtp_stream.xml">
<define name="VIEWVIDEO_QUALITY_FACTOR" value="80"/>
<define name="VIEWVIDEO_DOWNSIZE_FACTOR" value="1"/>
</load>
</modules>

<commands>
Expand Down
16 changes: 5 additions & 11 deletions conf/airframes/BR/bebop_indi.xml
Expand Up @@ -35,18 +35,18 @@
<!--load name="logger_file.xml">
<define name="FILE_LOGGER_PATH" value="/data/ftp/internal_000"/>
</load-->
<load name="video_rtp_stream.xml">
<load name="video_thread.xml">
<define name="VIEWVIDEO_FPS" value="4"/>
<define name="VIEWVIDEO_QUALITY_FACTOR" value="80"/>
<define name="VIEWVIDEO_DOWNSIZE_FACTOR" value="1"/>
<define name="VIEWVIDEO_DEVICE" value="/dev/video0"/>
<define name="VIEWVIDEO_SUBDEV" value="/dev/v4l-subdev0"/>
<define name="VIEWVIDEO_DEVICE_SIZE" value="640,480"/>
<define name="VIEWVIDEO_DEVICE_BUFFERS" value="60"/>
<define name="VIEWVIDEO_SHOT_PATH" value="/data/ftp/internal_000/images"/>
</load>
<load name="nav_survey_rectangle_rotorcraft.xml"/>
<load name="digital_cam_video.xml"/>
<load name="video_rtp_stream.xml">
<define name="VIEWVIDEO_QUALITY_FACTOR" value="80"/>
<define name="VIEWVIDEO_DOWNSIZE_FACTOR" value="1"/>
</load>
</modules>

<commands>
Expand Down Expand Up @@ -206,19 +206,13 @@
<section name="GUIDANCE_H" prefix="GUIDANCE_H_">
<!-- Good weather -->
<define name="MAX_BANK" value="20" unit="deg"/>
<define name="REF_MAX_SPEED" value="2" unit="m/s"/>
<!-- Bad weather -->
<!-- define name="MAX_BANK" value="32" unit="deg"/ -->
<define name="PGAIN" value="15"/>
<define name="DGAIN" value="100"/>
<define name="IGAIN" value="30"/>
</section>

<section name="NAVIGATION" prefix="NAV_">
<define name="CLIMB_VSPEED" value="2.5" />
<define name="DESCEND_VSPEED" value="-1.0" />
</section>

<section name="SIMULATOR" prefix="NPS_">
<define name="ACTUATOR_NAMES" value="nw_motor, ne_motor, se_motor, sw_motor" type="string[]"/>
<define name="JSBSIM_MODEL" value="simple_x_quad_ccw" type="string"/>
Expand Down
1 change: 1 addition & 0 deletions conf/airframes/ENAC/quadrotor/ard2_base_digit.xml
Expand Up @@ -36,6 +36,7 @@
<load name="agl_dist.xml">
<define name="USE_SONAR"/>
</load>
<load name="video_thread.xml"/>
<load name="video_rtp_stream.xml">
<configure name="VIEWVIDEO_USE_NC" value="TRUE"/>
</load>
Expand Down
1 change: 1 addition & 0 deletions conf/airframes/ENAC/quadrotor/ard2_base_vision.xml
Expand Up @@ -36,6 +36,7 @@
<load name="agl_dist.xml">
<define name="USE_SONAR"/>
</load>
<load name="video_thread.xml"/>
<load name="video_rtp_stream.xml">
<define name="VIDEO_SOCK_OUT_OFFSET" value="$(AC_ID)"/>
<define name="VIDEO_DOWNSIZE_FACTOR" value="2"/>
Expand Down
2 changes: 1 addition & 1 deletion conf/airframes/TUDelft/conf.xml
Expand Up @@ -51,7 +51,7 @@
telemetry="telemetry/default_rotorcraft.xml"
flight_plan="flight_plans/rotorcraft_basic.xml"
settings="settings/rotorcraft_basic.xml settings/control/rotorcraft_guidance.xml settings/estimation/ahrs_float_mlkf.xml settings/control/stabilization_att_int_quat.xml"
settings_modules="modules/geo_mag.xml modules/air_data.xml modules/video_rtp_stream.xml"
settings_modules="modules/geo_mag.xml modules/air_data.xml modules/video_thread.xml modules/video_rtp_stream.xml"
gui_color="green"
/>
<aircraft
Expand Down
1 change: 1 addition & 0 deletions conf/airframes/examples/ardrone2.xml
Expand Up @@ -32,6 +32,7 @@
<load name="air_data.xml"/>
<load name="geo_mag.xml"/>
<!--load name="logger_file.xml"/-->
<!--load name="video_thread.xml"/-->
<!--load name="video_rtp_stream.xml"/-->
</modules>

Expand Down
9 changes: 6 additions & 3 deletions conf/airframes/examples/bebop.xml
Expand Up @@ -7,6 +7,7 @@

<target name="nps" board="pc">
<subsystem name="fdm" type="jsbsim"/>
<subsystem name="udp"/>
</target>

<!--define name="USE_SONAR" value="TRUE"/-->
Expand All @@ -30,16 +31,18 @@
<!--load name="logger_file.xml">
<define name="FILE_LOGGER_PATH" value="/data/ftp/internal_000"/>
</load-->
<load name="video_rtp_stream.xml">
<load name="video_thread.xml">
<define name="VIEWVIDEO_FPS" value="4"/>
<define name="VIEWVIDEO_QUALITY_FACTOR" value="80"/>
<define name="VIEWVIDEO_DOWNSIZE_FACTOR" value="1"/>
<define name="VIEWVIDEO_DEVICE" value="/dev/video0"/>
<define name="VIEWVIDEO_SUBDEV" value="/dev/v4l-subdev0"/>
<define name="VIEWVIDEO_DEVICE_SIZE" value="640,480"/>
<define name="VIEWVIDEO_DEVICE_BUFFERS" value="60"/>
<define name="VIEWVIDEO_SHOT_PATH" value="/data/ftp/internal_000/images"/>
</load>
<load name="video_rtp_stream.xml">
<define name="VIEWVIDEO_QUALITY_FACTOR" value="80"/>
<define name="VIEWVIDEO_DOWNSIZE_FACTOR" value="1"/>
</load>
</modules>

<commands>
Expand Down
2 changes: 2 additions & 0 deletions conf/boards/pc.makefile
Expand Up @@ -12,3 +12,5 @@ BOARD_CFG = \"boards/pc_sim.h\"

$(TARGET).ARCHDIR = $(ARCH)

MODEM_HOST ?= 127.0.0.1

2 changes: 1 addition & 1 deletion conf/modules/digital_cam_video.xml
Expand Up @@ -34,7 +34,7 @@
</dl_settings>
</settings>

<depends>video_rtp_stream</depends>
<depends>video_thread</depends>

<conflicts>digital_cam,digital_cam_servo,digital_cam_i2c,digital_cam_uart</conflicts>

Expand Down
2 changes: 2 additions & 0 deletions conf/modules/video_exif.xml
Expand Up @@ -10,6 +10,8 @@
</description>
</doc>

<depends>video_thread</depends>

<header>
<file name="lib/exif/exif_module.h"/>
</header>
Expand Down
25 changes: 4 additions & 21 deletions conf/modules/video_rtp_stream.xml
Expand Up @@ -8,43 +8,32 @@
- Sends a RTP/UDP stream of the camera
- Possibility to save an image(shot) on the internal memory (JPEG, full size, best quality)
</description>
<define name="VIEWVIDEO_DEVICE" value="/dev/video1" description="The video device to capture from"/>
<define name="VIEWVIDEO_DEVICE_SIZE" value="1280,720" description="Video capture size (width, height)"/>
<define name="VIEWVIDEO_DEVICE_BUFFERS" value="10" description="Amount of V4L2 image buffers"/>
<define name="VIEWVIDEO_DOWNSIZE_FACTOR" value="4" description="Reduction factor of the video stream"/>
<define name="VIEWVIDEO_QUALITY_FACTOR" value="50" description="JPEG encoding compression factor [0-99]"/>
<define name="VIEWVIDEO_FPS" value="4" description="Video stream frame rate"/>
<define name="VIEWVIDEO_SHOT_PATH" value="/data/video/images" description="Path where the images should be saved"/>
<define name="VIEWVIDEO_USE_NETCAT" value="FALSE|TRUE" description="Use netcat for transfering images (default: FALSE)"/>
<define name="VIEWVIDEO_USE_RTP" value="TRUE|FALSE" description="Use RTP for transfering images (default: TRUE)"/>
</doc>
<settings>
<dl_settings>
<dl_settings name="video">
<dl_setting var="viewvideo.take_shot" min="0" step="1" max="1" shortname="take_shot" module="computer_vision/viewvideo" handler="take_shot">
<strip_button name="Shoot" icon="digital-camera.png" value="1" group="video"/>
</dl_setting>
<dl_setting var="viewvideo.use_rtp" min="0" step="1" max="1" values="FALSE|TRUE" shortname="rtp" module="computer_vision/viewvideo" param="VIEWVIDEO_USE_RTP"/>
</dl_settings>
</dl_settings>
</settings>

<depends>video_thread</depends>
<header>
<file name="viewvideo.h"/>
</header>

<init fun="viewvideo_init()"/>
<periodic fun="viewvideo_periodic()" freq="1" start="viewvideo_start()" stop="viewvideo_stop()" autorun="TRUE"/>
<makefile target="ap">
<makefile target="ap|nps">

<file name="viewvideo.c"/>

<!-- Include the needed Computer Vision files -->
<define name="modules/computer_vision" type="include"/>
<file name="image.c" dir="modules/computer_vision/lib/vision"/>
<file name="jpeg.c" dir="modules/computer_vision/lib/encoding"/>
<file name="rtp.c" dir="modules/computer_vision/lib/encoding"/>
<file name="v4l2.c" dir="modules/computer_vision/lib/v4l"/>

<!-- Define the network connection to send images over -->
<raw>
Expand All @@ -55,17 +44,11 @@
VIEWVID_CFLAGS = -DVIEWVIDEO_HOST=$(VIEWVIDEO_HOST) -DVIEWVIDEO_PORT_OUT=$(VIEWVIDEO_PORT_OUT)
ifeq ($(VIEWVIDEO_USE_NC),)
ap.CFLAGS += $(VIEWVID_CFLAGS) -DVIEWVIDEO_BROADCAST=$(VIEWVIDEO_BROADCAST)
nps.CFLAGS += $(VIEWVID_CFLAGS) -DVIEWVIDEO_BROADCAST=FALSE
else
ap.CFLAGS += $(VIEWVID_CFLAGS) -DVIEWVIDEO_USE_NC
$(TARGET).CFLAGS += $(VIEWVID_CFLAGS) -DVIEWVIDEO_USE_NC
endif
</raw>

<!-- Random flags -->
<define name="__USE_GNU"/>
<flag name="LDFLAGS" value="lrt"/>
<flag name="LDFLAGS" value="static-libgcc"/>
</makefile>
<makefile target="nps">
<file name="viewvideo_nps.c"/>
</makefile>
</module>
56 changes: 56 additions & 0 deletions conf/modules/video_thread.xml
@@ -0,0 +1,56 @@
<!DOCTYPE module SYSTEM "module.dtd">

<module name="video_thread" dir="computer_vision">
<doc>
<description>
Video streaming for Linux devices

- Sends a RTP/UDP stream of the camera
- Possibility to save an image(shot) on the internal memory (JPEG, full size, best quality)
</description>
<define name="video_thread_DEVICE" value="/dev/video1" description="The video device to capture from"/>
<define name="video_thread_DEVICE_SIZE" value="1280,720" description="Video capture size (width, height)"/>
<define name="video_thread_DEVICE_BUFFERS" value="10" description="Amount of V4L2 image buffers"/>
<define name="video_thread_FPS" value="4" description="Video stream frame rate"/>
<define name="video_thread_SHOT_PATH" value="/data/video/images" description="Path where the images should be saved"/>
</doc>
<settings>
<dl_settings>
<dl_settings name="video">
<dl_setting var="video_thread.take_shot" min="0" step="1" max="1" shortname="take_shot" module="computer_vision/video_thread" handler="take_shot">
<strip_button name="Shoot" icon="digital-camera.png" value="1" group="video"/>
</dl_setting>
</dl_settings>
</dl_settings>
</settings>

<header>
<file name="video_thread.h"/>
</header>

<init fun="video_thread_init()"/>
<periodic fun="video_thread_periodic()" freq="1" start="video_thread_start()" stop="video_thread_stop()" autorun="TRUE"/>
<makefile target="ap">

<file name="video_thread.c"/>
<file name="cv.c"/>

<!-- Include the needed Computer Vision files -->
<define name="modules/computer_vision" type="include"/>
<file name="image.c" dir="modules/computer_vision/lib/vision"/>
<file name="v4l2.c" dir="modules/computer_vision/lib/v4l"/>
<file name="jpeg.c" dir="modules/computer_vision/lib/encoding"/>

<!-- Random flags -->
<define name="__USE_GNU"/>
<flag name="LDFLAGS" value="lrt"/>
<flag name="LDFLAGS" value="static-libgcc"/>
</makefile>
<makefile target="nps">
<file name="video_thread_nps.c"/>
<file name="cv.c"/>
<file name="image.c" dir="modules/computer_vision/lib/vision"/>
<file name="jpeg.c" dir="modules/computer_vision/lib/encoding"/>
<flag name="LDFLAGS" value="lpthread"/>
</makefile>
</module>
48 changes: 48 additions & 0 deletions sw/airborne/modules/computer_vision/cv.c
@@ -0,0 +1,48 @@
/*
* 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
* <http://www.gnu.org/licenses/>.
*
*/

/**
* @file modules/computer_vision/cv.c
*
* Computer vision framework for onboard processing
*/

#include "cv.h"

#define MAX_CV_FUNC 10

int cv_func_cnt = 0;
cvFunction cv_func[MAX_CV_FUNC];

void cv_add(cvFunction func)
{
if (cv_func_cnt < (MAX_CV_FUNC - 1)) {
cv_func[cv_func_cnt] = func;
cv_func_cnt++;
}
}

void cv_run(struct image_t *img)
{
for (int i = 0; i < cv_func_cnt; i++) {
cv_func[i](img);
}
}
40 changes: 40 additions & 0 deletions sw/airborne/modules/computer_vision/cv.h
@@ -0,0 +1,40 @@
/*
* 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
* <http://www.gnu.org/licenses/>.
*
*/

/**
* @file modules/computer_vision/cv.h
*
* Computer vision framework for onboard processing
*/


#ifndef CV_H_
#define CV_H_

#include "std.h"
#include "lib/vision/image.h"

typedef bool_t (*cvFunction)(struct image_t *img);

extern void cv_add(cvFunction func);
extern void cv_run(struct image_t *img);

#endif /* CV_H_ */

0 comments on commit 0bb6810

Please sign in to comment.