I initially started with the Debian OS distribution, since I already run several Debian servers (such as this one) and it, or Ubuntu, are usually my distro of choice. But the experience with Debian on the Pi seems pretty flaky - no sshd by default (which matters to me since I only plan to run my Pi without a screen), and lots of people seem to have trouble getting hardware up and running (especially webcams), so in this case I fairly quickly moved over to Arch Linux - if only for the experience of playing around with another distro.
Arch Linux seems very well set up on the Pi - sshd starts up by default, and there seems to be very little bloat. It's all nicely responsive, and most importantly, hardware support seems to be much more straightforward.
I did a few of the classic initial setup tweaks just to optimize things a little:
- Copy
/boot/arm224_start.elf
over /boot/start.elf
, to reduce the amount of GPU RAM and give that to the main system instead.
- Edit /etc/fstab, and add the
noatime
and nodiratime
flags to the /dev/mmcblk0p1 filesystem. These remove the annoying default write-once-for-every-read behaviour of ext4, which both improves disk read performance and reduces wear on the SD card.
Next up was ensuring the system was up-to-date, with "pacman -Syu". That was mostly painfree, although I accepted the option to get udev from systemd-tools, which required me to manually remove a few files that were already present, and that it wanted to overwrite. Perhaps there's a flag to automatically overwrite - I didn't check. There were also a few files missing from the main mirror, reporting 404 when trying to fetch the packages. I seem to be able to ignore them without any problems - presumably the old versions will continue to be used, which is fine for now.
Now it was time to see if my webcam was supported. After trying a few cheapo webcams with my iMac, I've been using a "Hue HD" webcam happily there, so I tried that first. I plugged it in, and checked dmesg, which looked fairly happy:
A little looking around suggests that the Motion webcam software is pretty good. The download page doesn't mention anything about Arch Linux, but on the offchance I tried grabbing it from the package repository with pacman -S motion
. To my surprise, that worked just fine!
Motion has a lot of options, including automatic capture of images based on motion detection (its main purpose), as well as a simple webcam server. For now, I just wanted to see whether the webcam worked, so I set up the minimum number of options required to get that going, by editing /etc/motion/motion.conf
as follows.
- Comment out the
target_dir
setting - I don't have apache installed yet, so writing files to the current working directory (the default setting) is preferable.
- Increase
webcam_maxrate
from 1 to 4, to try to get a higher framerate.
- Turn
webcam_localhost
and control_localhost
both off, so that the system can be accessed across the network.
I found that I also had to create /var/run/motion
for the PID file to be written, but once done, I was able to start it up with "motion
" and connect a browser to http://raspi1:8081/, and everything was working well.
I don't get a great framerate - maybe 2 FPS - but that's OK for now. Possibly, if I tried turning off some of the motion detection, then that would go up. But it wasn't immediately obvious how to do that, and the CPU usage wasn't particularly high anyway, so maybe that's not the bottleneck. Shrug.
Another nice feature of Motion is its built-in web config console, on port 8080 by default. You can use that to dynamically tweak all the settings, for rapid experimentation to find the optimum settings.
Well, there we go - a simple webcam setup with just about zero pain. It seems to use anything up to about 25% CPU on the Pi, which seems fairly respectable. I've just found that OpenCV is also available as a pacman package - so that will be my next step, I think...