Saturday 26 April 2014

BirdBoxPiCam2014: Factors affecting image quality


The RaspberryPi camera (RaspiCam) is capable of high definition photos and video.


But there are a number of factors which influence the quality of the images that I can view and capture using my system.


This post describes some of the photographic challenges.

While I am very happy with the results achieved so far using this system, there are some points which could possibly be improved, and a few that I am probably stuck with.


Focus & Depth of Field


You can focus a camera lens at a specific distance from the lens, giving a depth of field where the image remains acceptably sharp in front of, and behind the focal point. On a hand held camera, the depth of field can be increased or decreased by changing the aperture setting. Also, the closer the focal point is to the camera, the narrower/shorter the depth of field.

So with a birdbox camera we have to carefully consider where to set the focal point. If set to give a sharp image of the bottom of the empty box, what will the image of the adult birds look like after the floor has been raised by the addition of 50-70mm of nest material?

Focusing the camera back in February

As a compromise between seeing the adults in focus as well as the new born chicks, the bird box camera is generally focused about 70-90mm above the base of the box. However, when the chicks are only a few days old and contained deep down within the next cup, they may look distinctly blurry.

Lighting


Without light (or some other means of illumination) there would be no photography.

With any electronic camera (like the RaspiCam) there will be electrical circuit noise which may result in "noise" on the image. If there is plenty of light to illuminate your image, the noise will not be noticable. But in very low light levels where the image "signal" may have to be amplified (e.g. by increasing the ISO setting) noise may show up on the image.

So the first point is that we need plenty of light, which may be a problem in a box with just a 25-30mm diameter entrance hole.

The second point is the source of the light.


Direct sunlight can be a bit of a problem as it produces a spot of light when shining straight through the entrance hole. While a cloudy sky might not provide enough illumination in the box for acceptable images.

The light source position or direction also influences the final picture. Putting the light source around or next to the camera lens provides even illumination, reducing shadows and exposing all detail in the image.

Lit from the 10mm LEDs positioned around the camera


However, it does produce a rather flat picture. Whereas positioning the light source at an angle to the camera tends to increase depth in a picture by casting shadows.

Lit by daylight only (from the 32mm hole to the left of image)


Lens Distortion & Alignment


As already mentioned, the RaspiCam is capable of good results. But the lens provided is pretty cheap, so you may notice problems on one unit that are much less noticeable on another.

In my case I have replaced the standard lens with a larger board lens, but I seem to have a focus issue just to the right of the image. If this was just due to the lens I would expect this to move around the image as the lens is rotated. As this is not the case, I suspect that the lens is not mounted centrally to the sensor.

Resolution Trade-offs


Images (stills or video) look at their best when viewed on a display where the display resolution is equal to the image resolution. "Up-scaling" an image (where you display a 640x480 image full-screen on a 1280x1024 display) always leads to disappointment. I stream my bird box video at 640x480 because the wifi network can't cope with anything larger.

However when taking stills, I can use high resolution as I have plenty of space on the RaspberryPi sd card, and they can subsequently be moved across the network to a local laptop. But high resolution video captures take up a lot more space, and can take a long time to copy to a local machine.

Video posted on this blog has been encoded and then re-encoded a couple of times to reduce file size.

Spiders


If you've ever installed and run a bird box camera and not seen a spider building a web across the lens, consider your self very lucky.

No spider, but look at the ghostly cloud floating around on the left of this video clip. Fortunately this web seems to have disappeared after a couple of days.

While the spider will probably end up as a snack for one of your birds, the web can hang around for days messing up your view!

Using RaspiCam Settings


Up till now I've just used the camera default setting, but I have spent a few hours recently experimenting. The first thing to say is that my RaspberryPi firmware is not up to date, so some of the problems I found may have been fixed (or maybe I just misunderstood what they are supposed to do!).

The settings that don't seem to work include ISO and EV. I also found that the affect of brightness and contrast differ when used on video as compared to stills.

I started by taking a few stills and opening them in The Gimp. They looked a bit washed-out and a quick look at the histogram revealed a fairly narrow distribution of pixel intensity.

Increasing contrast widens the histogram. Increasing brightness moves it to the right.


By increasing the RaspiCam settings for contrast (-co) and brightness (-br), and then taking similar stills, I found this stretched the histogram and improved the images.

Contrast increased from 0 (range -100 to +100) to 60 & brightness from 50 to 55

 

Conclusions

Depth of Field

I don't think there is much that can be done about the limited depth of field. I could make the bird box bigger and move the camera further away, but I'd probably lose any benefit once I'd replaced the lens with a narrower angle of view to fill the screen once again.

In our robin box we have 2 cameras. One is wide angle and set to focus higher in the box. The other produces more of a close-up image of (where I think) the nest cup will be, and is focused accordingly. I don't think I can do this with the RaspberryPi. Maybe I need some sort of motor controlled lens?

Lighting

I am please with the 10mm LEDs and the dim/bright control fitted to this bird box.

If I can position the camera at an angle for BirdBox2015 (rather than looking straight down on their heads), I'll probably try to include two banks of LEDs; one overhead and one around the camera lens. I may also consider some kind of window to let in more natural light.

The Lens

When I modify the next RaspiCam to take a large lens mount, I need to find a better way to align it. Maybe some kind of test card would help to identify problems before the mount is glued into place.

The field of view is just about right, although a slightly narrower angle lens would also be acceptable.

Resolution and Video Streaming

I need a faster wifi network or go back to cable.

Spiders

Maybe a motor with a blade or paddle to clear away the cobwebs (...yes, I'm joking!).

Camera Settings

I need to fully investigate these and build controls for contrast, brightness, white balance & so on into my controller user interface.


Nest News...


Our 10 great tit chicks are growing fast...



...and mum & dad are having to work a bit harder...

The first chick hatched on the 22nd




1 comment:

  1. I suffer from spiders too. I did read some guy who recommended pre-treating nest boxes with some sort of insecticide first but that does sound a little extreme to me. I think a spider caught crawling across the camera lens looks a little creepy, but my kids think its cool. Loving the graph too...

    ReplyDelete