liunx 下使用摄像头

今天无语了,linux14.04系统下,使用罗技c270摄像头。发现插上没有反应,系统版本:

[email protected]:~/Downloads$ uname -a
Linux lenovomyc-Lenovo-Product 3.13.0-61-generic #100-Ubuntu SMP Wed Jul 29 11:21:34 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

找了一上午UVC驱动,午饭都没吃。最终!!!是测试摄像头的程序cheese刚刚有点问题

下载了luvcview, 运行,正常工作

[email protected]:~/Downloads$ sudo apt-get install luvcview
Reading package lists... Done
Building dependency tree
Reading state information... Done
luvcview is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 9 not upgraded.
lenovo[email protected]:~/Downloads$ luvcview
luvcview 0.2.6

SDL information:
  Video driver: x11
  A window manager is available
Device information:
  Device path:  /dev/video0
Stream settings:
  Frame format: MJPG
  Frame size:   640x480
  Frame rate:   30 fps
find DRI
find DRI
find DRI
find DRI
find DRI
find DRI
find DRI
find DRI
find DRI
find DRI
find DRI
find DRI
find DRI
find DRI
find DRI
find DRI
find DRI
find DRI 

---------------------------------------------------以下是上午进行的尝试---------------------------------------------------

(1)判断是否为UVC设备

http://blog.csdn.net/myarrow/article/details/8465384

  判断一个摄像头是否属于UVC规范可以使用下面方法:

  1.使用lsusb命令或其它硬件信息查看工具找出摄像头的设备号(Vendor ID)和产品号(Product ID)。如Logitech Quickcam for Notebooks Pro摄像头是046d:08cb;

  2.查找是否有视频类接口信息

  lsusb -d 046d:08cb -v | grep "14 Video"

  如果该摄像头兼容UVC,则会输出类似信息

  bFunctionClass 14 Video

  bInterfaceClass 14 Video

  bInterfaceClass 14 Video

  bInterfaceClass 14 Video

  若无以上信息,则是non-UVC设备。

(2) uvc官网  http://www.ideasonboard.org/uvc/ 有说明:

Linux 2.6.26 and newer includes the Linux UVC driver natively. You will not need to download the driver sources manually unless you want to test a newer version or help with development.

就是说:linux 2.6.26 以及高版本内核都自带UVC驱动的。还以为系统有问题

系统目录下也有 /dev/video0 文件,说明摄像头驱动正常

lsusb输出当前usb设备

罗技C270 为 046d:0825

[email protected]:/dev$ lsusb
Bus 002 Device 012: ID 046d:0825 Logitech, Inc. Webcam C270
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 17ef:6019 Lenovo
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

(3)ubuntu下使用UVC摄像头  http://blog.csdn.net/xingyu19871124/article/details/5764954

分别下载了

1、v41-dvb

网址:http://linuxtv.org/hg/v4l-dvb/  make的时候出错,版本不匹配。是针对linux 3.3.0版本编译的, 当前版本为3.13.0 报错:

UVC File not found: /lib/modules/3.3.0-61-generic/build/.config

又根据:

http://blog.sina.com.cn/s/blog_3dc687f30100kwf5.html

尝试 make config 依旧不行,放弃

重新clone了一遍源码

[email protected]:/dev$ git clone git://linuxtv.org/media_build.git

make (编译内核 。。。)

