Skip to content

Commit

Permalink
[opticflow] dox
Browse files Browse the repository at this point in the history
  • Loading branch information
flixr committed Feb 5, 2015
1 parent 11d94d7 commit 5fd3808
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 21 deletions.
35 changes: 28 additions & 7 deletions sw/airborne/modules/computer_vision/opticflow/inter_thread_data.h
Original file line number Diff line number Diff line change
@@ -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
* <http://www.gnu.org/licenses/>.
*/

/**
* @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

Expand All @@ -22,14 +45,12 @@ 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]
float theta; // pitch [rad]
float agl; // height above ground [m]
};



#endif
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
*
*/



// Sockets
#include <stdio.h>
#include <unistd.h>
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 6 additions & 7 deletions sw/airborne/modules/computer_vision/opticflow/visual_estimator.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <stdio.h>
Expand Down Expand Up @@ -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--) {
Expand Down Expand Up @@ -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);

}

Original file line number Diff line number Diff line change
Expand Up @@ -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"

/**
Expand Down

0 comments on commit 5fd3808

Please sign in to comment.