覆盆子Pi - Raspbian - 运动 - USB相机 - 黑色图像

时间:2013-11-30 13:12:21

标签: camera linux-device-driver raspberry-pi motion debian-based

我最近购买了Rasperry Pi,VersionB,并且我正在尝试使用旧的USB网络摄像头来处理动作,以便我可以通过http访问流。我正在使用Raspbian,已完成更新/升级。

我相当肯定相机会工作,因为我使用了motion.conf文件很长一段时间,以及拔掉/重新插入usb相机几次,并在某些时候记录了2秒但是,我不确定我做了什么让它暂时起作用。

此外,我可以访问控制端口8089,以及8081的流(在firefox中),但是流是黑色背景,右下方有一个计数器。

控制端口列出相机已连接且运动检测处于活动状态,但端口8081上的视频流为黑色。

最后,当我通过控制端口(8089)手动捕获屏幕截图时,屏幕截图为黑色图像,就好像相机已被遮盖一样。

那就是说,我决定转向堆栈向导。

供参考:

与相机有关的

lsusb输出:

Bus 001 Device 005: ID 0c45:6288 Microdia PC Camera with Microphone (SN9C202 + OV9655)

- 编辑:

插入USB摄像头后收到

dmesg输出:

[  269.597235] usb 1-1.2: new high-speed USB device number 5 using dwc_otg
[  269.700498] usb 1-1.2: New USB device found, idVendor=0c45, idProduct=6288
[  269.700530] usb 1-1.2: New USB device strings: Mfr=0, Product=1, SerialNumber=0
[  269.700546] usb 1-1.2: Product: USB20 Camera
[  269.784573] media: Linux media interface: v0.10
[  269.810131] Linux video capture interface: v2.00
[  269.819113] gspca_main: v2.14.0 registered
[  269.826148] gspca_main: gspca_sn9c20x-2.14.0 probing 0c45:6288
[  271.897401] gspca_sn9c20x: OV9655 sensor detected
[  271.905922] input: gspca_sn9c20x as /devices/platform/bcm2708_usb/usb1/1-1/1-1.2/input/input0
[  271.910445] usbcore: registered new interface driver gspca_sn9c20x
[  272.078022] 5:2:1: cannot get freq at ep 0x84
[  272.091857] usbcore: registered new interface driver snd-usb-audio
[  278.190887] gspca_sn9c20x: Set 640x480
[  279.187333] gspca_sn9c20x: Set 640x480
[  280.158810] gspca_main: ISOC data error: [23] len=0, status=-63

sudo motion -n输出

[0] Processing thread 0 - config file /etc/motion/motion.conf
[0] Motion 3.2.12 Started
[0] ffmpeg LIBAVCODEC_BUILD 3482368 LIBAVFORMAT_BUILD 3478785
[0] Thread 1 is from /etc/motion/motion.conf
[0] httpd bind(): Address already in use
[1] Thread 1 started
[0] httpd thread exit
[1] cap.driver: "gspca_sn9c20x"
[1] cap.card: "USB20 Camera    "
[1] cap.bus_info: "usb-bcm2708_usb-1.3"
[1] cap.capabilities=0x85000001
[1] - VIDEO_CAPTURE
[1] - READWRITE
[1] - STREAMING
[1] Test palette JPEG (640x480)
[1] Using palette JPEG (640x480) bytesperlines 640 sizeimage 154190 colorspace 00000007
[1] found control 0x00980900, "Brightness", range 0,255
[1]     "Brightness", default 127, current 127
[1] found control 0x00980901, "Contrast", range 0,255
[1]     "Contrast", default 127, current 127
[1] found control 0x00980902, "Saturation", range 0,255
[1]     "Saturation", default 127, current 127
[1] found control 0x00980903, "Hue", range -180,180
[1]     "Hue", default 0, current 0
[1] found control 0x0098090e, "Red Balance", range 0,127
[1]     "Red Balance", default 40, current 40
[1] found control 0x0098090f, "Blue Balance", range 0,127
[1]     "Blue Balance", default 40, current 40
[1] found control 0x00980910, "Gamma", range 0,255
[1]     "Gamma", default 16, current 16
[1] found control 0x00980911, "Exposure", range 0,6016
[1]     "Exposure", default 51, current 5864
[1] found control 0x00980912, "Gain, Automatic", range 0,1
[1]     "Gain, Automatic", default 1, current 1
[1] found control 0x00980913, "Gain", range 0,28
[1]     "Gain", default 0, current 0
[1] Error requesting buffers 4 for memory map. VIDIOC_REQBUFS: Device or resource busy
[1] ioctl (VIDIOCGCAP): Inappropriate ioctl for device
[1] Could not fetch initial image from camera
[1] Motion continues using width and height from config file(s)
[1] Resizing pre_capture buffer to 1 items
[1] bind(): Address already in use
[1] Problem enabling stream server in port 8088: Address already in use
[1] Thread exiting
[0] Motion thread 1 restart
[1] Thread 1 started
""""
""""
""""
""""

