Lichtvervuiling in Utrecht

Sorry, this post is in Dutch.

Afgelopen week ben ik een avondje op stap geweest met Stefan Speelberg, 2e jaars student aan de Hogeschool voor Journalistiek.
Zijn opdracht was het maken van een radio item van 3 minuten over lichtvervuiling en de overlast die amateur astronomen die hiervan ondervinden.

Hoe we de lichtvervuiling in de binnenstad van Utrecht en in een donkere omgeving ergens in de provincie ervaren, kan je horen in onderstaand radio item.

Nog even voor de duidelijkheid: dit item is niet echt op de radio uitgezonden geweest. Het was een studie opdracht van Stefan voor een fictief radioprogramma.

Using the Raspberry Pi for camera surveillance using Motion and cloud storage

February, 16th 2014
A fully updated post using BoxFS2 with oauth2 authentication.
The previous version of this post used an old version of BoxFS which is now obsolete because changed their API.

If you are looking for a cheap camera surveillance setup, the Raspberry Pi is a great solution.
It is small, easy to install and, most important, has low energy usage.
I own Model B (see the Raspberry Pi Wikipedia page for detail about the models) which uses 3.5 Watts.

There are several open source motion detection applications for Linux such as ZoneMinder and Motion.
Both programs are available through the Rasbian repository.
ZoneMinder looks like a real security control center with all those nice cam screens, but it’s too bloated and too CPU heavy for the Raspberry Pi.
Motion is more lightweight and doesn’t stress the CPU too much when processing 320×200 camera data.
With 2 IP camera’s my average load is less than 0.50 on my RasPi, which also serves as an caching DNS server.

For storage of the AVI video files which contain the captured motion frames, I use a free account. provides the same service as the popular Dropbox.
The reason for choosing is because Dropbox has no open source client. The Dropbox Linux client is closed source and has, at the moment, no support for ARM devices like the Raspberry Pi.
Furthermore the free account gives you 10 GB of free storage. Way enough to store home camera data for a couple of months.

is the weapon of choice to mount your account as a drive partition on your Raspberry Pi.
Some basic Linux knowledge is preferred.

Setting up BoxFS2
First, read the README file on the BoxFS2 site carefully for the needed dependencies 🙂

Install the needed libraries from the command prompt:

sudo apt-get install libxml2-dev libfuse-dev libcurl4-gnutls-dev

Besides some libraries from the Raspbian repository, you’ll also need libapp and libjson.
Get the latest commits from boxfs2, libapp and libjson:

git clone
git clone
git clone

Compile libapp first, then libjson and boxfs2 last using make and sudo make install.
After installing make sure you run the command ldconfig to update links to the libraries for the operating system.
Forgetting this might give you some error messages about not found libraries.

The BoxFS2 binary will be installed in /usr/local/bin.

Creating a BoxFS2 config file
With the command boxfs-init you can create a config file for BoxFS2.
The configuration file will be placed in the directory .boxfs2.

Open an editor and the configuration file would look something like this:

# Conf file for boxfs
# edit to fit your needs.

# Put oauth2 tokens here:
token_file = /home/pi/.boxfs/token

# Set a valid mount point
mountpoint = /home/pi/
verbose = no
largefiles = no

# Configure the cache
cache_dir = /home/pi/.boxfs/cache
expire_time = 1440

# Configure your uid and gid below:
uid = 1000
gid = 1000
fperm = 644
dperm = 755

The mountpoint must be provided in either way. This can be an empty directory called /motion for example.

Also check the user id (uid) and the group id (gid) of the user you are using.
You can check this in the passwd file which is located in /etc.
In my case I’m using user pi which has user id 1000 and group id 1000.

To let Boxfs2 run as a non-root user you have to add your user to the fuse group:

sudo gpasswd -a fuse

If you won’t do this, the following error message will be shown:
fuse: failed to open /dev/fuse: Permission denied

Also the execute bit of the fusermount binary should be set:

sudo chmod +x /bin/fusermount

Forgetting this will cause mounting to fail with this error message:
fuse: failed to exec fusermount: Permission denied

Mounting your account using BoxFS
To start the BoxFS2 client, simply run this command from the home directory of your user:

boxfs -f .boxfs/boxfs.cfg

