USB Camera in Hass.io

So I’m working on an addon to display an usb camera. It is a Playstation Eye Camera - which I mainly got because of the microphone array, but I thought using the camera would be also nice. Seems like the camera is some how recognized, but there is no /dev/video0 device.

What I see in the dmesg logs:
[ 2.284560] usb 1-1.2: new high-speed USB device number 4 using dwc_otg
[ 2.387047] usb 1-1.2: New USB device found, idVendor=1415, idProduct=2000
[ 2.387069] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 2.387081] usb 1-1.2: Product: USB Camera-B4.09.24.1
[ 2.387094] usb 1-1.2: Manufacturer: OmniVision Technologies, Inc.

I think the docker container from my addon might have no access to the camera - I already tried to add “devices” to my config.json - but I’m not sure what exactly I have to define here.

Thanks for the help & Regards

2 Likes

I was thinking of buying one of those because of the mic capabilities, did you flash the firmware? Sorry I can’t help with the camera, I’m looking into the same thing myself.

No, I did not flash the firmware or anything. The mic was working out of the box. What would be the benefit of an alternative firmware?

From what I saw on amazon the ones they are selling now have to be flashed to be used because they don’t come with proper firmware, but I didn’t look that deep into it.

No problems with sound/video on Ubuntu with the stock firmware… Can you provide me a link to the firmware upgrade please? Then I’d just try it out!

I’m making progress… got the camera device in the container - but camera output is just a grey picture.

[1] cap.driver: “ov534”
[1] cap.card: “USB Camera-B4.09.24.1”
[1] cap.bus_info: “usb-3f980000.usb-1.2”
[1] cap.capabilities=0x85200001
[1] - VIDEO_CAPTURE
[1] - READWRITE
[1] - STREAMING
[1] Unable to query input -1 VIDIOC_ENUMINPUT: Invalid argument
[1] ioctl (VIDIOCGCAP): Not a tty

Anyone familiar with this error? I can publish my repository tomorrow!

Sorry I tried to find some details but seems that was specific to windows drivers not recognizing the default. The reviews I saw even clarified that it works with linux out of the box.

So, finally got it working. My addon repo can be found here:

But please note - still work in progress! I’ve noticed that sometimes the addon stops randomly…

1 Like

Woah sweet I’m going to have to try this out.

The problem is, the docker container (or motion itself) stops after about 24minutes. I have not yet figured out why… Also, the motion package in alpine linux is a bit outdated. I hope this will be fixed soon!

Other users were saying the same thing about the ffmpeg and onvif components. So far I haven’t had much luck at all getting cameras into my configuration across multiple platforms. I’ve got 3 NVR’s, 3 dlink cams, about 40 onvif cams, 2 foscams, 2 usb cams, and a cheap digoo cam. I’m not looking to view them all at once, that would be unreasonable, but the NVRs have these nice feeds that are multiple channels in a split view. I’ve given up on cameras at the moment until I see changes announced.

Amazing! I had been looking into this and whether it would be feasible as a docker container in hass.io but it was well beyond my capabilities.

Will it work with any plug and play usb camera a pi can recognize?

I’ve only tested with the Sony Eye Camera - But I think as long as it get’s recognized by the alpinelinux - it should work! Please try it and share your results!

Hello, need some help with this addon. It recognize camera but can’t create image. Here is log:

