Controlling a photo camera with gPhoto2
gPhoto2 is an open source, vendor-neutral camera control tool for Unix-like systems, such as Linux and Mac. It supports photo cameras of multiple brands, including Canon, Nikon, Olympus, Pentax, Sony, and Fuji. The supported features vary by model. The following table lists gPhoto2's major features, alongside the official count of supported cameras for each feature:
These numbers are current as of version 2.5.8, and are conservative. For example, some configuration features are supported on the Nikon D80, even though the gPhoto2 documentation does not list this camera as configurable. For our purposes, image capture and configuration...
Detecting the presence of a photogenic subject
Chapter 1, Getting the Most out of Your Camera System, proposed that a photograph ought to capture a subject in a moment. Let's explore this notion further as we search for ways to detect a desirable or "photogenic" subject and moment.
As a medium, photography uses light, an aperture, a photosensitive surface, and time to draw an image of a scene. The earliest photographic technology, in the 1820s, lacked the resolution and speed to convey a detailed subject in a precise moment, but it was able to capture a grainy scene on a sunny day. Later, with better lenses, flashes, and photosensitive surfaces, photography became capable of capturing a sharp scene, a formal portrait, a faster and more natural portrait, and finally a moment of action, frozen in time.
Consider the following series of famous photographs, ranging from 1826 to 1942:
For general interest, here are some details about the preceding photographs:
Processing images to show subtle colors and motion
By now, you have probably captured some exposure-bracketed photos and time-lapse photos. Upload them onto your computer using a photo management application, a file browser, or the following gPhoto2 command:
The latter command will upload the files to the current working directory.
We will merge exposure-bracketed photos to create HDR images, which will improve color rendition in shadows and highlights. Similarly, we will merge time-lapse photos to create time-lapse videos, which will show gradual motion on an accelerated scale. We will start by processing some of the sample photos from the book's GitHub repository at https://github.com/OpenCVBlueprints/OpenCVBlueprints/tree/master/chapter_2/CameraTrap/media, and then you will be able to adapt the code to use your photos instead.
OpenCV 3 has a new module called "photo". Two of its classes, MergeDebevec
and MergeMertens
, create an HDR image by merging...
Computational photography is a diverse and popular field, which combines the work of artists, technicians, and scientists. Thus, there are many types of authors, instructors, and mentors who can help you become a better "computational photographer". Here are just a few examples of helpful guides:
Learning Image Processing with OpenCV, by Gloria Bueno García et al (Packt Publishing, 2015), covers a wide range of OpenCV 3's capabilities with respect to image capture, image editing, and computational photography. The book uses C++, and is suitable for beginners in computer vision.
The National Geographic Masters of Photography video lectures (The Great Courses, 2015) provide great insight into the goals and techniques of master photographers. Several of the lecturers are wildlife photographers, whose use of camera traps was an inspiration for this chapter.
OpenSource Astrophotography, by Karl Sarnow (CreateSpace Independent Publishing Platform, 2013), covers the use of gPhoto2 and...
This chapter has demonstrated a set of surprisingly flexible commands and classes, which enable us to conduct experiments in computational photography, with short and simple code. We have written scripts to control a photo camera. Along the way, we have acquainted ourselves with gPhoto2, the Bash shell, PTP communication, GVFS mount points, and Python's support for subprocesses. We have also scripted several variations of a photo trap to take pictures when a subject comes into view. For this, OpenCV has provided us with the capability to detect motion, measure color similarities, and classify objects. Finally, we have used OpenCV to combine a set of photos into a time-lapse video or HDR image.
So far, this book has provided a fairly broad survey of ways to capture light as data, control a camera, detect a subject, and process a photo. The remaining chapters will focus on a selection of advanced techniques, which will enable us to perform much finer classification and identification...