47 #if defined(BOARD_BEBOP) || defined(BOARD_DISCO)
56 #ifndef VIDEO_THREAD_NICE_LEVEL
57 #define VIDEO_THREAD_NICE_LEVEL 5
62 #ifndef VIDEO_THREAD_MAX_CAMERAS
63 #define VIDEO_THREAD_MAX_CAMERAS 4
67 #ifndef VIDEO_THREAD_VERBOSE
68 #define VIDEO_THREAD_VERBOSE 0
71 #define printf_debug if(VIDEO_THREAD_VERBOSE > 0) printf
95 snprintf(print_tag, 80,
"video_thread-%s", vid->
dev_name);
102 #define IMG_FLT_SIZE 272
108 fprintf(stderr,
"[%s] Could not start capture.\n", print_tag);
112 #if defined(BOARD_BEBOP) || defined(BOARD_DISCO)
125 uint32_t frame_dt_us, computation_dt_us;
139 struct image_t *img_final = &img;
145 img_final = &img_color;
157 if (frame_dt_us > fps_period_us + 10000) {
158 fprintf(stderr,
"[%s] desired %i fps, only managing %.1f fps\n", print_tag, vid->
fps, 1000000.f / frame_dt_us);
161 if (computation_dt_us + 1000 < fps_period_us) {
178 fprintf(stderr,
"[video_thread] Could not initialize the %s subdevice.\n", camera->
subdev_name);
186 fprintf(stderr,
"[video_thread] Could not initialize the %s V4L2 device.\n", camera->
dev_name);
202 if (cameras[i] == device) {
207 if (cameras[i] != NULL) {
239 fprintf(stderr,
"[viewvideo] Could not create streaming thread for camera %s: Reason: %d.\n", camera->
dev_name, errno);
243 pthread_setname_np(tid,
"camera");
259 fprintf(stderr,
"[video_thread] Could not stop capture of %s.\n", device->
thread.
dev->
name);
273 cameras[indexCameras] = NULL;
284 if (cameras[indexCameras] != NULL) {
297 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 ...
void sys_time_usleep(uint32_t us)
sys_time_usleep(uint32_t us)
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 *in, struct image_t *out, int RedX, int RedY)
Decode Bayer Pattern.
char * subdev_name
path to sub device
#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.
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
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.