检查摄像头摄像头设备gnome库

时间:2011-01-28 12:55:04

标签: c++ c linux gtk gnome

如何使用gnome库检测相机设备。

请给我一些关于此的示例代码。

我已经关注了Cheese源代码,但是当我调用detect camera api时,它返回NULL。

谢谢和问候, iSight

1 个答案:

答案 0 :(得分:2)

从我的理解,如果您需要的是网络摄像头设备信息,您根本不需要使用gnome \ gtk。请尝试下面的代码,它应该查询并输出视频驱动程序功能:

#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <linux/videodev2.h>

int main()
{
    struct v4l2_capability vc;
    int fd = open("/dev/video0", O_RDONLY);
    if (fd != -1)
    {
        ioctl(fd, VIDIOC_QUERYCAP, &vc);

        printf("driver: %s\n", vc.driver);
        printf("card: %s\n", vc.card);
        printf("bus info: %s\n", vc.bus_info);
        printf("version: %d\n", vc.version);
        printf("capabilities: %x\n", vc.capabilities);

        close(fd);
    }
    return 0;
}
我的机器输出上的

是:

  

driver:uvcvideo

     

卡:联想EasyCamera

     

巴士信息:usb-0000:00:1d.7-3

     

版本:256

     

功能:4000001

您还可以在此处找到更多信息:How to get a list of video capture devices (web cameras) on linux

希望这有帮助,尊重

相关问题