starting version 3.2.2
[Info] Show connected usb devices
Bus 001 Device 002: ID 0424:9514
Bus 001 Device 001: ID 1d6b:0002
Bus 001 Device 003: ID 0424:ec00
Bus 001 Device 004: ID 093a:2468
crw-rw----    1 root     44         81,   0 Sep 18 18:21 /dev/video0
[0] Processing thread 0 - config file /etc/motion.conf
[0] Motion 3.2.12 Started
[0] Thread 1 is from /etc/motion.conf
[1] Thread 1 started
[1] cap.driver: "pac207" 
[1] cap.card: "CIF Single Chip     "
[1] cap.bus_info: "usb-3f980000.usb-1.5"
[1] cap.capabilities=0x85200001
[1] - VIDEO_CAPTURE
[1] - READWRITE
[1] - STREAMING
[1] Config palette index 8 (YU12) doesn't work.
[1] Supported palettes:
[1] 0: P207 (GSPCA PAC207)
[1] Unable to find a compatible palette format.
[1] ioctl (VIDIOCGCAP): Not a tty
[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

I have some old USB camera which work with motion in hassbian, but i have to install libv2lconvert.so with

sudo apt-get install camorama

and modify motion initialization:

LD_PRELOAD=/usr/lib/arm-linux-gnueabihf/libv4l/v4l2convert.so motion

Anyone know how to ovecome this problem?

I’ve just created a (untested) feature branch with your request. Can you check it out and test it locally by just copying the files to /addons on your pi?

https://github.com/HerrHofrat/hassio-addons/tree/feature/v4l2convert/motion

Thanks for quick response.

I copy files to /addon and install motion, but it can’t find file v412convert.so…

starting version 3.2.2
[Info] Show connected usb devices 
Bus 001 Device 002: ID 0424:9514
Bus 001 Device 001: ID 1d6b:0002
Bus 001 Device 003: ID 0424:ec00 
Bus 001 Device 006: ID 093a:2468
crw-rw----    1 root     44         81,   0 Sep 19 22:22 /dev/video0
/run.sh: line 39: /LD_PRELOAD=/usr/lib/libv4l/v4l2convert.so: No such file or directory

I try to search on rpi3 for this file or libv4l directory but couldn’t find it…

If I correctly assume from dockerfile, v4l-utils-libs should be installed from alpinelinux?! I search in http://nl.alpinelinux.org/alpine/edge/testing but there is no such library. Is it possible to install that library from somewhere else?

According to https://pkgs.alpinelinux.org/packages?name=v4l-utils-libs&branch=&repo=&arch=&maintainer= it should be there - I’ll test it in the next couple of days!

Edit: Had some time - just remove the exec in the last line - please see my last commit. But now it fails with a Segmentation fault… Have to further debug that!

You were right, now camera show pictures, but save only two to three pictures then addon stops. Maybe my log can help you:

starting version 3.2.2
[Info] Show connected usb devices
Bus 001 Device 002: ID 0424:9514
Bus 001 Device 001: ID 1d6b:0002
Bus 001 Device 003: ID 0424:ec00
Bus 001 Device 004: ID 093a:2468
crw-rw----    1 root     44         81,   0 Sep 20 23:15 /dev/video0
otal 64
drwxr-xr-x    3 root     root          4096 Sep 20 22:51 .
drwxr-xr-x    3 root     root          4096 Sep 20 22:51 ..
-rwxr-xr-x    1 root     root         13468 Jun  1 10:18 ov511-decomp
-rwxr-xr-x    1 root     root         17564 Jun  1 10:18 ov518-decomp
drwxr-xr-x    2 root     root          4096 Sep 20 22:51 plugins
-rwxr-xr-x    1 root     root          5176 Jun  1 10:18 v4l1compat.so
-rwxr-xr-x    1 root     root          5224 Jun  1 10:18 v4l2convert.so
[0] Processing thread 0 - config file /etc/motion.conf
[0] Motion 3.2.12 Started
[0] Thread 1 is from /etc/motion.conf
[1] Thread 1 started
[1] cap.driver: "pac207"
[1] cap.card: "CIF Single Chip     "
[1] cap.bus_info: "usb-3f980000.usb-1.4"
[1] cap.capabilities=0x85200001
[1] - VIDEO_CAPTURE
[1] - READWRITE
[1] - STREAMING
[1] Test palette YU12 (352x288)
[1] Using palette YU12 (352x288) bytesperlines 352 sizeimage 152064 colorspace 00000008
[1] found control 0x00980900, "Brightness", range 0,255 
[1] 	"Brightness", default 46, current 46
[1] found control 0x00980910, "Gamma", range 500,3000 
[1] 	"Gamma", default 1500, current 1500
[1] found control 0x00980911, "Exposure", range 3,90 
[1] 	"Exposure", default 5, current 32
[1] found control 0x00980912, "Gain, Automatic", range 0,1 
[1] 	"Gain, Automatic", default 1, current 1
[1] found control 0x00980913, "Gain", range 0,31 
[1] 	"Gain", default 7, current 24
[1] mmap information:
[1] frames=4
[1] 0 length=155648
[1] 1 length=155648
[1] 2 length=155648
[1] 3 length=155648
[1] Using V4L2
[1] Resizing pre_capture buffer to 1 items
libv4l2: error dequeuing buf: I/O error
[1] v4l2_next: VIDIOC_DQBUF: EIO (s->pframe 1): I/O error
[1] v4l2_next: VIDIOC_QBUF: Invalid argument
[1] Video device fatal error - Closing video device
[1] Closing video device /dev/video0
libv4l2: warning v4l2 mmap buffers still mapped on close()
[1] File of type 2 saved to: /share/motion/01-20170920231831-snapshot.jpg
[1] Retrying until successful connection with camera
[1] cap.driver: "pac207"
[1] cap.card: "CIF Single Chip     "
[1] cap.bus_info: "usb-3f980000.usb-1.4"
[1] cap.capabilities=0x85200001
[1] - VIDEO_CAPTURE
[1] - READWRITE
[1] - STREAMING
[1] Test palette YU12 (352x288)
[1] Using palette YU12 (352x288) bytesperlines 352 sizeimage 152064 colorspace 00000008
[1] found control 0x00980900, "Brightness", range 0,255 
[1] 	"Brightness", default 46, current 46
[1] found control 0x00980910, "Gamma", range 500,3000 
[1] 	"Gamma", default 1500, current 1500
[1] found control 0x00980911, "Exposure", range 3,90 
[1] 	"Exposure", default 5, current 38
[1] found control 0x00980912, "Gain, Automatic", range 0,1 
[1] 	"Gain, Automatic", default 1, current 1
[1] found control 0x00980913, "Gain", range 0,31 
[1] 	"Gain", default 7, current 22
[1] mmap information:
[1] frames=4
[1] 0 length=155648
[1] 1 length=155648
[1] 2 length=155648
[1] 3 length=155648
[1] Using V4L2
/run.sh: line 40:    38 Segmentation fault      (core dumped) LD_PRELOAD=/usr/lib/libv4l/v4l2convert.so motion -c $CONFIG < /dev/null

I’ve added a new version - it uses debian:jessie as docker base image now.
Pro: seems to work stable now
Contra: the size of the docker image increased a lot