28 #ifndef _CV_LIB_V4L2_H
29 #define _CV_LIB_V4L2_H
31 #include <linux/v4l2-subdev.h>
38 #define V4L2_IMG_NONE 255
Image helper functions like resizing, color filter, converters...
static const struct usb_device_descriptor dev
void * buf
Pointer to the memory mapped buffer.
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.
struct v4l2_img_buf * buffers
The memory mapped image buffers.
int fd
The file pointer to the device.
bool v4l2_init_subdev(char *subdev_name, uint8_t pad, uint16_t code, struct img_size_t size)
Initialize a V4L2 subdevice.
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 ...
volatile uint8_t buffers_deq_idx
The current dequeued index.
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.
uint16_t h
The height of the image.
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...
char * name
The name of the device.
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 timeval timestamp
The time value of the image.
uint32_t pprz_timestamp
The time of the image in us since system startup.
pthread_t thread
The thread that handles the images.
pthread_mutex_t mutex
Mutex lock for enqueue/dequeue of buffers (change the deq_idx)
uint32_t physp
Physical address pointer.
bool v4l2_stop_capture(struct v4l2_device *dev)
Stop capturing of the image stream (Thread safe) This function is blocking until capturing thread is ...
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...
size_t length
The size of the buffer.
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.