AN5020 · Application noteIntroduction to digital camera interface (DCMI) for STM32 MCUs
Download .pdfOpen in the full document

Camera modules and basic concepts

Camera modules and basic concepts

This section provides a summarized description of camera modules and their main components. It also highlights the external interface focusing on parallel camera modules.

Basic imaging concepts

This section introduces the imaging field, and gives an overview of the basic concepts and fundamentals, such as pixel, resolution, color depth, and blanking.

  • Pixel: each point of an image represents a color for color images, or a gray scale for black-and-white photos
    A digital approximation is reconstructed to be the final image. This digital image is a two-dimensional array composed of physical points. Each point is called a pixel (invented from picture elements). In other words, a pixel is the smallest controllable element of a picture. Each pixel is addressable. Figure 1 Original versus digital image illustrates the difference between the original image and the digital approximation.
    Figure 1. Original versus digital image
  • Resolution: number of pixels in the image.

    The more the pixel size increases, the more the image size increases. For the same image size, the higher the number of pixels is, the more details the image contains.

  • Color depth (bit depth): the number of bits used to indicate the color of a pixel (is also given in bits per pixel, bpp)
    Examples:
    • For a bitonal image, each pixel comprises one bit. Each pixel is either black or white (0 or 1).
    • For a gray scale, the image is most of the time composed of 2 bpp (each pixel can have one of four gray levels) to 8 bpp (each pixel can have one of 256 gray levels).
    • For color images, the number of bits per pixel varies from 8 to 24 (each pixel can have up to 16777216 possible colors).
  • Frame rate (for video): number of frames (or images) transferred each second, expressed in frame per second (FPS).
  • Horizontal blanking: ignored rows between the end of one line and the beginning of the next one.
    Figure 2. Horizontal blanking illustration
  • Vertical blanking: ignored lines between the end of the last line of a frame and the beginning of the first line in the next frame.
    Figure 3. Vertical blanking illustration
  • Progressive scan: a manner of dealing with moving images
    The lines can be drawn one after the other in a sequence without separating the odd lines from the even ones, as for interlaced scan. To construct the image:
    • In progressive scan, the first line is drawn, then the second, and, finally, the third
    • In interlaced scan, each frame is divided into two fields (odd and even lines), which are displayed alternately

Camera module components

The four components of a camera module are described below.

Image sensor

It is an analog device used to convert the received light into electronic signals. These signals convey the information that constitutes the digital image.

There are two types of sensors that can be used in digital cameras:
  • CCD (charge-coupled device) sensors
  • CMOS (complementary metal-oxide semiconductor) sensors

Both types convert the light into electronic signals, but each has its own conversion method. As their performance continually evolves and their cost decreases, CMOS imagers now dominate the digital photography landscape.

Lens

It is an optic, which allows the reproduction of the real image captured rigorously on the image sensor. Picking the proper lens is part of the user creativity, and affects considerably the image quality.

Printed circuit board (PCB)

It is a board that comprises electronic components to ensure the good polarization and the protection of the image sensor. The PCB also supports all the other parts of the camera module.

Camera module interconnect

The camera interface is a kind of bridge that allows the image sensor to connect to an embedded system, and to send/receive signals. The following signals are transferred between a camera and an embedded system:
  • Control signals
  • Image data signals
  • Power supply signals
  • Camera configuration signals

The camera interfaces are divided into two types: parallel and serial interfaces, depending on the method to transfer data signals.

Camera module interconnect (parallel interface)

As mentioned above, a camera module requires four main types of signals to transmit image data properly: control signals, image data signals, power supply signals, and camera configuration signals. Figure 5 Interfacing a camera module with an STM32 MCU illustrates a typical block diagram of a CMOS sensor, and the interconnection with an MCU.

Figure 5. Interfacing a camera module with an STM32 MCU


  • Control signals: used for clock generation and data transfer synchronization

    The camera clock must be provided according to the camera specification. The camera also provides two data synchronization signals: HSYNC (for horizontal/line synchronization) and VSYNC (for vertical/frame synchronization).

  • Image data signals: each of them transmits a bit of the image data.

    Their width represents the number of bits to be transferred at each pixel clock. This number depends on the parallel interface of the camera module, and on the embedded system interface.

  • Power supply signals:

    As any embedded electronic system, the camera module needs to have a power supply. The operating voltage of the camera module is specified in its datasheet.

  • Configuration signals: used for the following:
    • To configure the appropriate image features such as resolution, format, and frame rate
    • To configure the contrast and the brightness
    • To select the type of interface. (A camera module can support more than one interface: a parallel and a serial interface. The user must then choose the most convenient one for the application.)

Most camera modules are parametrized through an I2C communication bus.

STM32 DCMI overview

This section gives a general preview of the DCMI availability across the various STM32 devices, and gives an easy-to-understand explanation on the DCMI integration in the STM32 MCUs architecture.

The DCMI is a synchronous parallel data bus, which is used for an easy integration and easy adaptation to specific application requirements. The DCMI connects with 8-, 10-, 12-, and 14-bit CMOS camera modules, and supports a multitude of data formats.

DCMI availability and features across STM32 MCUs

Table 2 Availability of DCMI and related resources summarizes the STM32 devices embedding the DCMI, and highlights the availability of other hardware resources that facilitate the DCMI operation, or that can be used with the DCMI in the same application.

The DCMI applications need a frame buffer to store the captured images. It is then necessary to use a memory destination that varies depending on the image size and the transfer speed.

In some applications, it is necessary to interface with external memories that offer large sizes for data storage. Quad-SPI can be used in this case. For more details, refer to the application note Quad-SPI interface on STM32 microcontrollers and microprocessors (AN4760).

The DMA2D (Chrom-ART Accelerator controller) is useful for color space transformation (such as RGB565 to ARGB8888), or for data transfer from one memory to another.

The JPEG codec allows data compression (JPEG encoding) or decompression (JPEG decoding).