[email protected]:~/Downloads/media_build$ make
make -C /home/lenovo-myc/Downloads/media_build/v4l
make[1]: Entering directory `/home/lenovo-myc/Downloads/media_build/v4l‘
Updating/Creating .config
make[2]: Entering directory `/home/lenovo-myc/Downloads/media_build/linux‘
Applying patches for kernel 3.13.0-61-generic
patch -s -f -N -p1 -i ../backports/api_version.patch
patch -s -f -N -p1 -i ../backports/pr_fmt.patch
patch -s -f -N -p1 -i ../backports/debug.patch
patch -s -f -N -p1 -i ../backports/drx39xxj.patch
patch -s -f -N -p1 -i ../backports/v4.1_pat_enabled.patch
patch -s -f -N -p1 -i ../backports/v4.0_dma_buf_export.patch
patch -s -f -N -p1 -i ../backports/v4.0_drop_trace.patch
patch -s -f -N -p1 -i ../backports/v3.16_netdev.patch
patch -s -f -N -p1 -i ../backports/v3.16_wait_on_bit.patch
patch -s -f -N -p1 -i ../backports/v3.16_void_gpiochip_remove.patch
Patched drivers/media/dvb-core/dvbdev.c
Patched drivers/media/v4l2-core/v4l2-dev.c
Patched drivers/media/rc/rc-main.c
make[2]: Leaving directory `/home/lenovo-myc/Downloads/media_build/linux‘
Preparing to compile for kernel version 3.13.0

***WARNING:*** You do not have the full kernel sources installed.
This does not prevent you from building the v4l-dvb tree if you have the
kernel headers, but the full kernel source may be required in order to use
make menuconfig / xconfig / qconfig.

If you are experiencing problems building the v4l-dvb tree, please try
building against a vanilla kernel before reporting a bug.

Vanilla kernels are available at http://kernel.org.
On most distros, this will compile a newly downloaded kernel:

cp /boot/config-`uname -r` <your kernel dir>/.config
cd <your kernel dir>
make all modules_install install

Please see your distro‘s web site for instructions to build a new kernel.

WARNING: This is the V4L/DVB backport tree, with experimental drivers
     backported to run on legacy kernels from the development tree at:
        http://git.linuxtv.org/media-tree.git.
     It is generally safe to use it for testing a new driver or
     feature, but its usage on production environments is risky.
     Don‘t use it in production. You‘ve been warned.
V4L2_FLASH_LED_CLASS: Requires at least kernel 4.2.0
RC_ST: Requires at least kernel 3.15.0
VIDEO_XILINX: Requires at least kernel 3.17.0
I2C_SI4713: Requires at least kernel 3.17.0
VIDEO_ADV7604: Requires at least kernel 3.17.0
VIDEO_MT9P031: Requires at least kernel 3.17.0
VIDEO_MT9V032: Requires at least kernel 3.19.0
VIDEO_SMIAPP: Requires at least kernel 4.0.0
SOC_CAMERA_OV2640: Requires at least kernel 3.17.0
Created default (all yes) .config file
./scripts/make_myconfig.pl
make[1]: Leaving directory `/home/lenovo-myc/Downloads/media_build/v4l‘
make[1]: Entering directory `/home/lenovo-myc/Downloads/media_build/v4l‘
perl scripts/make_config_compat.pl /lib/modules/3.13.0-61-generic/build ./.myconfig ./config-compat.h
creating symbolic links...
make -C firmware prep
make[2]: Entering directory `/home/lenovo-myc/Downloads/media_build/v4l/firmware‘
make[2]: Leaving directory `/home/lenovo-myc/Downloads/media_build/v4l/firmware‘
make -C firmware
make[2]: Entering directory `/home/lenovo-myc/Downloads/media_build/v4l/firmware‘
Generating vicam/firmware.fw
Generating ttusb-budget/dspbootcode.bin
Generating cpia2/stv0672_vp4.bin
Generating av7110/bootcode.bin
make[2]: Leaving directory `/home/lenovo-myc/Downloads/media_build/v4l/firmware‘
Kernel build directory is /lib/modules/3.13.0-61-generic/build
make -C ../linux apply_patches
make[2]: Entering directory `/home/lenovo-myc/Downloads/media_build/linux‘
Patches for 3.13.0-61-generic already applied.
make[2]: Leaving directory `/home/lenovo-myc/Downloads/media_build/linux‘
make -C /lib/modules/3.13.0-61-generic/build SUBDIRS=/home/lenovo-myc/Downloads/media_build/v4l  modules
make[2]: Entering directory `/usr/src/linux-headers-3.13.0-61-generic‘
  CC [M]  /home/lenovo-myc/Downloads/media_build/v4l/bt87x.o
  LD [M]  /home/lenovo-myc/Downloads/media_build/v4l/snd-bt87x.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /home/lenovo-myc/Downloads/media_build/v4l/snd-bt87x.mod.o
  LD [M]  /home/lenovo-myc/Downloads/media_build/v4l/snd-bt87x.ko
make[2]: Leaving directory `/usr/src/linux-headers-3.13.0-61-generic‘
./scripts/rmmod.pl check
Can‘t locate Proc/ProcessTable.pm in @INC (you may need to install the Proc::ProcessTable module) (@INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at ./scripts/rmmod.pl line 4.
BEGIN failed--compilation aborted at ./scripts/rmmod.pl line 4.
make[1]: *** [default] Error 2
make[1]: Leaving directory `/home/lenovo-myc/Downloads/media_build/v4l‘
make: *** [all] Error 2

