天嵌二次封装库使用手册  V2.1.2
lib_uvc2.h
浏览该文件的文档.
1 
7 #ifndef LINUX_LIBV2_SOURCE_USB_CAMERA2_LIB_UVC2_H_
8 #define LINUX_LIBV2_SOURCE_USB_CAMERA2_LIB_UVC2_H_
9 
10 // Copyright 2024
11 
12 #include <stdio.h>
13 #include <fcntl.h>
14 #include <unistd.h>
15 #include <stdint.h>
16 #include <stdlib.h>
17 #include <string.h>
18 #include <malloc.h>
19 #include <stddef.h>
20 #include <sys/mman.h>
21 #include <sys/ioctl.h>
22 #include <sys/types.h>
23 #include <sys/stat.h>
24 #include <asm/types.h>
25 #include <linux/videodev2.h>
26 
30 struct videobuffer {
31  unsigned char *start;
32  size_t offset;
33  unsigned int length;
34 };
35 
39 struct uvc_fd {
40  const char* name;
41  int v4l2_fd;
42  int in_width;
43  int in_height;
44  int width;
45  int height;
46  int sizeimage;
47  int top;
48  int left;
49  int rotate;
50  int cap_fmt;
53  int usb_camera;
54  struct videobuffer buffers[4];
55  unsigned int buf_count;
56  int buf_index;
57 };
58 
59 #ifdef __cplusplus
60 #define UVC2_API extern "C"
61 #else
62 #define UVC2_API
63 #endif
64 
70  UVC2_API int uvc2_check(char *dev);
71 
83  UVC2_API int uvc2_init(struct uvc_fd *v, const char *devname, int width, int height);
84 
92  UVC2_API int uvc2_start_capturing(struct uvc_fd *v);
93 
99  UVC2_API int ucv2_stop_capturing(struct uvc_fd v);
100 
106  UVC2_API int uvc2_get_buffsize(struct uvc_fd v);
107 
113  UVC2_API void *uvc2_capturing(struct uvc_fd *v);
114 
120  UVC2_API int uvc2_release_capturing(struct uvc_fd v);
121 
126  UVC2_API void uvc2_close(struct uvc_fd v);
127 
137  UVC2_API int YUY2ToRGB(unsigned char *src, unsigned char *rgb, int width, int height, int bits);
138 
147  UVC2_API int convert_yuv_to_rgb_buffer(unsigned char *yuv,
148  unsigned char *rgb,
149  unsigned int width,
150  unsigned int height);
151 
152 #endif
int v4l2_fd
打开设备name后的文件描述符
Definition: lib_uvc2.h:41
UVC2_API void * uvc2_capturing(struct uvc_fd *v)
获取采集到的缓存
UVC2_API void uvc2_close(struct uvc_fd v)
关闭摄像头
视频缓冲区结构体
Definition: lib_uvc2.h:30
int cap_fmt
像素格式
Definition: lib_uvc2.h:50
unsigned int buf_count
缓冲区个数
Definition: lib_uvc2.h:55
UVC2_API int uvc2_check(char *dev)
检测摄像头是否是 usb 摄像头
UVC2_API int YUY2ToRGB(unsigned char *src, unsigned char *rgb, int width, int height, int bits)
将YUV格式转RGB格式(YUY2是YUV422格式,排列是(YUYV),是1 plane)
size_t offset
偏移量
Definition: lib_uvc2.h:32
UVC2_API int uvc2_init(struct uvc_fd *v, const char *devname, int width, int height)
初始化 usb 摄像头
int buf_index
缓冲区的索引号
Definition: lib_uvc2.h:56
#define UVC2_API
Definition: lib_uvc2.h:62
int rotate
旋转度数
Definition: lib_uvc2.h:49
UVC2_API int uvc2_get_buffsize(struct uvc_fd v)
获取采集数据缓存大小
int usb_camera
usb摄像头
Definition: lib_uvc2.h:53
UVC2_API int uvc2_release_capturing(struct uvc_fd v)
释放采集到的缓存
int left
左边边距
Definition: lib_uvc2.h:48
int in_height
输入的高
Definition: lib_uvc2.h:43
int camera_framerate
摄像头帧率
Definition: lib_uvc2.h:51
int capture_mode
捕获模式
Definition: lib_uvc2.h:52
UVC2_API int ucv2_stop_capturing(struct uvc_fd v)
停止摄像头采集
int width
Definition: lib_uvc2.h:44
int height
Definition: lib_uvc2.h:45
unsigned char * start
缓冲区起始地址
Definition: lib_uvc2.h:31
UVC2_API int uvc2_start_capturing(struct uvc_fd *v)
开启摄像头采集
int sizeimage
图像大小
Definition: lib_uvc2.h:46
uvc设备信息结构体
Definition: lib_uvc2.h:39
const char * name
设备名
Definition: lib_uvc2.h:40
int top
顶部边距
Definition: lib_uvc2.h:47
unsigned int length
缓冲区大小
Definition: lib_uvc2.h:33
UVC2_API int convert_yuv_to_rgb_buffer(unsigned char *yuv, unsigned char *rgb, unsigned int width, unsigned int height)
将YUV格式转RGB格式(YUY2是YUV422格式,排列是(YUYV),是1 plane)
int in_width
输入的宽
Definition: lib_uvc2.h:42