DSLR Camera Software

Modules

Combining the individual modules together renders a fully functioning software system for a DSLR camera. The basic workflow of the capture image process is as follows (Figure 5):

  1. The camera operator depresses the shutter button halfway down.
  2. The aperture and flash are set in response to the light sensed in the environment.
  3. The focal length of the lens is set based on the distance from the camera to the subject of the photograph.
  4. The camera operator depresses the shutter button all the way down.
  5. The image is captured.
  6. The image is translated to the JPEG format.
  7. The image is persisted to physical storage.
(Figure 5) High Level Functional Overview

The following sections will detail the architectures of the Equipment Operator, Image Processor, and Controller modules.

Module 1 - Equipment Operator

The equipment module is responsible for adjusting the physical pieces of the camera based on the amount of light in the environment and the distance from the camera to the subject of the photograph. When the Controller Module, (see the Module 3 section below for details of the Controller Module), raises a setEquipment event, the Equipment Operator module will respond by engaging the process control detailed in the next section.

Design Element - DE-1

In examining the elements of the problem that module 1 solves, we find that it closely resembles the elements of a closed loop feedback system. Closed loop feedback control systems consist of a problem definition, process input and control variables, a sensor to read the control variable, a set point or target value for the control variable, and an algorithm for controlling the process. Based on the DSLR camera problem space, we will actually have two closed loop feedback controls needed in this module, one for controlling the amount of light required for a photograph and one for controlling the focal length of the lens.

Applying a closed loop feedback control system to our “light and focus” problems we come up with the following process control definitions:

Problem Element Light Problem Focus Problem
Problem Definition The process receives a light measurement as input and open or closes the aperture of the camera and sets the flash to on or off. The process receives a focal point measurement as input and rotates the lens of the camera.
Control Algorithm Read current amount of light in the environment, compare that value to the amount of light required for the image and make adjustments to the aperture and flash. Read the current focal length of the lens, compare that value to the focal length required for the image and make adjustment to the lens.
Control Variable Current light value. Current focal length.
Manipulated Variable Aperture setting. Flash on/off. Lens focal length setting.
Set Point The camera must be in automatic mode. The set point for the aperture is amount of light needed for the image. The flash is either on or off. The camera must be in automatic mode. The set point for the lens is the focal length needed to for the subject of the image to be in focus.
Sensor for the controlled variable The controlled variable is the current light value. This data is supplied by a light sensor in the camera. The controlled variable is the focal length of the lens. This data is supplied by a distance sensor in the camera.

Translating the process control definitions above into an architecture yields the following:

(Figure 6) Process control architecture for setting an aperture based on a light sensor

Here, the camera is in automatic mode and the shutter button is depressed halfway. The Controller Module raises the setEquipment event. The Equipment Operator Module, having registered as a subscriber of this event is invoked. The system determines the set point value for the amount of light required to capture an image and compares that to the control value or current amount of light being let into the camera. The Equipment Operator Module will continually adjust the aperture until the control value equals the set point. When amount of light being let into the camera (the control value) equals the amount of light needed to capture an image (the set point), the Equipment Operator Module disengages the Aperture setting process control and engages the Focal Length process control. If the aperture is fully open and the light being let into the camera (the control value) is less than the amount of light need to capture an image (the set point), the Equipment Operator Module sets the flash to flash to “on” and disengages the Aperture setting process control and engages the Focal Length process control.

(Figure 7) Process control architecture for setting the focal length of a lens based on a distance sensor

Here, the camera is in automatic mode and the shutter button is depressed halfway. The Controller Module raises the setEquipment event. The Equipment Operator Module, having registered as a subscriber of this event is invoked. The system determines the set point value for the focal length required to capture an image that is in focus and compares that to the control value or current distance from the camera to the subject of the photograph. The Equipment Operator Module will continually adjust the lens until the control value equals the set point. When the focal length of the lens (the control value) equals the focal length required to capture an in focus image (the set point) the Equipment Operator Module disengages the Focal Length setting process control and the Equipment Operator Module is closed.

Module 2 - Image Processor