2、gspcav1-20071224.tar.gz

网址:http://mxhaard.free.fr/download.html

make依旧出错

后来下载了 luvciew。发现摄像头可以运行! 好吧,到此结束

1、查看摄像头ID:

[[email protected] dev]# lsusb

Bus 002 Device 013: ID 0ac8:3313 Z-Star Microelectronics Corp.

0xc8:3313在UVC中支持了。

2、插入摄像头后,就可以在/dev/下查看是否有video设备文件:

[[email protected] dev]# ls | grep video

video

video0

其中,video是video0的连接。如果没有再现,可能UVC没有配置到内核中,重新配置就可以了

(大致在Device DriversàMultimedia devicesàVideo capture adaptersàV4L USB devices下面)。如果内核配置了,

还是不出现,可以使用modprobe uvcvideo来加载该模块。

3、先看看摄像头的相关信息:

lshal | grep Cam

出现:

info.product = ‘Vega USB 2.0 Camera.‘ (string)

usb_device.product = ‘Vega USB 2.0 Camera.‘ (string)

usb.interface.description = ‘Vega USB 2.0 Camera.‘ (string)

info.product = ‘Vega USB 2.0 Camera.‘ (string)

input.product = ‘Vega USB 2.0 Camera.‘ (string)

info.product = ‘Vega USB 2.0 Camera.‘ (string)

对USB有研究的,就很熟悉这些字段。

再看一下系统能不能识别出摄像头:

[[email protected] log]# dmesg | grep Cam

uvcvideo: Found UVC 1.00 device Vega USB 2.0 Camera. (0ac8:3313)

input: Vega USB 2.0 Camera. as /class/input/input6

usb 2-7: Product: Vega USB 2.0 Camera.

uvcvideo: Found UVC 1.00 device Vega USB 2.0 Camera. (0ac8:3313)

input: Vega USB 2.0 Camera. as /class/input/input7

usb 2-7: Product: Vega USB 2.0 Camera.

uvcvideo: Found UVC 1.00 device Vega USB 2.0 Camera. (0ac8:3313)

input: Vega USB 2.0 Camera. as /class/input/input8

usb 2-7: Product: Vega USB 2.0 Camera.

[[email protected] ~]# dmesg | grep video

pci 0000:05:00.0: Boot video device

Linux video capture interface: v2.00

usbcore: registered new interface driver uvcvideo

uvcvideo 2-7:1.0: usb_probe_interface

uvcvideo 2-7:1.0: usb_probe_interface - got id

uvcvideo: Found UVC 1.00 device Vega USB 2.0 Camera. (0ac8:3313)

uvcvideo 2-7:1.0: usb_probe_interface

uvcvideo 2-7:1.0: usb_probe_interface - got id

uvcvideo: Found UVC 1.00 device Vega USB 2.0 Camera. (0ac8:3313)

uvcvideo 2-7:1.0: usb_probe_interface

uvcvideo 2-7:1.0: usb_probe_interface - got id

uvcvideo: Found UVC 1.00 device Vega USB 2.0 Camera. (0ac8:3313)

时间: 2024-10-15 06:20:33

liunx 下使用摄像头的相关文章

Liunx下安装jdk

Liunx下安装jdk 1.首先进入ROOT权限  命令 sudo su  输入密码进入 root 权限 2.看下当前liunx 是否存在jdk 环境 ,输入命令 javac,如果存在则会显示对应jdk环境内容,如果不存在,会提示找不到jdk环境,提示内容如下: The program 'javac' can be found in the following packages:  * default-jdk  * ecj  * gcj-4.6-jdk  * gcj-4.7-jdk  * ope

liunx下mysql数据库使用之三范式,关系模型设计注意项,安装目录结构

数据库的三范式第一范式===>每行记录的属性,是原子的,拆到不可拆为止.===>例如:一个人的籍贯,可以拆分为,省,市,县,乡,村 第二范式===>每行记录的非主属性(非主键属性),都完全依赖主属性(主键).===>每行的数据都能唯一区分.===>例如:一个学校的教师,他的姓名,年龄,性别,籍贯.都依赖它的教师编号===>而它教授的科目,并不依赖他的编号,则需要另建表,作为关系模型,进行存储 第三范式===>在实体关系中,如果不存在非关键字段对任一候选关键字段的函

