Make a camera for lenticular photography

Installing the Camarray HAT

You can install the required applications and the driver for the quad kit with the shell script

install_pivariety_pkgs.sh

(Listing 1). More information is available in the ArduCam documentation.

Listing 1

Installing the Camarray HAT

$ wget -O install_pivariety_pkgs.sh https://github.com/ArduCAM/Arducam-Pivariety-V4L2-Driver/releases/download/install_script/install_pivariety_pkgs.sh
$ chmod +x install_pivariety_pkgs.sh
$ sudo apt-update
$ ./install_pivariety_pkgs.sh -p libcamera_dev
$ ./install_pivariety_pkgs.sh -p libcamera_apps
$ ./install_pivariety_pkgs.sh -p imx519_kernel_driver_low_speed
[...]
$ libcamera-still --list-cameras
  0 : imx519 [4656x3496] (/base/soc/i2c0mux/i2c@1/imx519@1a)
  Modes: 'SRGGB10_CSI2P' : 1280x720 1920x1080 2328x1748 3840x2160 4656x3496

After the libcamera-hello command, the camera will respond for a short while. The

libcamera-still --list-cameras

command (Listing 1, last command) checks which cameras are connected. As mentioned before, the software identifies the four sensors as a single device.

Libcamera

The release of the Raspberry Pi OS "Bullseye" operating system in November 2021 fundamentally changed the handling of the camera module. Brand new libcamera commands have since replaced the tried and trusted command-line tools raspistill and raspivid. You can still use raspistill in legacy mode, but makers with more ambitious goals need to get comfortable with the libcamera library.

The transition of the camera control to the Linux kernel's Libcamera driver ensures a standards-compliant solution without proprietary code. New commands such as libcamera-still or libcamera-vid are available, and you can build your own apps on the Libcamera code. Extensive documentation can be found on the Raspberry Pi Foundation [6] website.

If you have already worked with raspistill or raspivid, it should not be difficult to come to grips quickly with Libcamera. The sample code

$ i2cset -y 10 0x24 0x24 0x00
$ libcamera-still -t 30000 --ev -5 --gain 8--roi 0,0,1,1 --autofocus --info-text "Killepitch" -o testQuadro.jpg

captures the entire image (region of interest, --roi) in autofocus mode after a preview time of 30 seconds (time out, -t) with an exposure compensation of -5 (exposure value, --ev). The --gain 8 parameter corresponds to an ISO value of 800, and the --info-text flag lets you manipulate the header in the application; the output file is assigned the name testQuadro.jpg (output, -o).

Shooting Lenticular Photos

The DIY camera is designed to be point-and-shoot, but the implementation is a little more modest because of the available technology. In my test environment, the system is connected to the local WiFi network behind a mobile router. After switching on the camera, the operating system boots and logs on to the WiFi network. The Virtual Network Computing (VNC) server starts up at boot time.

The same applies to the graphical user interface (GUI; Figure 5), with simple setup functions such as image name, shutter speed, exposure value, preview image, and shutter trigger. The GUI offers more functions, but I will not be using them for the time being. The software, written in Python, uses Guizero with object-oriented controls. It keeps its settings in a dictionary and uses system commands to call the camera functions (see also the "Graphical User Interface" box).

Figure 5: You can set the basic values for the shot in a GUI.

Graphical User Interface

In the download section for this article you will find the lentiCam.py GUI [7], which I programmed in Python. The dcim/ directory also contains some recent images as examples of the components of a lenticular image.

The images for positions A and B and the individual image tiles end up in the dcim/randomCode/ directory with randomized image labels. The GUI displays the generated random code, which can be changed alphanumerically if required. You decide in advance whether you want to create two, four, or eight exposures. The camera settings can be saved so that you can reuse them for later shots. To align the camera, click the Preview button; status messages are displayed in the header.

Finding a shooting scenario is now the problem. The camera is oriented horizontally. By rule of thumb, the distance to the object is 30 times the distance from the right to the left camera (close-up distance 1/30). Intermediate images split this distance evenly, as you can see in Figure 6, working with four sensors at a distance of 12cm with two intermediate images. This results in a close-up distance of about 3.6m. If you move the lens board by 2cm, you end up with four shots at 8cm apart, and ideally approach the subject to within 2.4m.

Figure 6: Intermediate frames divide the base (distance between the right- and left-most cameras).

These approximations are only rough, based on experience, and by no means binding. The close-up value could well be closer to 1/20 than 1/30. As soon as you move your camera between two positions, you are forced to limit your work to static objects. Manual exposure by shutter speed and gain settings is generally recommended.

After capturing an image, you then need to break the frame down into individual tiles for further processing with the help of the FFmpeg suite or ImageMagick tools, which you can install with:

sudo apt-get install imagemagick
sudo apt-get install ffmpeg

To ensure that the images are ordered correctly, add a numerical suffix in the file name.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Miniature Photography

    The combination of a web camera, Raspberry Pi, and simple software facilitates miniature tabletop photography.

  • Digital_Photo_Intro.pdf

    The Linux environment includes some powerful tools for editing, managing, and scanning digital images.

  • New Raspberry Pi Camera

    The popular Raspberry Pi single-board Linux computer gets a new add-on camera device.

  • Hugin

    Hugin is a tool for creating panoramic images, with many additional functions that make it a powerful supplement to your image editing toolbox.

  • Gimp and Photos

    Gimp will help you dial up the quality on your less-than-perfect digital

    images.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News