The Image Processor module is responsible for retrieving raw image data from a buffer, converting that data to the JPEG format, and then persisting that JPEG data to physical storage. In addition to the JPEG data, metadata will also be stored with the image. In addition to the metadata detailed in Figure 3, the image metadata consists of the date and time the image was captured and the longitude and latitude coordinates of the location where the image was captured. When Controller Module, (see the Module 3 section below for details of the Controller Module), raises the captureImage event, the Image Processor Module will respond as detailed in the next section.

Design Element - DE-2

The problem domain for this module can be decomposed into objects from the domain. As seen in Figure 8, the Image Processing problem can be broken into the following objects:

  1. Buffer - this object encapsulates the raw image data.
  2. ImageTranslator - this object encapsulates the data and operations for converting raw image data to the JPEG format and performs basic edits.
  3. Image - this objects encapsulate the data and operations of the converted JPEG image and the image’s metadata.
  4. PhysicalStorage - this object encapsulates the data and operations of the saving the image to physical storage.
  5. CaptureProcess - this object encapsulates the data and operations required to respond to the captureImage event, mutate the representation and invoke operations of the other objects in the modules.
(Figure 8) A Class Diagram outlining the structure of the Image Processor module

When the operator of the camera depresses the shutter button all the way down, the Controller Module will ensure that the Equipment Operator Module has completed its work. The Controller Module will then raise the captureImage event. The Image Process Module, having registered for this event is invoked. As seen in Figure 9, when the CaptureProcess object responds to the captureImage event, it creates a Buffer object with the raw image data. The Buffer object containing the raw image data is passed into the ImageTranslator object where it is converted to the JPEG format. The ImageTranslator object also performs basic edits such as removing red eyes for the raw image data. After the raw image data is converted to the JPEG format it is packaged, along with the image metadata into an Image object. The ImageTranslator object then passes the Image Object to the PhysicalStorage object where it is persisted to physical storage.

(Figure 9) Image Processor Module Sequence Diagram
Module 3 - Controller

This module is responsible for providing an eventing system through which the other modules of the system are invoked. The controller module serves as the command and control center for the invocation of the Equipment Operator and Image Processor Modules.

Design Element - DE-3

The Controller Module will be rooted in the Event-Driven/Publish-Subscribe (Pub-Sub) architectural style. The controller object will publish and raise the following events:

  1. setEquipment - This event notifies the other modules of the system that the camera operator intends to capture an image and needs the camera to be adjusted based on the amount of light in the environment and distance between the camera and the subject of the photograph.
  2. captureImage - This event notifies the other modules of the system that the camera has been adjusted to ensure a quality image and that the camera operator wants to capture an image.

The Controller Module does not care what other module or modules in the system may respond to the events that is raises. It is only concerned with informing the other modules that some action needs to be taken. The Controller Module accomplishes this by publishing the setEquipment and captureImage events. The Controller Module allows other modules in the system that are interested in these events to subscribe to them. Each time the Controller Module raises one of these events, it notifies each subscriber so that they may respond. The Controller Module will only publish events when the camera is on and in the automatic mode. When the camera is on and not in automatic mode, full control of the camera is given to the camera operator.

Traceability Matrix
Functional Requirements Category Requirement ID Design ID
Operational FR-1 DE-3
Operational FR-2 DE-3
Operational FR-3 DE-1
Operational FR-4 DE-1
Operational FR-5 DE-1
Operational FR-6 DE-1
Image Handling FR-7 DE-2
Image Handling FR-8 DE-2
Image Handling FR-9 DE-2
Operational FR-10 DE-12
Non-Functional Requirements Operational NFR-1 DE-1, DE-2, DE-3
Operational NFR-2 DE-3
Operational NFR-3 DE-3
Operational NFR-4 DE-4
Operational NFR-5 DE-1
Operational NFR-6 DE-3
Image Handling NFR-7 DE-2
Image Handling NFR-8 DE-2
Operational NFR-9 DE-1
Image Handling NFR-10 DE-2
Previous: High-Level Design Next: Design Rationale