#include <stdio.h>#include <stdlib.h>#include <string.h>#include <assert.h>#include <fcntl.h>#include <unistd.h>#include <errno.h>#include <malloc.h>#include <sys/stat.h>#include <sys/types.h>#include <sys/time.h>#include <sys/mman.h>#include <sys/ioctl.h>#include <asm/types.h>#include <linux/videodev2.h>#include <libavcodec/avcodec.h>#include <libswscale/swscale.h>#include <usb_cam/usb_cam.h>#include <string>#include <sstream>

Go to the source code of this file.
Classes | |
| struct | buffer |
Defines | |
| #define | __STDC_CONSTANT_MACROS |
| #define | CLEAR(x) memset (&(x), 0, sizeof (x)) |
Functions | |
| static unsigned char | CLIPVALUE (int val) |
| static void | close_device (void) |
| static void | errno_exit (const char *s) |
| static void | init_device (int image_width, int image_height) |
| static int | init_mjpeg_decoder (int image_width, int image_height) |
| static void | init_mmap (void) |
| static void | init_read (unsigned int buffer_size) |
| static void | init_userp (unsigned int buffer_size) |
| static void | mjpeg2rgb (char *MJPEG, int len, char *RGB, int NumPixels) |
| static void | open_device (void) |
| static void | process_image (const void *src, int len, usb_cam_camera_image_t *dest) |
| static int | read_frame (usb_cam_camera_image_t *image) |
| static void | start_capturing (void) |
| static void | stop_capturing (void) |
| static void | uninit_device (void) |
| void | usb_cam_camera_grab_image (usb_cam_camera_image_t *image) |
| void | usb_cam_camera_shutdown (void) |
| usb_cam_camera_image_t * | usb_cam_camera_start (const char *dev, usb_cam_io_method io_method, usb_cam_pixel_format pixel_format, int image_width, int image_height) |
| void | uyvy2rgb (char *YUV, char *RGB, int NumPixels) |
| static int | xioctl (int fd, int request, void *arg) |
| static void | YUV2RGB (const unsigned char y, const unsigned char u, const unsigned char v, unsigned char *r, unsigned char *g, unsigned char *b) |
| static void | yuyv2rgb (char *YUV, char *RGB, int NumPixels) |
Variables | |
| static AVCodec * | avcodec = NULL |
| static AVCodecContext * | avcodec_context = NULL |
| static AVFrame * | avframe_camera = NULL |
| static int | avframe_camera_size = 0 |
| static AVFrame * | avframe_rgb = NULL |
| static int | avframe_rgb_size = 0 |
| struct buffer * | buffers = NULL |
| static char * | camera_dev |
| const int | clipping_table_offset = 128 |
| static int | fd = -1 |
| static usb_cam_io_method | io = IO_METHOD_MMAP |
| static unsigned int | n_buffers = 0 |
| static unsigned int | pixelformat |
| const unsigned char | uchar_clipping_table [] |
| struct SwsContext * | video_sws = NULL |
| #define __STDC_CONSTANT_MACROS |
Definition at line 36 of file usb_cam.cpp.
| #define CLEAR | ( | x | ) | memset (&(x), 0, sizeof (x)) |
Definition at line 61 of file usb_cam.cpp.
| static unsigned char CLIPVALUE | ( | int | val | ) | [static] |
Clip a value to the range 0<val<255. For speed this is done using an array, so can only cope with numbers in the range -128<val<383.
Definition at line 172 of file usb_cam.cpp.
| static void close_device | ( | void | ) | [static] |
Definition at line 775 of file usb_cam.cpp.
| static void errno_exit | ( | const char * | s | ) | [static] |
Definition at line 83 of file usb_cam.cpp.
| static void init_device | ( | int | image_width, | |
| int | image_height | |||
| ) | [static] |
Definition at line 664 of file usb_cam.cpp.
| static int init_mjpeg_decoder | ( | int | image_width, | |
| int | image_height | |||
| ) | [static] |
Definition at line 280 of file usb_cam.cpp.
| static void init_mmap | ( | void | ) | [static] |
Definition at line 571 of file usb_cam.cpp.
| static void init_read | ( | unsigned int | buffer_size | ) | [static] |
Definition at line 553 of file usb_cam.cpp.
| static void init_userp | ( | unsigned int | buffer_size | ) | [static] |
Definition at line 622 of file usb_cam.cpp.
| static void mjpeg2rgb | ( | char * | MJPEG, | |
| int | len, | |||
| char * | RGB, | |||
| int | NumPixels | |||
| ) | [static] |
Definition at line 315 of file usb_cam.cpp.
| static void open_device | ( | void | ) | [static] |
Definition at line 783 of file usb_cam.cpp.
| static void process_image | ( | const void * | src, | |
| int | len, | |||
| usb_cam_camera_image_t * | dest | |||
| ) | [static] |
Definition at line 347 of file usb_cam.cpp.
| static int read_frame | ( | usb_cam_camera_image_t * | image | ) | [static] |
Definition at line 357 of file usb_cam.cpp.
| static void start_capturing | ( | void | ) | [static] |
Definition at line 473 of file usb_cam.cpp.
| static void stop_capturing | ( | void | ) | [static] |
Definition at line 453 of file usb_cam.cpp.
| static void uninit_device | ( | void | ) | [static] |
Definition at line 529 of file usb_cam.cpp.
| void usb_cam_camera_grab_image | ( | usb_cam_camera_image_t * | image | ) |
Definition at line 863 of file usb_cam.cpp.
| void usb_cam_camera_shutdown | ( | void | ) |
Definition at line 844 of file usb_cam.cpp.
| usb_cam_camera_image_t* usb_cam_camera_start | ( | const char * | dev, | |
| usb_cam_io_method | io_method, | |||
| usb_cam_pixel_format | pixel_format, | |||
| int | image_width, | |||
| int | image_height | |||
| ) |
Definition at line 805 of file usb_cam.cpp.
| void uyvy2rgb | ( | char * | YUV, | |
| char * | RGB, | |||
| int | NumPixels | |||
| ) |
Definition at line 236 of file usb_cam.cpp.
| static int xioctl | ( | int | fd, | |
| int | request, | |||
| void * | arg | |||
| ) | [static] |
Definition at line 90 of file usb_cam.cpp.
| static void YUV2RGB | ( | const unsigned char | y, | |
| const unsigned char | u, | |||
| const unsigned char | v, | |||
| unsigned char * | r, | |||
| unsigned char * | g, | |||
| unsigned char * | b | |||
| ) | [static] |
Conversion from YUV to RGB. The normal conversion matrix is due to Julien (surname unknown):
[ R ] [ 1.0 0.0 1.403 ] [ Y ] [ G ] = [ 1.0 -0.344 -0.714 ] [ U ] [ B ] [ 1.0 1.770 0.0 ] [ V ]
and the firewire one is similar:
[ R ] [ 1.0 0.0 0.700 ] [ Y ] [ G ] = [ 1.0 -0.198 -0.291 ] [ U ] [ B ] [ 1.0 1.015 0.0 ] [ V ]
Corrected by BJT (coriander's transforms RGB->YUV and YUV->RGB do not get you back to the same RGB!) [ R ] [ 1.0 0.0 1.136 ] [ Y ] [ G ] = [ 1.0 -0.396 -0.578 ] [ U ] [ B ] [ 1.0 2.041 0.002 ] [ V ]
Definition at line 204 of file usb_cam.cpp.
| static void yuyv2rgb | ( | char * | YUV, | |
| char * | RGB, | |||
| int | NumPixels | |||
| ) | [static] |
Definition at line 258 of file usb_cam.cpp.
AVCodec* avcodec = NULL [static] |
Definition at line 76 of file usb_cam.cpp.
AVCodecContext* avcodec_context = NULL [static] |
Definition at line 77 of file usb_cam.cpp.
AVFrame* avframe_camera = NULL [static] |
Definition at line 74 of file usb_cam.cpp.
int avframe_camera_size = 0 [static] |
Definition at line 78 of file usb_cam.cpp.
AVFrame* avframe_rgb = NULL [static] |
Definition at line 75 of file usb_cam.cpp.
int avframe_rgb_size = 0 [static] |
Definition at line 79 of file usb_cam.cpp.
Definition at line 72 of file usb_cam.cpp.
char* camera_dev [static] |
Definition at line 68 of file usb_cam.cpp.
| const int clipping_table_offset = 128 |
Definition at line 166 of file usb_cam.cpp.
int fd = -1 [static] |
Definition at line 71 of file usb_cam.cpp.
usb_cam_io_method io = IO_METHOD_MMAP [static] |
Definition at line 70 of file usb_cam.cpp.
unsigned int n_buffers = 0 [static] |
Definition at line 73 of file usb_cam.cpp.
unsigned int pixelformat [static] |
Definition at line 69 of file usb_cam.cpp.
| const unsigned char uchar_clipping_table[] |
Definition at line 100 of file usb_cam.cpp.
| struct SwsContext* video_sws = NULL |
Definition at line 81 of file usb_cam.cpp.