如何知道摄像头输出什么格式的数据,bmp、jpeg还是rgb或者yuv格式

Do_Change_Lyd 2014-08-02 08:42:52
请问如何知道摄像头输出什么格式的数据,是bmp或者jpeg还是rgb或者yuv格式,因为要知道摄像头输出数据的格式,才能确定是不是要进行格式转换,我使用H.264编码库对yuv格式数据进行编码然后传输
...全文
3100 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Do_Change_Lyd 2014-08-07
  • 打赏
  • 举报
回复
我使用下面程序检查摄像头是否支持 rgb240格式 的数据,为什么没反应的? //检查是否支持某种帧格式 struct v4l2_format fmt; fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_RGB24; if( ioctl( vd->fd, VIDIOC_TRY_FMT, &fmt) == -1 ) if( errno == EINVAL ) printf(" Not support format RGB24!\n"); else printf("support format RGB24 !\n");
nuclears 2014-08-06
  • 打赏
  • 举报
回复
下面这个是我的Logitech C270摄像头的输出信息: #luvcview -L luvcview 0.2.6 SDL information: Video driver: x11 A window manager is available Device information: Device path: /dev/video0 { pixelformat = 'YUYV', description = 'YUV 4:2:2 (YUYV)' } { discrete: width = 640, height = 480 } Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5, { discrete: width = 160, height = 120 } Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5, { discrete: width = 176, height = 144 } Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5, { discrete: width = 320, height = 176 } Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5, { discrete: width = 320, height = 240 } Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5, { discrete: width = 352, height = 288 } Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5, { discrete: width = 432, height = 240 } Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5, { discrete: width = 544, height = 288 } Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5, { discrete: width = 640, height = 360 } Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5, { discrete: width = 752, height = 416 } Time interval between frame: 1/25, 1/20, 1/15, 1/10, 1/5, { discrete: width = 800, height = 448 } Time interval between frame: 1/25, 1/20, 1/15, 1/10, 1/5, { discrete: width = 800, height = 600 } Time interval between frame: 1/20, 1/15, 1/10, 1/5, { discrete: width = 864, height = 480 } Time interval between frame: 1/20, 1/15, 1/10, 1/5, { discrete: width = 960, height = 544 } Time interval between frame: 1/15, 1/10, 1/5, { discrete: width = 960, height = 720 } Time interval between frame: 1/10, 1/5, { discrete: width = 1024, height = 576 } Time interval between frame: 1/10, 1/5, { discrete: width = 1184, height = 656 } Time interval between frame: 1/10, 1/5, { discrete: width = 1280, height = 720 } Time interval between frame: 1/10, 1/5, { discrete: width = 1280, height = 960 } Time interval between frame: 2/15, 1/5, { pixelformat = 'MJPG', description = 'MJPEG' } { discrete: width = 640, height = 480 } Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5, { discrete: width = 160, height = 120 } Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5, { discrete: width = 176, height = 144 } Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5, { discrete: width = 320, height = 176 } Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5, { discrete: width = 320, height = 240 } Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5, { discrete: width = 352, height = 288 } Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5, { discrete: width = 432, height = 240 } Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5, { discrete: width = 544, height = 288 } Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5, { discrete: width = 640, height = 360 } Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5, { discrete: width = 752, height = 416 } Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5, { discrete: width = 800, height = 448 } Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5, { discrete: width = 800, height = 600 } Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5, { discrete: width = 864, height = 480 } Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5, { discrete: width = 960, height = 544 } Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5, { discrete: width = 960, height = 720 } Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5, { discrete: width = 1024, height = 576 } Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5, { discrete: width = 1184, height = 656 } Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5, { discrete: width = 1280, height = 720 } Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5, 剩下的不贴了,超过字数限制了。
nuclears 2014-08-06
  • 打赏
  • 举报
回复
现在的摄像头基本都是支持V4L2的。 通过V4L2的接口可以获得当前摄像头驱动所支持的所有数据格式以及分辨率等信息。 或者将摄像头插到Linux机器上,直接使用命令luvcview获得当前摄像头所支持的所有数据格式以及分辨率信息: luvcview -L
falloutmx 2014-08-04
  • 打赏
  • 举报
回复
这个跟摄像头有关,YUV/RGB都有,也有两种都支持的。如果是YUV也会有区别,有些是YUV420有些是YUV422。
Do_Change_Lyd 2014-08-04
  • 打赏
  • 举报
回复
我的摄像头输出的是jpeg格式的数据,需要先用libjpeg库解码,得到RGB24格式的数据,然后将它转换成yuv420格式的,再对其进行编码传送。你有做过这个吗。你的QQ多少,想和你讨论一下,可以么?
获取USB摄像头的1080p的JPEG格式的图片20180608_1806.7z 电脑上的系统:ubuntu14.04 // http://www.linuxidc.com/Linux/2011-03/33020.htm // V4L2摄像头获取单幅图片测试程序(MMAP模式) // [日期:2011-03-06] 来源:Linux社区 作者:aokikyon [字体:大 中 小] // // #加了点注释 // // #Rockie Cheng // printf #include #include // memset #include #include #include #include // close write usleep read #include #include #include #include #include #include // mmap #include #include #include #include // pthread_create pthread_join #include #define CLEAR(x) memset (&(x), 0, sizeof (x)) #define REQ_COUNT 6 #define uchar unsigned char struct buffer { void * start; size_t length; }; static char * dev_name = "/dev/video0";//摄像头设备名 static int fd = -1; struct buffer * buffers = NULL; // static unsigned int n_buffers = 0; // 2012-7-13 11:33 camera flag // static int iFlagCamera = 0; volatile int iFlagCamera = 0; // 函数名称:thread1 // 函数功能:用于接受键盘的输入,之后通知thread2抓图 // 参数列表: // 返回值 : void thread1(void) { char ch; printf("\n !!!!Warning!!!!\n Max 1000 color bmp\n Input the char: \n"); printf("\n !!!!press o an capture 1 frame picture! \n"); printf("\n !!!!press t an capture 10 frame picture! \n"); printf("\n !!!!press h an capture 100 frame picture! \n"); while(1) { while((ch=getchar()) != '\n') { printf("%c\n", ch); if('o'==ch) { iFlagCamera = 1; printf("thread1=%d\n", iFlagCamera); } else if('t'==ch) { iFlagCamera = 10; printf("thread1=%d\n", iFlagCamera); } else if('h'==ch) { iFlagCamera = 101; printf("thread1=%d\n", iFlagCamera); } else if('q'==ch) { iFlagCamera = 10001; printf("thread1=%d\n", iFlagCamera

23,125

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