28 #ifndef _CV_LIB_V4L2_H
29 #define _CV_LIB_V4L2_H
31 #include <linux/v4l2-subdev.h>
38 #define V4L2_IMG_NONE 255
pthread_mutex_t mutex
Mutex lock for enqueue/dequeue of buffers (change the deq_idx)
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...
bool v4l2_stop_capture(struct v4l2_device *dev)
Stop capturing of the image stream (Thread safe) This function is blocking until capturing thread is ...
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...
uint32_t pprz_timestamp
The time of the image in us since system startup.
Image helper functions like resizing, color filter, converters...
uint16_t h
The height of the image.
struct timeval timestamp
The time value of the image.
bool v4l2_image_get_nonblock(struct v4l2_device *dev, struct image_t *img)
Get the latest image and lock it (Thread safe, NON BLOCKING) This function returns NULL if it can't g...
struct v4l2_img_buf * buffers
The memory mapped image buffers.
void v4l2_close(struct v4l2_device *dev)
Close the V4L2 device (Thread safe) This needs to be preformed to clean up all the buffers and close ...
size_t length
The size of the buffer.
static const struct usb_device_descriptor dev
void * buf
Pointer to the memory mapped buffer.
char * name
The name of the device.
bool v4l2_start_capture(struct v4l2_device *dev)
Start capturing images in streaming mode (Thread safe)
uint8_t buffers_cnt
The number of image buffers.
bool v4l2_init_subdev(char *subdev_name, uint8_t pad, uint16_t code, struct img_size_t size)
Initialize a V4L2 subdevice.
volatile uint8_t buffers_deq_idx
The current dequeued index.
pthread_t thread
The thread that handles the images.
struct v4l2_device * v4l2_init(char *device_name, struct img_size_t size, struct crop_t crop, uint8_t buffers_cnt, uint32_t _pixelformat)
Initialize a V4L2(Video for Linux 2) device.
uint16_t w
The width of the image.
int fd
The file pointer to the device.