Paparazzi UAS  v5.12_stable-4-g9b43e9b
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
video_thread_nps.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Tom van Dijk
3  *
4  * This file is part of Paparazzi.
5  *
6  * Paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * Paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Paparazzi; see the file COPYING. If not, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21 
29 // Own header
30 #include "video_thread_nps.h"
31 #include "video_thread.h"
32 #include "cv.h"
33 #include "lib/vision/image.h"
34 
37 
38 #include <stdio.h>
39 
40 // Camera structs for use in modules.
41 // See boards/pc_sim.h
42 // Default values from ARDrone can be overwritten by simulator.
44  .output_size = { .w = 1280, .h = 720 },
45  .sensor_size = { .w = 1280, .h = 720 },
46  .crop = { .x = 0, .y = 0, .w = 1280, .h = 720 },
47  .dev_name = "front_camera",
48  .subdev_name = NULL,
49  .format = V4L2_PIX_FMT_UYVY,
50  .buf_cnt = 10,
51  .filters = 0,
52  .cv_listener = NULL,
53  .fps = 0
54 };
55 
57  .output_size = { .w = 320, .h = 240 },
58  .sensor_size = { .w = 320, .h = 240 },
59  .crop = { .x = 0, .y = 0, .w = 320, .h = 240 },
60  .dev_name = "bottom_camera",
61  .subdev_name = NULL,
62  .format = V4L2_PIX_FMT_UYVY,
63  .buf_cnt = 10,
64  .filters = 0,
65  .cv_listener = NULL,
66  .fps = 0
67 };
68 
69 // Keep track of added devices.
71 
72 // All dummy functions
74 {
75 }
77 {
78 
79 }
80 
82 {
83 }
85 {
86 }
87 
91 bool add_video_device(struct video_config_t *device)
92 {
93  // Loop over camera array
94  for (int i = 0; i < VIDEO_THREAD_MAX_CAMERAS; ++i) {
95  // If device is already registered, break
96  if (cameras[i] == device) {
97  break;
98  }
99  // If camera slot is already used, continue
100  if (cameras[i] != NULL) {
101  continue;
102  }
103  // No initialization, should be handled by simulation!
104  // Store device pointer
105  cameras[i] = device;
106  // Debug statement
107  printf("[video_thread_nps] Added %s to camera array.\n",
108  device->dev_name);
109  // Successfully added
110  return true;
111  }
112  // Camera array is full
113  return false;
114 }
void video_thread_start(void)
Starts the streaming of a all cameras.
struct video_config_t bottom_camera
struct img_size_t output_size
Output image size.
Definition: video_device.h:45
Capture images from a V4L2 device (Video for Linux 2)
Start a Video thread and grab images.
struct video_config_t * cameras[VIDEO_THREAD_MAX_CAMERAS]
char * dev_name
path to device
Definition: video_device.h:48
void video_thread_stop(void)
Stops the streaming of all cameras This could take some time, because the thread is stopped asynchron...
void video_thread_init(void)
Initialize the view video.
Image helper functions like resizing, color filter, converters...
Computer vision framework for onboard processing.
This header gives NPS access to the list of added cameras.
void video_thread_periodic(void)
A dummy for now.
#define VIDEO_THREAD_MAX_CAMERAS
Definition: video_thread.c:65
bool add_video_device(struct video_config_t *device)
Keep track of video devices added by modules.
uint16_t w
The width.
Definition: image.h:74
V4L2 device settings.
Definition: video_device.h:44
struct video_config_t front_camera
Video thread dummy for simulation.