Liunx下Redis集群的安装与测试,以及项目中的应用(redis中对象和集合的储存)。

Liunx下Redis集群的安装与测试,以及项目中的应用. 首先准备ruby和redis接口: redis-3.0.0.gem和 去https://redis.io/下载 1.使用ruby脚本搭建集群.需要ruby的运行环境. 安装ruby yum install ruby yum install rubygems 1.1安装ruby脚本运行使用的包. [[email protected] ~]# gem install redis-3.0.0.gem Successfully installe

C语言高级应用---操作linux下V4L2摄像头应用程序

我们都知道,想要驱动linux下的摄像头,其实很简单,照着V4L2的手册一步步来写,很快就可以写出来,但是在写之前我们要注意改变系统的一些配置,使系统支持framebuffer,在dev下产生fb0这样的节点,这样我们才能在linux系统上操作Camera摄像头,framebuffer在之前的博文已经有说过了,这里就不再提了. 有需要了解framebuffer的那么请点击:http://baike.baidu.com/view/3351639.htm 最重要的,我们需要改一个脚本,在/dev/g

liunx 下安装 php_screw 扩展 以及报错处理

php_screw 是一个 php 源代码加密扩展.首先来看一下 php_screw 在liunx下是如何安装的 首先 去源完整下载 安装包,现在的最新版是 1.5,我们就用1.5 来做个实例 如果有最新版,可以在 http://sourceforge.net/projects/php-screw/files/php-screw/ 查看,下载地址也可以更新哦 开始下载 wget http://sourceforge.net/projects/php-screw/files/latest/down

liunx下服务的注册

由于某些软件安装好之后没有注册过服务,而有时候需要将程序加入开机启动列表. 这时我们可以采取注册服务的方法 服务开启关闭的原理 我们进入/etc/init.d目录 cd /etc/init.d ls 这边显示了已经注册的服务(灰的不是) 让我们使用nano打开其中一个文件 nano iptables 看见红框圈的了吗,这其实就是一个shell脚本 既然这样,我们也试着注册添加一个文件看看 文件如下 #!/bin/bash if [[ $1 == start ]]; then     {MU_DI

如何在树莓派下实现摄像头的拍摄(5MP Raspiberry PI Camera)_PI-3B

学无止境    今天终于抽出空来写了,给大家分享一下. 首先,我们打开树莓派 LX 终端界面,输入命令: sudo raspi-config 然后在camera选项中设置为enable: Finsh保存退出: 拆开外壳的树莓派(七层黑白相间外壳保护)内部结构: 摄像头引脚卡槽的位置就在HDMI接口和火牛电源中间那个黑白相间的地方. 注意:绝对不可以带着电源的情况下插入摄像头,如果带电操作,十之八九你的摄像头会GG         连接500W像素CSI摄像头模块的树莓派它有四个热插拔USB插口,

性能测试十五:liunx下搭建(tomcatr+项目+jmete命令行)

单机 准备工作: 1.压力机安装并配置好JDK,输入java和javac验证环境变量 2.上传jmeter到liunx下: 准备好jmeter的压缩包 在第三方工具中对linux文件上传下载(需先装好rz/sz工具),以liunx系统本身出发:sz下载/发送(send)   rz上传/接收(receive) 同样道理,上传已配好项目的tomcat和项目的压缩包 上传文件的文件夹根据自己的情况而定,如我现在要将传在root目录下的文件移到我自己另外建的文件夹(/home/server/)下 解压:

性能测试十七:liunx下jmeter结果报表、html报表

控制台日志,只能看出整体的数据,若只是测单接口,这个最好用,但若有多个接口时,无法分别展示,所以需要换另外一种报表 四种方式来获取Jmeter的结果报表 一.在GUI模式下跑Jmeter的脚本,用tps插件实时展示图表 二.在命令行模式下跑Jmeter的脚本,生成的jtl文件,在GUI界面的聚合报告里打开,可以展示tps和 响应时间等数据 在liunx下通过sz命令把报告发送到windows端,使用jmeter打开,适合多接口的测试结果展示 三.在命令行模式下跑Jmeter的脚本,生成的jtl文