The first time you run boxfs, you will need to complete the authentication (oauth2) process and grant access to your account. It’s easy, just follow the instructions on the terminal and on your browser.

When the mount is successful, set the right permissions with the command chmod -r 755 <mountpoint>.

To check if everything is doing what it should be doing, go to your BoxFS mount point and try to create or copy some files.
For debugging I recommend to be logged in to your account with your browser to see if things are actually written in to the cloud storage.

Installing and configuring Motion

To install Motion just run this command:

sudo apt-get install motion

Be sure that your camera’s and/or webcams output a 320×200 (or 240) image and Motion is configured with the same resolution.
I’ve tried a resolution like 640×400 pixels, but the CPU load went sky high on the RasPi, so I’ve settled for a lower resolution.
The images generated by my camera’s are quite clear and useful, so I’m happy.
I have no experience over clocking the Pi in combination with Motion, but if you do, please share your findings in the comments.
Same goes for solving the above resolution problem 🙂

Further configuring Motion is something you have to do on your own.
The on line manual is quite clear about the numerous settings which can be done.
Mailing an image snapshot or a simple message when motion is detected is just one of the many possibilities.
Oh, and don’t forget to set the path to your BoxFS2 mount point to store your videos 😉

When you’ve got an mobile device, you can use the app to download an AVI file and watch it using a movie player which supports the file format.
Great when you’re on holiday for example, and want to know what’s going on at home.
And all of this without tampering  your firewall, keeping your home network closed and secure.

I hope this post helps you to set up your own budget camera surveillance system.
For less than 180 euro (that’s 2 decent IP camera’s and a RasPi) you’re all set to go.

The Registax 6 initialize error

In my previous post I wrote about using the Philips webcams with the Linux 3.0 kernel and problems which might occur.
Last week I had to opportunity to capture the planet Jupiter with my webcam and last night I felt like processing the AVI files using Registax 6.

I use Registax 6 on my Ubuntu laptop in a VirtualBox environment running Windows XP. Yeah, some applications just don’t work that good using Wine so I have to use Windows once in a while 😉
Okay, so I clicked the Registax 6 icon and… ERROR The application failed to initialize properly (0xc0150002). Click on OK to terminate the application.


Looking at the Windows System Logs I noticed that some Microsoft Virtual C++ 9 (aka Microsoft Virtual C++ 2008) libraries weren’t found.
Registax was created with Virtual C++ and it seems that those libraries were damaged or deleted.

Downloading and installing the Virtual C++ 2008 Redistributable Package solved the problem.

Hope this helps if you ever stumble upon this error message.

Philips webcams and the Linux 3.x kernel

The Philips SPC900 and ToU Cam Pro II webcams are still very popular by amateur astronomers who want to try out some basic planetary astrophotography.
I happen to be such a person.
A few years ago I said farewell to the Windows operating system and started to use Ubuntu Linux.
I am still very pleased about my decision.

Last Friday was the first imaging session in a while.
Planet Jupiter was tracked by my mount, webcam was plugged into my telescope and connected to my laptop.
I started up my favorite capturing tool wxAstroCapture.
An over exposed image was displayed on my screen so I had to tweak around with the gain.

Bang! Kernel panic.

Using the sliders for controlling gain, brightness etcetera caused the operating system to crash.
After rebooting it happened again, thus so far an evening of webcam imaging 🙁

Now what’s the cause of this?

Philips webcams use special drivers (PWC) to make them work under Linux.
Imaging software such as wxAstroCapture and Qastrocam-g2 use the Video For Linux (V4L) API to communicate with these webcam drivers.
Version 1 of the V4L API was included with the older 2.6 Linux kernel but was replaced with V4L version 2 when Linux kernel 3.x was introduced.
The current status of the webcam drivers is that they aren’t 100% compatible with V4L version 2 and causes, in my case, the OS to crash.

The solution is quite simple: switch back to a Linux 2.6.x kernel.
When booting your machine, choose in the GRUB boot menu the Previous Versions option.
Select a 2.6 kernel version to your taste and the machine will boot with this version.

If you try to use your favorite imaging tool, you’ll notice it works like a charm again.

My laptop runs Ubuntu 12.04 at the moment. I guess switching to another kernel version on other Linux distros with this similar problem will be just as easy.

Happy camming! 🙂