From 5fd3808a39b2025eca85d175bea637e84b3340d6 Mon Sep 17 00:00:00 2001 From: Felix Ruess Date: Thu, 5 Feb 2015 21:59:46 +0100 Subject: [PATCH] [opticflow] dox --- .../opticflow/inter_thread_data.h | 35 +++++++++++++++---- .../opticflow/opticflow_thread.c | 7 ++-- .../opticflow/opticflow_thread.h | 6 +++- .../opticflow/visual_estimator.c | 13 ++++--- .../opticflow/visual_estimator.h | 5 ++- 5 files changed, 45 insertions(+), 21 deletions(-) diff --git a/sw/airborne/modules/computer_vision/opticflow/inter_thread_data.h b/sw/airborne/modules/computer_vision/opticflow/inter_thread_data.h index e28f44ab2fb..65ef0cb41e0 100644 --- a/sw/airborne/modules/computer_vision/opticflow/inter_thread_data.h +++ b/sw/airborne/modules/computer_vision/opticflow/inter_thread_data.h @@ -1,12 +1,35 @@ +/* + * Copyright (C) 2015 The Paparazzi Community + * + * 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 modules/computer_vision/opticflow/inter_thread_data.h + * @brief Inter-thread data structures. + * + * Data structures used to for inter-thread communication via Unix Domain sockets. + */ #ifndef _INTER_THREAD_DATA_H #define _INTER_THREAD_DATA_H - -// Inter-thread communication: Unix Socket - -// Data from thread to module +/// Data from thread to module struct CVresults { int cnt; // Number of processed frames @@ -22,7 +45,7 @@ struct CVresults { float FPS; }; -// Data from module to thread +/// Data from module to thread struct PPRZinfo { int cnt; // IMU msg counter float phi; // roll [rad] @@ -30,6 +53,4 @@ struct PPRZinfo { float agl; // height above ground [m] }; - - #endif diff --git a/sw/airborne/modules/computer_vision/opticflow/opticflow_thread.c b/sw/airborne/modules/computer_vision/opticflow/opticflow_thread.c index d5d8e46e7f3..0566279f1b8 100644 --- a/sw/airborne/modules/computer_vision/opticflow/opticflow_thread.c +++ b/sw/airborne/modules/computer_vision/opticflow/opticflow_thread.c @@ -23,8 +23,6 @@ * */ - - // Sockets #include #include @@ -74,7 +72,10 @@ void *computervision_thread_main(void *args) // Video Input struct vid_struct vid; - vid.device = (char *)"/dev/video2"; // video1 = front camera; video2 = bottom camera + /* On ARDrone2: + * video1 = front camera; video2 = bottom camera + */ + vid.device = (char *)"/dev/video2"; vid.w = 320; vid.h = 240; vid.n_buffers = 4; diff --git a/sw/airborne/modules/computer_vision/opticflow/opticflow_thread.h b/sw/airborne/modules/computer_vision/opticflow/opticflow_thread.h index 06ad218cae5..5826da2229b 100644 --- a/sw/airborne/modules/computer_vision/opticflow/opticflow_thread.h +++ b/sw/airborne/modules/computer_vision/opticflow/opticflow_thread.h @@ -22,8 +22,12 @@ * @file modules/computer_vision/opticflow/opticflow_thread.h * @brief computer vision thread * - */ + */ +#ifndef OPTICFLOW_THREAD_H +#define OPTICFLOW_THREAD_H void *computervision_thread_main(void *args); /* computer vision thread: should be given a pointer to a socketpair as argument */ void computervision_thread_request_exit(void); + +#endif diff --git a/sw/airborne/modules/computer_vision/opticflow/visual_estimator.c b/sw/airborne/modules/computer_vision/opticflow/visual_estimator.c index cb10364ca73..48bd4ffd5d2 100644 --- a/sw/airborne/modules/computer_vision/opticflow/visual_estimator.c +++ b/sw/airborne/modules/computer_vision/opticflow/visual_estimator.c @@ -20,13 +20,13 @@ /** * @file modules/computer_vision/opticflow/visual_estimator.c - * @brief optical-flow based hovering for Parrot AR.Drone 2.0 + * @brief Estimate velocity from optic flow. * - * Sensors from vertical camera and IMU of Parrot AR.Drone 2.0 + * Using sensors from vertical camera and IMU of Parrot AR.Drone 2.0. + * + * Warning: all this code is called form the Vision-Thread: do not access any autopilot data in here. */ -// Warning: all this code is called form the Vision-Thread: do not access any autopilot data in here. - #include "std.h" #include @@ -185,8 +185,8 @@ void opticflow_plugin_run(unsigned char *frame, struct PPRZinfo* info, struct CV // ************************************************************************************* CvtYUYV2Gray(visual_estimator.gray_frame, frame, w, h); - opticFlowLK(visual_estimator.gray_frame, visual_estimator.prev_gray_frame, x, y, count_fil, w, - h, new_x, new_y, status, 5, 100); + opticFlowLK(visual_estimator.gray_frame, visual_estimator.prev_gray_frame, x, y, + count_fil, w, h, new_x, new_y, status, 5, 100); results->flow_count = count_fil; for (int i = count_fil - 1; i >= 0; i--) { @@ -281,4 +281,3 @@ void opticflow_plugin_run(unsigned char *frame, struct PPRZinfo* info, struct CV memcpy(visual_estimator.prev_gray_frame, visual_estimator.gray_frame, w * h); } - diff --git a/sw/airborne/modules/computer_vision/opticflow/visual_estimator.h b/sw/airborne/modules/computer_vision/opticflow/visual_estimator.h index 5fef180b6d7..f499ffd320a 100644 --- a/sw/airborne/modules/computer_vision/opticflow/visual_estimator.h +++ b/sw/airborne/modules/computer_vision/opticflow/visual_estimator.h @@ -20,15 +20,14 @@ /** * @file modules/computer_vision/opticflow/visual_estimator.h - * @brief optical-flow based hovering for Parrot AR.Drone 2.0 + * @brief Estimate velocity from optic flow. * - * Sensors from vertical camera and IMU of Parrot AR.Drone 2.0 + * Using sensors from vertical camera and IMU of Parrot AR.Drone 2.0 */ #ifndef VISUAL_ESTIMATOR_H #define VISUAL_ESTIMATOR_H - #include "inter_thread_data.h" /**