lsmod输出

Module                  Size  Used by
snd_bcm2835            16165  0
snd_usb_audio         116191  0
snd_usbmidi_lib        18267  1 snd_usb_audio
snd_hwdep               5968  1 snd_usb_audio
snd_seq_midi            4682  0
snd_seq_midi_event      6551  1 snd_seq_midi
snd_rawmidi            21357  2 snd_usbmidi_lib,snd_seq_midi
snd_pcm                81593  2 snd_bcm2835,snd_usb_audio
snd_page_alloc          5156  1 snd_pcm
snd_seq                53769  2 snd_seq_midi_event,snd_seq_midi
snd_seq_device          6473  3 snd_seq,snd_rawmidi,snd_seq_midi
snd_timer              20133  2 snd_pcm,snd_seq
snd                    58895  9 snd_bcm2835,snd_usb_audio,snd_hwdep,snd_timer,snd_pcm,snd_seq,snd_rawmidi,snd_usbmidi_lib,snd_seq_device
evdev                   9325  1
arc4                    1683  2
rt2800usb              16720  0
rt2800lib              67499  1 rt2800usb
rt2x00usb              11492  1 rt2800usb
rt2x00lib              44180  3 rt2x00usb,rt2800lib,rt2800usb
gspca_sn9c20x          25601  1
gspca_main             23579  2 gspca_sn9c20x
mac80211              315610  3 rt2x00lib,rt2x00usb,rt2800lib
videodev              111230  3 gspca_sn9c20x,gspca_main
cfg80211              209273  2 mac80211,rt2x00lib
media                  13467  1 videodev
crc_ccitt               1529  1 rt2800lib
leds_gpio               2059  0
rfkill                 19138  2 cfg80211
led_class               3688  2 leds_gpio,rt2x00lib

如果重要,我已将动作设为守护进程。

我应该检查/改变其他任何东西以使事情正常工作?

P.S。我显然是linux / debian noob,所以请放轻松。

1 个答案:

答案 0 :(得分:1)

在低端笔记本电脑上遇到完全相同的问题。 pi上可用的总USB带宽有限,您已经在使用一些用于网络连接。

我建议你降低运动处理的图像分辨率和帧率。

现在我首先假设你已经安装了最新版本的动作

sudo apt-get update
sudo apt-get install motion

然后我们确认USB Camera已被识别为v4l2设备

lsusb
ls /dev/video*
v4l2-ctl --list-devices

确保在每个输出中看到您期望的相机。记下相机名称,我假设/dev/video0

现在我们将编辑动作配置

sudo nano /etc/motion/motion.conf

在“捕获设备选项”标题下,您应该拥有与您拥有的相匹配的相机。例如videodevice /dev/video0

接下来确保帧率和分辨率都很好而且低。你可以稍后再增加它们,直到动作再次中断,然后从有效的方法开始。

width 320
height 240
framerate 2

要进行调试,最好打开现场网络摄像头服务器,并将其设置为可以从笔记本电脑查看。只需查看/etc/motion/motion.conf文件,直到找到该部分。

webcam_motion on
webcam_localhost off

现在我们需要通过打开另一个文件来启用动作守护程序。

sudo nano /etc/default/motion

将值更改为start_motion_daemon=yes

现在我们可以开始运动!!

sudo service motion start

我们将在Firefox中查看来自相机的Feed。首先使用ifconfig查找pi的IP地址,如果你是wifi等,请查找wlan0。

ifconfig

我假设pi IP地址为192.168.1.123

现在,从笔记本电脑打开firefox并在地址栏中输入192.168.1.123:8081。您将看到动作Feed的预览!!如果不这样做,请将分辨率降低,并确保您的笔记本电脑连接良好,并且与您的pi处于同一网络。