首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >USB摄像头协议

USB摄像头协议
EN

Stack Overflow用户
提问于 2012-04-04 17:05:49
回答 1查看 3.1K关注 0票数 2

我想把USB摄像头连接到嵌入式设备上。我的设备操作系统是嵌入式Linux,支持USB Host。我可以很容易地读写USB端口,但我不知道如何从相机捕捉图像。有没有USB摄像头的标准协议,我可以捕捉图像?

EN

回答 1

Stack Overflow用户

发布于 2012-04-04 17:21:55

大多数支持此功能的摄像头都使用Picture Transfer Protocol (PTP)。在Linux中,很多相机都可以通过libgphoto2来支持这一点。

您可以使用以下命令列出已连接的设备:

代码语言:javascript
复制
    CameraList      *xlist = NULL;

    ret = gp_list_new (&xlist);
    if (ret < GP_OK) goto out;
    if (!portinfolist) {
        /* Load all the port drivers we have... */
        ret = gp_port_info_list_new (&portinfolist);
        if (ret < GP_OK) goto out;
        ret = gp_port_info_list_load (portinfolist);
        if (ret < 0) goto out;
        ret = gp_port_info_list_count (portinfolist);
        if (ret < 0) goto out;
    }
    /* Load all the camera drivers we have... */
    ret = gp_abilities_list_new (&abilities);
    if (ret < GP_OK) goto out;
    ret = gp_abilities_list_load (abilities, context);
    if (ret < GP_OK) goto out;

    /* ... and autodetect the currently attached cameras. */
    ret = gp_abilities_list_detect (abilities, portinfolist, xlist, context);
    if (ret < GP_OK) goto out;

    /* Filter out the "usb:" entry */
        ret = gp_list_count (xlist);
    if (ret < GP_OK) goto out;
    for (i=0;i<ret;i++) {
        const char *name, *value;

        gp_list_get_name (xlist, i, &name);
        gp_list_get_value (xlist, i, &value);
        if (!strcmp ("usb:",value)) continue;
        gp_list_append (list, name, value);
    }
out:
    gp_list_free (xlist);
    return gp_list_count(list);

(摘自libgphoto2-2.4.11/examples/autodetect.c)

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10008073

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档