Skip to content

Camera and focus

A new ethoscope with a Pi NoIR camera v1 or v2 is almost certainly out of focus, and the focus may need adjusting again during maintenance. You need a small tool to turn the lens. Some cameras come with one; otherwise print this focus wrench (STL).

Focus with an arena in place, ideally with flies in it, so that the focus is right for real experiments. You also need a continuous video stream from the ethoscope. The easiest way is Video → Start Streaming on the ethoscope’s page in the node.

The Video menu of an ethoscope in the node, with Record Video and Start Streaming

On a slow network, or with an old ethoscope, the stream may be too slow to be useful. Instead, connect a monitor to the Pi’s HDMI port and a keyboard to a USB port, log in (the image’s default user is ethoscope, password ethoscope), and start a full-screen preview:

Terminal window
rpicam-hello -t 0

Stop it with Ctrl+C and log out with exit. On the older Arch Linux images the preview command was /opt/vc/bin/raspivid -t 0 -h 960 -w 1280.

The NoIR versions of the Raspberry Pi cameras have the same optics as the standard versions; only the infrared filter is missing. Historical working distances in ethoscopes are about 130 mm for camera v1 and about 107 mm for camera v2 (106.6 mm between lightbox and case, see the distancing walls).

v1 (OV5647) v2 (IMX219) v3 (IMX708)
Lens focal length 3.6 mm 3.04 mm 4.74 mm
Aperture f/2.9 f/2.0 f/1.8
Focus Fixed, adjustable by hand Fixed, adjustable by hand Autofocus
Minimum focus distance about 50 cm as supplied about 50 cm as supplied about 5 cm
Diagonal field of view 62° 76° 75°
Sensor size 1/4” 1/4” 1/2.43”

Both have a fixed focus, set at the factory to about 1 m to infinity. The lens is glued but can be turned in its holder, which brings the focus down to about 10–15 cm. Ethoscopes need this adjustment: about 130 mm working distance for v1 and about 107 mm for v2. The v2’s shorter focal length gives a wider field of view, so the same magnification needs a shorter distance.

The v3 has autofocus, driven by a voice-coil actuator, with a minimum focus distance of about 5 cm, so ethoscope working distances (107–130 mm) are well within range and no mechanical change is needed. Its sensor is larger and its aperture wider, which helps in infrared light, and it supports HDR. A wide-angle variant (102° diagonal) also exists.

For ethoscopes:

  1. Lock the focus in software to stop the autofocus from hunting during tracking, with the libcamera --lens-position setting. For a working distance of about 110 mm this is roughly 9 dioptres (1/0.11 m).
  2. Start from the v2 working distance (about 107 mm): the v3’s field of view is nearly the same (75° against 76°), because its longer focal length is offset by its larger sensor. Check the exact distance by experiment, as it may differ by a few millimetres.