58 #ifndef VIDEO_THREAD_NICE_LEVEL
59 #define VIDEO_THREAD_NICE_LEVEL 5
64 #ifndef VIDEO_THREAD_MAX_CAMERAS
65 #define VIDEO_THREAD_MAX_CAMERAS 4
92 snprintf(print_tag, 80,
"video_thread-%s", vid->
dev_name);
99 #define IMG_FLT_SIZE 272
105 fprintf(stderr,
"[%s] Could not start capture.\n", print_tag);
121 struct timespec time_now;
122 struct timespec time_prev;
123 clock_gettime(CLOCK_MONOTONIC, &time_prev);
130 clock_gettime(CLOCK_MONOTONIC, &time_now);
132 time_prev = time_now;
137 if (dt_us < fps_period_us) {
138 usleep(fps_period_us - dt_us);
140 fprintf(stderr,
"[%s] desired %i fps, only managing %.1f fps\n", print_tag, vid->
fps, 1000000.f / dt_us);
149 struct image_t *img_final = &img;
155 img_final = &img_color;
176 printf(
"[video_thread] Could not initialize the %s subdevice.\n", camera->
subdev_name);
184 printf(
"[video_thread] Could not initialize the %s V4L2 device.\n", camera->
dev_name);
218 printf(
"[video_thread] Added %s to camera array.\n", device->
dev_name);
237 printf(
"[viewvideo] Could not create streaming thread for camera %s: Reason: %d.\n", camera->
dev_name, errno);
254 printf(
"[video_thread] Could not stop capture of %s.\n", device->
thread.
dev->
name);
275 if (
cameras[indexCameras] != NULL) {
289 if (
cameras[indexCameras] != NULL) {
uint32_t format
Video format.
struct crop_t crop
Cropped area definition.
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 img_size_t output_size
Output image size.
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)
static struct video_config_t * cameras[VIDEO_THREAD_MAX_CAMERAS]
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.
void video_thread_stop()
Stops the streaming of all cameras This could take some time, because the thread is stopped asynchron...
char * dev_name
path to device
uint8_t filters
filters to use (bitfield with VIDEO_FILTER_x)
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.
Functions to obtain rt priority or set the nice level.
uint8_t buf_cnt
Amount of V4L2 video device buffers.
bool v4l2_stop_capture(struct v4l2_device *dev)
Stop capturing of the image stream (Thread safe) This function is blocking until capturing thread is ...
Image helper functions like resizing, color filter, converters...
int configure_isp(struct v4l2_device *dev)
static void start_video_thread(struct video_config_t *camera)
Architecture independent timing functions.
struct img_size_t sensor_size
Original sensor size.
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.
char * subdev_name
path to sub device
static unsigned int sys_time_elapsed_us(struct timespec *prev, struct timespec *now)
elapsed time in microsecs between two timespecs
#define VIDEO_FILTER_DEBAYER
Enable software debayer.
static void * video_thread_function(void *data)
Handles all the video streaming and saving of the image shots This is a separate thread, so it needs to be thread safe!
static bool initialize_camera(struct video_config_t *camera)
void video_thread_start()
Starts the streaming of a all cameras.
char * name
The name of the device.
void cv_run_device(struct video_config_t *device, struct image_t *img)
#define VIDEO_FILTER_ISP
Enable ISP.
bool v4l2_init_subdev(char *subdev_name, uint8_t pad, uint16_t code, struct img_size_t size)
Initialize a V4L2 subdevice.
volatile bool is_running
When the device is running.
bool v4l2_start_capture(struct v4l2_device *dev)
Start capturing images in streaming mode (Thread safe)
UYVY format (uint16 per pixel)
static void stop_video_thread(struct video_config_t *device)
struct v4l2_device * dev
The V4L2 device that is used for the video stream.
#define VIDEO_THREAD_MAX_CAMERAS
uint32_t subdev_format
Subdevice video format.
bool add_video_device(struct video_config_t *device)
#define VIDEO_THREAD_NICE_LEVEL
static int set_nice_level(int level)
struct video_thread_t thread
Information about the thread this camera is running on.
void video_thread_periodic(void)
A dummy for now.