1.V4L2çç¼ç¨
2.什么是驱驱动USB (Universal Serial Bus) Video Class的缩写UVC?
3.(Lenovo USB 2.0 UVC Camera)该设备的驱动程序未被安装. (代码 28)
V4L2çç¼ç¨
v4L2æ¯é对uvcå 驱usb设å¤çç¼ç¨æ¡æ¶ ï¼ä¸»è¦ç¨äºééusbæå头çï¼ç¼ç¨æ¨¡å¼å¦ä¸ï¼ æå¼è§é¢è®¾å¤åï¼å¯ä»¥è®¾ç½®è¯¥è§é¢è®¾å¤çå±æ§ï¼ä¾å¦è£åªã缩æ¾çãè¿ä¸æ¥æ¯å¯éçãå¨Linuxç¼ç¨ä¸ï¼ä¸è¬ä½¿ç¨ioctlå½æ°æ¥å¯¹è®¾å¤çI/Oééè¿è¡ç®¡çï¼extern int ioctl (int __fd, unsigned long int __request, â¦) __THROW;
__fdï¼è®¾å¤çIDï¼ä¾å¦åæç¨openå½æ°æå¼è§é¢ééåè¿åçcameraFdï¼
__requestï¼å ·ä½çå½ä»¤æ å¿ç¬¦ã
å¨è¿è¡V4L2å¼åä¸ï¼ä¸è¬ä¼ç¨å°ä»¥ä¸çå½ä»¤æ å¿ç¬¦ï¼
VIDIOC_REQBUFSï¼åé å å
VIDIOC_QUERYBUFï¼æVIDIOC_REQBUFSä¸åé çæ°æ®ç¼å转æ¢æç©çå°å
VIDIOC_QUERYCAPï¼æ¥è¯¢é©±å¨åè½
VIDIOC_ENUM_FMTï¼è·åå½å驱å¨æ¯æçè§é¢æ ¼å¼
VIDIOC_S_FMTï¼è®¾ç½®å½å驱å¨çé¢æè·æ ¼å¼
VIDIOC_G_FMTï¼è¯»åå½å驱å¨çé¢æè·æ ¼å¼
VIDIOC_TRY_FMTï¼éªè¯å½å驱å¨çæ¾ç¤ºæ ¼å¼
VIDIOC_CROPCAPï¼æ¥è¯¢é©±å¨çä¿®åªè½å
VIDIOC_S_CROPï¼è®¾ç½®è§é¢ä¿¡å·çè¾¹æ¡
VIDIOC_G_CROPï¼è¯»åè§é¢ä¿¡å·çè¾¹æ¡
VIDIOC_QBUFï¼ææ°æ®æ¾åç¼åéå
VIDIOC_DQBUFï¼ææ°æ®ä»ç¼åä¸è¯»ååºæ¥
VIDIOC_STREAMONï¼å¼å§è§é¢æ¾ç¤ºå½æ°
VIDIOC_STREAMOFFï¼ç»æè§é¢æ¾ç¤ºå½æ°
VIDIOC_QUERYSTDï¼æ£æ¥å½åè§é¢è®¾å¤æ¯æçæ åï¼ä¾å¦PALæNTSCã
è¿äºIOè°ç¨ï¼æäºæ¯å¿ é¡»çï¼æäºæ¯å¯éæ©çã 1. æå¼è®¾å¤æ件ã
int fd=open(â/dev/video0â³,O_RDWR);
2. åå¾è®¾å¤çcapabilityï¼çç设å¤å ·æä»ä¹åè½ï¼æ¯å¦æ¯å¦å ·æè§é¢è¾å ¥,æè é³é¢è¾å ¥è¾åºçãVIDIOC_QUERYCAP,struct v4l2_capability
v4l2_std_id std;
do {
ret= ioctl(fd, VIDIOC_QUERYSTD, &std);
} while (ret == -1 && errno == EAGAIN);
switch (std) {
case V4L2_STD_NTSC:
//â¦â¦
case V4L2_STD_PAL:
//â¦â¦
}
3. éæ©è§é¢è¾å ¥ï¼ä¸ä¸ªè§é¢è®¾å¤å¯ä»¥æå¤ä¸ªè§é¢è¾å ¥ãVIDIOC_S_INPUT,struct v4l2_input(å¯ä¸è¦)
4. 设置è§é¢çå¶å¼åå¸§æ ¼å¼ï¼å¶å¼å æ¬PALï¼NTSCï¼å¸§çæ ¼å¼ä¸ªå æ¬å®½åº¦åé«åº¦çã
VIDIOC_S_STD,VIDIOC_S_FMT,struct v4l2_std_id,struct v4l2_format
struct v4l2_format fmt;
/
*v4l2_format ç»æå¦ä¸ï¼
struct v4l2_format
{
enum v4l2_buf_type type; // æ°æ®æµç±»åï¼å¿ 须永è¿æ¯V4L2_BUF_TYPE_VIDEO_CAPTURE
union
{
struct v4l2_pix_format pix;
struct v4l2_window win;
struct v4l2_vbi_format vbi;
__u8 raw_data[];
} fmt;
};
struct v4l2_pix_format
{
__u width; // 宽ï¼å¿ é¡»æ¯ çåæ°
__u height; // é«ï¼å¿ é¡»æ¯ çåæ°
__u pixelformat; // è§é¢æ°æ®åå¨ç±»åï¼ä¾å¦æ¯YUV 4 ï¼2 ï¼2 è¿æ¯RGB
enum v4l2_field field;
__u bytesperline;
__u sizeimage;
enum v4l2_colorspace colorspace;
__u priv;
};
*/
æ ·ä¾ï¼
memset ( &fmt, 0, sizeof(fmt) );
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
fmt.fmt.pix.width = ;
fmt.fmt.pix.height = ;
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_JPEG;
if (ioctl(fd, VIDIOC_S_FMT, &fmt) < 0ï¼
{
printf(set format failed\n);
//return 0;
}
5. å驱å¨ç³è¯·å¸§ç¼å²ï¼ä¸è¬ä¸è¶ è¿5个ãstruct v4l2_requestbuffers
struct v4l2_requestbuffers
{
__u count; // ç¼åæ°éï¼ä¹å°±æ¯è¯´å¨ç¼åéåéä¿æå¤å°å¼ ç §ç
enum v4l2_buf_type type; // æ°æ®æµç±»åï¼å¿ 须永è¿æ¯V4L2_BUF_TYPE_VIDEO_CAPTURE
enum v4l2_memory memory; // V4L2_MEMORY_MMAP æ V4L2_MEMORY_USERPTR
__u reserved[2];
};
æ ·ä¾ï¼
struct v4l2_requestbuffers req;
memset(&req, 0, sizeof (req));
req.count = 4;
req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
req.memory = V4L2_MEMORY_MMAP;
if (ioctl(fd,VIDIOC_REQBUFS,&req) == -1)
{
perror(VIDIOC_REQBUFS error \n);
//return -1;
}
6.ç³è¯·ç©çå å
å°ç³è¯·å°ç帧ç¼å²æ å°å°ç¨æ·ç©ºé´ï¼è¿æ ·å°±å¯ä»¥ç´æ¥æä½ééå°ç帧äºï¼èä¸å¿ å»å¤å¶ãå°ç³è¯·å°ç帧ç¼å²å ¨é¨å ¥éåï¼ä»¥ä¾¿åæ¾ééå°çæ°æ®.VIDIOC_QBUF,struct v4l2_buffer
VideoBuffer* buffers = calloc( req.count, sizeof(VideoBuffer) );
printf(sizeof(VideoBuffer) is %d\n,sizeof(VideoBuffer));
struct v4l2_buffer buf;
for (numBufs = 0; numBufs < req.count; numBufs++)
{
memset( &buf, 0, sizeof(buf) );
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.memory = V4L2_MEMORY_MMAP;
buf.index = numBufs;
if (ioctl(fd, VIDIOC_QUERYBUF, &buf) < 0)
{
printf(VIDIOC_QUERYBUF error\n);
//return -1;
}
printf(buf len is %d\n,sizeof(buf));
//å åæ å°
buffers[numBufs].length = buf.length;
buffers[numBufs].offset = (size_t) buf.m.offset;
buffers[numBufs].start = mmap (NULL, buf.length,PROT_READ | PROT_WRITE, MAP_SHARED, fd, buf.m.offset);
printf(buffers.length = %d,buffers.offset = %d ,buffers.start[0] = %d\n,buffers[numBufs].length,buffers[numBufs].offset,buffers[numBufs].start[0]);
printf(buf2 len is %d\n,sizeof(buffers[numBufs].start));
if (buffers[numBufs].start == MAP_FAILED)
{
perror(buffers error\n);
//return -1;
}
if (ioctl (fd, VIDIOC_QBUF, &buf) < 0)
{
printf(VIDIOC_QBUF error\n);
//return -1;
}
}
7. å¼å§è§é¢çééã
enum v4l2_buf_type type;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if (ioctl (fd, VIDIOC_STREAMON, &type) < 0)
{
printf(VIDIOC_STREAMON error\n);
// return -1;
}
8. åºéå以åå¾å·²ééæ°æ®ç帧ç¼å²ï¼åå¾åå§ééæ°æ®ãVIDIOC_DQBUF, å°ç¼å²éæ°å ¥éåå°¾,è¿æ ·å¯ä»¥å¾ªç¯ééãVIDIOC_QBUF
if (ioctl(fd, VIDIOC_DQBUF, &buf) < 0)
{
perror(VIDIOC_DQBUF failed.\n);
//return -1;
}
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.memory = V4L2_MEMORY_MMAP;
unsigned char *ptcur = buffers[numBufs].start;
DEBUG(buf.bytesused = %d \n,buf.bytesused);
int i1;
for(i1=0; i1<buf.bytesused; i1++)
{
if((buffers[numBufs].start[i1] == 0xFF) && (buffers[numBufs].start[i1+1] == 0xC4))
{
DEBUG(huffman table finded! \nbuf.bytesused = %d\nFFC4 = %d \n,buf.bytesused,i1);
break;
}
}
if(i1 == buf.bytesused)printf(huffman table don't exist! \n);
int i;
for(i=0; i<buf.bytesused; i++)
{
if((buffers[numBufs].start[i] == 0xFF) && (buffers[numBufs].start[i+1] == 0xD8)) break;
ptcur++;
}
DEBUG(i=%d,FF=%x,D8=%x\n,i,buffers[numBufs].start[i],buffers[numBufs].start[i+1]);
int imagesize =buf.bytesused - i;
DEBUG(buf.bytesused = %d \n,buf.bytesused);
DEBUG (imagesize = %d \n,imagesize);
9. åæ¢è§é¢çééãVIDIOC_STREAMOFF
. å ³éè§é¢è®¾å¤ãclose(fd);
什么是USB (Universal Serial Bus) Video Class的缩写UVC?
UVC,全称为USB (Universal Serial Bus) Video Class的动源缩写,中文直译为“USB(通用串行总线)视频类”。源码这个术语主要应用于计算机和电子设备领域,驱驱动用来描述通过USB接口传输视频数据的动源微信小游戏源码养成类端游一种标准。UVC的源码反编译vbox源码缩写词在英语中的流行度为,表明它在相关技术文档和硬件设备中被广泛使用。驱驱动
UVC代表的动源是一个计算技术分类,具体指的源码是USB设备能够支持视频流传输的能力。它属于Drivers(驱动程序)类别,驱驱动主要用于连接各种摄像头、动源显示器或其他视频输入/输出设备,源码使得这些设备能够通过USB接口方便地与电脑或其他设备交互。驱驱动肇庆到惠州源码例如,动源许多现代智能手机和平板电脑支持UVC,源码可以作为外接显示器或通过USB传输视频数据到电脑。
总的论文不提供源码来说,UVC是一个技术术语,它简化了视频设备的连接方式,使得USB接口不仅仅局限于文件传输,还可以实现高质量的酷酷游戏源码下载视频通信。在学习和使用计算机硬件时,理解UVC的重要性有助于提高设备的兼容性和效率。
(Lenovo USB 2.0 UVC Camera)该设备的驱动程序未被安装. (代码 )
尊敬的联想用户您好!
您可以检测下载相关驱动。
驱动下载链接:
/lenovo/wsi/Modules/Drive.aspx?intcmp=I_F_Driver
更多问题您可以咨询联想智能机器人:
/8sYxpQm
如果没有解决您的问题可以吐槽提出您宝贵的意见,再转人工服务。
期待您满意的评价,感谢您对联想的支持,祝您生活愉快!
2024-11-29 17:38
2024-11-29 17:07
2024-11-29 17:05
2024-11-29 15:58
2024-11-29 15:57
2024-11-29 15:43