Paparazzi UAS  v5.15_devel-230-gc96ce27
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  .camera_intrinsics = {
55  .focal_x = 300,
56  .focal_y = 300,
57  .center_x = 1280 / 2,
58  .center_y = 720 / 2,
59  .Dhane_k = 1
60  }
61 };
62 
64  .output_size = { .w = 240, .h = 240 },
65  .sensor_size = { .w = 320, .h = 240 },
66  .crop = { .x = 40, .y = 0, .w = 240, .h = 240 },
67  .dev_name = "bottom_camera",
68  .subdev_name = NULL,
69  .format = V4L2_PIX_FMT_UYVY,
70  .buf_cnt = 10,
71  .filters = 0,
72  .cv_listener = NULL,
73  .fps = 0,
74  .camera_intrinsics = {
75  .focal_x = 350,
76  .focal_y = 350,
77  .center_x = 240 / 2,
78  .center_y = 240 / 2,
79  .Dhane_k = 1
80  }
81 };
82 
83 // Keep track of added devices.
85 
86 // All dummy functions
88 {
89 }
91 {
92 
93 }
94 
96 {
97 }
99 {
100 }
101 
105 bool add_video_device(struct video_config_t *device)
106 {
107  // Loop over camera array
108  for (int i = 0; i < VIDEO_THREAD_MAX_CAMERAS; ++i) {
109  // If device is already registered, break
110  if (cameras[i] == device) {
111  break;
112  }
113  // If camera slot is already used, continue
114  if (cameras[i] != NULL) {
115  continue;
116  }
117  // No initialization, should be handled by simulation!
118  // Store device pointer
119  cameras[i] = device;
120  // Debug statement
121  printf("[video_thread_nps] Added %s to camera array.\n",
122  device->dev_name);
123  // Successfully added
124  return true;
125  }
126  // Camera array is full
127  return false;
128 }
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:56
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:59
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:63
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:75
V4L2 device settings.
Definition: video_device.h:55
struct video_config_t front_camera
Video thread dummy for simulation.