head.h
usb_camera.c
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <fcntl.h> /* low-level i/o */
- #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 <linux/videodev2.h>
- #define DEVICE "/dev/video"
- static struct v4l2_requestbuffers req;
- struct buffer
- {
- void* start;
- unsigned int length;
- };
- static struct buffer *buffers;
- static struct v4l2_buffer buf;
- #include "head.h"
- int main()
- {
- int fd;
- fd=open_device();
- get_device_info(fd);
- get_frame_fmt(fd);
- get_current_frame_info(fd);
- try_format_support(fd);
- set_frame_format(fd);
- apply_memory_buf(fd);
- memory_mapping(fd);
- buffer_enqueue(fd);
- close(fd);
- return 0;
- }
- int open_device()
- {
- int fd;