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);
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);
284 if (
cameras[indexCameras] != NULL) {
297 if (
cameras[indexCameras] != NULL) {
void BayerToYUV(struct image_t *in, struct image_t *out, int RedX, int RedY)
Decode Bayer Pattern.
void sys_time_usleep(uint32_t us)
sys_time_usleep(uint32_t us)
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
void cv_run_device(struct video_config_t *device, struct image_t *img)
void image_free(struct image_t *img)
Free the image.
void image_create(struct image_t *img, uint16_t width, uint16_t height, enum image_type type)
Create a new image.
Image helper functions like resizing, color filter, converters...
@ IMAGE_YUV422
UYVY format (uint16 per pixel)
int configure_isp(struct v4l2_device *dev)
PRINT_CONFIG_VAR(ONELOOP_ANDI_FILT_CUTOFF)
Functions to obtain rt priority or set the nice level.
static int set_nice_level(int level)
Architecture independent timing functions.
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.
bool v4l2_init_subdev(char *subdev_name, uint8_t pad, uint16_t code, struct img_size_t size)
Initialize a V4L2 subdevice.
bool v4l2_start_capture(struct v4l2_device *dev)
Start capturing images in streaming mode (Thread safe)
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 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,...
bool v4l2_stop_capture(struct v4l2_device *dev)
Stop capturing of the image stream (Thread safe) This function is blocking until capturing thread is ...
Capture images from a V4L2 device (Video for Linux 2)
char * name
The name of the device.
struct video_thread_t thread
Information about the thread this camera is running on.
#define VIDEO_FILTER_DEBAYER
Enable software debayer.
char * subdev_name
path to sub device
#define VIDEO_FILTER_ISP
Enable ISP.
uint8_t filters
filters to use (bitfield with VIDEO_FILTER_x)
uint32_t format
Video format.
volatile bool is_running
When the device is running.
uint32_t subdev_format
Subdevice video format.
struct crop_t crop
Cropped area definition.
uint8_t buf_cnt
Amount of V4L2 video device buffers.
struct img_size_t output_size
Output image size.
char * dev_name
path to device
struct v4l2_device * dev
The V4L2 device that is used for the video stream.
struct img_size_t sensor_size
Original sensor size.
void video_thread_start()
Starts the streaming of a all cameras.
void video_thread_init(void)
Initialize the view video.
#define VIDEO_THREAD_MAX_CAMERAS
static void stop_video_thread(struct video_config_t *device)
static struct video_config_t * cameras[VIDEO_THREAD_MAX_CAMERAS]
void video_thread_stop()
Stops the streaming of all cameras This could take some time, because the thread is stopped asynchron...
static void * video_thread_function(void *data)
Handles all the video streaming and saving of the image shots This is a separate thread,...
bool add_video_device(struct video_config_t *device)
static void start_video_thread(struct video_config_t *camera)
#define VIDEO_THREAD_NICE_LEVEL
static bool initialize_camera(struct video_config_t *camera)
void video_thread_periodic(void)
A dummy for now.
Start a Video thread and grab images.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.