使用数码单反相机作为网络摄像头

使用数码单反相机作为网络摄像头

我尝试在 Ubuntu 机器上将我的佳能 DSLR 用作网络摄像头。摄像头未显示为/dev/video*

相机出现在hwinfo --usb

19: USB 00.0: 10f01 WebCam
  [Created at usb.122]
  Unique ID: R8DB._ROX1vreGqF
  Parent ID: FKGF.4Nx_qoDfSd7
  SysFS ID: /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.1/2-1.1:1.0
  SysFS BusID: 2-1.1:1.0
  Hardware Class: camera
  Model: "Canon EOS 100D"
  Hotplug: USB
  Vendor: usb 0x04a9 "Canon"
  Device: usb 0x3270 "EOS 100D"
  Revision: "0.02"
  Driver: "usbfs"
  Driver Modules: "usbcore"
  Speed: 480 Mbps
  Module Alias: "usb:v04A9p3270d0002dc00dsc00dp00ic06isc01ip01in00"
  Config Status: cfg=new, avail=yes, need=no, active=unknown
  Attached to: #4 (Hub)

USB相关lsmod显示如下:

$ lsmod | grep usb
wusbcore               45056  0  # I activated this manually, shot in the dark
uwb                    73728  1 wusbcore
snd_usb_audio         204800  4
snd_usbmidi_lib        32768  1 snd_usb_audio
snd_hwdep              20480  2 snd_usb_audio,snd_hda_codec
btusb                  45056  0
btrtl                  16384  1 btusb
btbcm                  16384  1 btusb
btintel                16384  1 btusb
bluetooth             548864  46 btrtl,hidp,btintel,btbcm,bnep,btusb,rfcomm
snd_pcm                98304  5 snd_hda_codec_hdmi,snd_hda_intel,snd_usb_audio,snd_hda_codec,snd_hda_core
snd_rawmidi            32768  2 snd_seq_midi,snd_usbmidi_lib
snd                    81920  34 snd_hda_codec_generic,snd_seq,snd_seq_device,snd_hda_codec_hdmi,snd_hwdep,snd_hda_intel,snd_usb_audio,snd_usbmidi_lib,snd_hda_codec,snd_hda_codec_realtek,snd_timer,snd_pcm,snd_rawmidi
usbhid                 49152  0
hid                   118784  3 hidp,usbhid,hid_generic

这是的尾部dmesg

[  530.523684] media: Linux media interface: v0.10
[  530.530299] Linux video capture interface: v2.00
[  530.540171] usbcore: registered new interface driver uvcvideo
[  530.540172] USB Video Class driver (1.1.1)
[  878.930024] usb 2-1.1: USB disconnect, device number 6
[  973.616657] usb 2-1.1: new high-speed USB device number 7 using ehci-pci
[  973.818855] usb 2-1.1: New USB device found, idVendor=04a9, idProduct=3270
[  973.818859] usb 2-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[  973.818861] usb 2-1.1: Product: Canon Digital Camera
[  973.818862] usb 2-1.1: Manufacturer: Canon Inc.

尝试查找有关 usbcore 的一些信息modprobe

$ ls -R /lib/modules/$(uname -r)/kernel | grep usbcor
wusbcore
/lib/modules/4.15.0-91-generic/kernel/drivers/usb/wusbcore:
wusbcore.ko

正如之前所说,相机没有显示/dev/video*,我不知道下一步该怎么做!

答案1

我让它工作了感谢

$ sudo apt-get install gphoto2 v4l2loopback-utils ffmpeg
$ sudo modprobe v4l2loopback exclusive_caps=1 max_buffers=2
(some advice there as how to make this more automatic)

然后是一些正在运行的进程需要被杀死

$ ps aux|grep gphoto
$ kill <the PID for the process gvfsd-gphoto2, or something like that>

并在后台运行:

$ gphoto2 --stdout --capture-movie | ffmpeg -i - -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video

所有这些都使得它看起来/dev/video0像是一个视频输入,并且能够工作。虽然现在,我的帧率很低

相关内容