49 #if JPEG_WITH_EXIF_HEADER
58 #ifndef VIDEO_THREAD_CAMERA
59 #warning "Are you sure you don't want to use the bottom_camera or front_camera?"
61 #ifndef VIDEO_THREAD_DEVICE_BUFFERS
62 #define VIDEO_THREAD_DEVICE_BUFFERS 10
65 #ifndef VIDEO_THREAD_SUBDEV
66 #define VIDEO_THREAD_SUBDEV NULL
68 #ifndef VIDEO_THREAD_FILTERS
69 #define VIDEO_THREAD_FILTERS 0
72 .
w = VIDEO_THREAD_VIDEO_WIDTH,
73 .h = VIDEO_THREAD_VIDEO_HEIGHT,
74 .dev_name = STRINGIFY(VIDEO_THREAD_DEVICE),
79 #define VIDEO_THREAD_CAMERA custom_camera
85 #ifndef VIDEO_THREAD_FPS
86 #define VIDEO_THREAD_FPS 4
91 #ifndef VIDEO_THREAD_SHOT_PATH
92 #define VIDEO_THREAD_SHOT_PATH "/data/video/images"
116 if (access(save_name, F_OK) == -1) {
121 #if JPEG_WITH_EXIF_HEADER
124 FILE *fp = fopen(save_name,
"w");
126 printf(
"[video_thread-thread] Could not write shot %s.\n", save_name);
155 #define IMG_FLT_SIZE 272
165 printf(
"[video_thread-thread] Could not start capture of %s.\n", video_thread.
dev->
name);
173 struct timespec time_now;
174 struct timespec time_prev;
175 clock_gettime(CLOCK_MONOTONIC, &time_prev);
182 clock_gettime(CLOCK_MONOTONIC, &time_now);
184 time_prev = time_now;
188 if (dt_us < fps_period_us) {
189 usleep(fps_period_us - dt_us);
192 fprintf(stderr,
"video_thread: desired %i fps, only managing %.1f fps\n",
193 video_thread.
fps, 1000000.f / dt_us);
201 struct image_t *img_final = &img;
209 img_final = &img_color;
242 printf(
"[video_thread] Could not initialize the %s subdevice.\n", vid->
subdev_name);
249 if (video_thread.
dev == NULL) {
250 printf(
"[video_thread] Could not initialize the %s V4L2 device.\n", vid->
dev_name);
257 if (system(save_name) != 0) {
276 printf(
"[vievideo] Could not create streaming thread.\n");
297 printf(
"[video_thread] Could not stop capture of %s.\n", video_thread.
dev->
name);
#define VIDEO_THREAD_DEVICE_BUFFERS
The camera video config (usually bottom_camera or front_camera)
uint32_t format
Video format.
void video_thread_stop(void)
Stops the streaming This could take some time, because the thread is stopped asynchronous.
static void video_thread_save_shot(struct image_t *img, struct image_t *img_jpeg)
uint32_t buf_size
The buffer size.
bool_t v4l2_start_capture(struct v4l2_device *dev)
Start capturing images in streaming mode (Thread safe)
void v4l2_image_free(struct v4l2_device *dev, struct image_t *img)
Free the image and enqueue the buffer (Thread safe) This must be done after processing the image...
struct video_config_t custom_camera
void v4l2_image_get(struct v4l2_device *dev, struct image_t *img)
Get the latest image buffer and lock it (Thread safe, BLOCKING) This functions blocks until image acc...
void image_free(struct image_t *img)
Free the image.
Capture images from a V4L2 device (Video for Linux 2)
#define VIDEO_THREAD_CAMERA
void image_create(struct image_t *img, uint16_t width, uint16_t height, enum image_type type)
Create a new image.
Start a Video thread and grab images.
bool_t v4l2_stop_capture(struct v4l2_device *dev)
Stop capturing of the image stream (Thread safe) This function is blocking until capturing thread is ...
char * dev_name
path to device
uint8_t filters
filters to use (bitfield with VIDEO_FILTER_x)
Functions to obtain rt priority or set the nice level.
uint8_t buf_cnt
Amount of V4L2 video device buffers.
void jpeg_encode_image(struct image_t *in, struct image_t *out, uint32_t quality_factor, bool_t add_dri_header)
Encode an YUV422 image.
Image helper functions like resizing, color filter, converters...
#define VIDEO_THREAD_SUBDEV
Architecture independent timing functions.
int write_exif_jpeg(char *filename, const unsigned char *image_jpg, const unsigned int image_jpg_len, const unsigned int image_jpg_x, const unsigned int image_jpg_y)
void video_thread_init(void)
Initialize the view video.
void BayerToYUV(struct image_t *Input, struct image_t *out, int RedX, int RedY)
Decode Bayer Pattern.
Computer vision framework for onboard processing.
char * subdev_name
path to sub device
void * buf
Image buffer (depending on the image_type)
static unsigned int sys_time_elapsed_us(struct timespec *prev, struct timespec *now)
elapsed time in microsecs between two timespecs
#define VIDEO_FILTER_DEBAYER
volatile bool_t is_running
When the device is running.
void video_thread_take_shot(bool_t take)
Take a shot and save it This will only work when the streaming is enabled.
static void * video_thread_function(void *data)
Handles all the video streaming and saving of the image shots This is a sepereate thread...
bool_t v4l2_init_subdev(char *subdev_name, uint8_t pad, uint8_t which, uint16_t code, uint16_t width, uint16_t height)
Initialize a V4L2 subdevice.
Encode images with the use of the JPEG encoding.
#define VIDEO_THREAD_FILTERS
char * name
The name of the device.
uint16_t shot_number
The last shot number.
volatile bool_t take_shot
Wether to take an image.
UYVY format (uint16 per pixel)
v4l2 video device settings interface Works on Linux platforms
#define VIDEO_THREAD_SHOT_PATH
void cv_run(struct image_t *img)
uint8_t fps
The amount of frames per second.
struct v4l2_device * dev
The V4L2 device that is used for the video stream.
Write JPEG images containing EXIF headers with GPS coordinates.
void video_thread_start(void)
Start with streaming.
static int set_nice_level(int level)
struct v4l2_device * v4l2_init(char *device_name, uint16_t width, uint16_t height, uint8_t buffers_cnt, uint32_t _pixelformat)
Initialize a V4L2(Video for Linux 2) device.
struct video_thread_t video_thread
void video_thread_periodic(void)
A dummy for now.
An JPEG encoded image (not per pixel encoded)