Paparazzi UAS  v5.8.2_stable-0-g6260b7c
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
video_thread.c File Reference
#include "modules/computer_vision/video_thread.h"
#include "modules/computer_vision/cv.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/time.h>
#include <math.h>
#include "lib/v4l/v4l2.h"
#include "lib/vision/image.h"
#include "lib/vision/bayer.h"
#include "lib/encoding/jpeg.h"
#include "peripherals/video_device.h"
#include "mcu_periph/sys_time.h"
#include <BOARD_CONFIG>
#include <pthread.h>
#include "rt_priority.h"
+ Include dependency graph for video_thread.c:

Go to the source code of this file.

Macros

#define VIDEO_THREAD_DEVICE_BUFFERS   10
 The camera video config (usually bottom_camera or front_camera) More...
 
#define VIDEO_THREAD_SUBDEV   NULL
 
#define VIDEO_THREAD_FILTERS   0
 
#define VIDEO_THREAD_CAMERA   custom_camera
 
#define VIDEO_THREAD_FPS   4
 
#define VIDEO_THREAD_SHOT_PATH   "/data/video/images"
 
#define IMG_FLT_SIZE   272
 

Functions

static void * video_thread_function (void *data)
 Handles all the video streaming and saving of the image shots This is a sepereate thread, so it needs to be thread safe! More...
 
void video_thread_periodic (void)
 A dummy for now. More...
 
static void video_thread_save_shot (struct image_t *img, struct image_t *img_jpeg)
 
void video_thread_init (void)
 Initialize the view video. More...
 
void video_thread_start (void)
 Start with streaming. More...
 
void video_thread_stop (void)
 Stops the streaming This could take some time, because the thread is stopped asynchronous. More...
 
void video_thread_take_shot (bool_t take)
 Take a shot and save it This will only work when the streaming is enabled. More...
 

Variables

struct video_config_t custom_camera
 
struct video_thread_t video_thread
 

Macro Definition Documentation

#define IMG_FLT_SIZE   272

Referenced by video_thread_function().

#define VIDEO_THREAD_CAMERA   custom_camera

Definition at line 79 of file video_thread.c.

Referenced by video_thread_function(), video_thread_init(), and video_thread_start().

#define VIDEO_THREAD_DEVICE_BUFFERS   10

The camera video config (usually bottom_camera or front_camera)

Definition at line 62 of file video_thread.c.

#define VIDEO_THREAD_FILTERS   0

Definition at line 69 of file video_thread.c.

#define VIDEO_THREAD_FPS   4

Definition at line 86 of file video_thread.c.

#define VIDEO_THREAD_SHOT_PATH   "/data/video/images"

Definition at line 92 of file video_thread.c.

Referenced by video_thread_init(), and video_thread_save_shot().

#define VIDEO_THREAD_SUBDEV   NULL

Definition at line 66 of file video_thread.c.

Function Documentation

static void * video_thread_function ( void *  data)
static

Handles all the video streaming and saving of the image shots This is a sepereate thread, so it needs to be thread safe!

Definition at line 145 of file video_thread.c.

References BayerToYUV(), cv_run(), video_thread_t::dev, FALSE, video_config_t::filters, video_thread_t::fps, video_config_t::h, image_create(), image_free(), IMAGE_JPEG, IMAGE_YUV422, IMG_FLT_SIZE, video_thread_t::is_running, v4l2_device::name, set_nice_level(), sys_time_elapsed_us(), video_thread_t::take_shot, TRUE, v4l2_image_free(), v4l2_image_get(), v4l2_start_capture(), VIDEO_FILTER_DEBAYER, VIDEO_THREAD_CAMERA, video_thread_save_shot(), and video_config_t::w.

Referenced by video_thread_start().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void video_thread_init ( void  )

Initialize the view video.

Definition at line 234 of file video_thread.c.

void video_thread_periodic ( void  )

A dummy for now.

Definition at line 98 of file video_thread.c.

static void video_thread_save_shot ( struct image_t img,
struct image_t img_jpeg 
)
static

Definition at line 108 of file video_thread.c.

References image_t::buf, image_t::buf_size, image_t::h, jpeg_encode_image(), video_thread_t::shot_number, TRUE, VIDEO_THREAD_SHOT_PATH, image_t::w, and write_exif_jpeg().

Referenced by video_thread_function().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void video_thread_start ( void  )

Start with streaming.

Definition at line 266 of file video_thread.c.

void video_thread_stop ( void  )

Stops the streaming This could take some time, because the thread is stopped asynchronous.

Definition at line 285 of file video_thread.c.

void video_thread_take_shot ( bool_t  take)

Take a shot and save it This will only work when the streaming is enabled.

Definition at line 308 of file video_thread.c.

Referenced by cv_blob_locator_periodic(), and dc_send_command().

+ Here is the caller graph for this function:

Variable Documentation

struct video_config_t custom_camera
Initial value:
= {
.w = VIDEO_THREAD_VIDEO_WIDTH,
.h = VIDEO_THREAD_VIDEO_HEIGHT,
.dev_name = STRINGIFY(VIDEO_THREAD_DEVICE),
.subdev_name = VIDEO_THREAD_SUBDEV,
}
#define VIDEO_THREAD_DEVICE_BUFFERS
The camera video config (usually bottom_camera or front_camera)
Definition: video_thread.c:62
#define VIDEO_THREAD_SUBDEV
Definition: video_thread.c:66
#define VIDEO_THREAD_FILTERS
Definition: video_thread.c:69

Definition at line 71 of file video_thread.c.

struct video_thread_t video_thread
Initial value:
= {
.is_running = FALSE,
.take_shot = FALSE,
.shot_number = 0
}
#define FALSE
Definition: std.h:5
#define VIDEO_THREAD_FPS
Definition: video_thread.c:86

Definition at line 101 of file video_thread.c.