Course materials · Microprocessor Applications

Camera frames and frame rate

English translation

Choosing a resolution and capture interval requires understanding the trade-offs among storage, field of view, and frame rate.

Before practice

01 How much does storage increase with higher resolution?

Description

Before compression, it is proportional to width × height × channels × bytes per channel.

02 Why can requested FPS differ from recorded FPS?

Description

It depends on exposure, acquisition, conversion, and storage time, as well as the execution environment. Measure it using timestamps.

Execution conditions

Inputs: a generated image and timestamps. The real capture example uses Picamera2 on Raspberry Pi OS. If it is not installed in the OS, run sudo apt install python3-picamera2 in a terminal.

Practice

Preview practice notebookDownload practice notebook

1. Image size and memory

Starting conditions

Use the 120×160×3 uint8 RGB image generated by the provided NumPy code.

Procedure

  1. Record the dimensions, channels, data type, and nbytes.
  2. Display the image reduced with [::2,::2] alongside the original.
  3. Compare the spatial size ratio with the ratio of stored array bytes.

Results to retain

Items to record and points to check
Video
shape
dtype
Array bytes
Ratio to original

Points to check

  • Did you avoid calling the array byte count the JPEG file size?
  • Did you check how halving both axes changes the pixel count?

2. Calculate frame rate from timestamps

Starting conditions

Use the acquisition timestamps timestamp=[00.0330.0670.10.150.183]\mathrm{timestamp}=\begin{bmatrix}0&0.033&0.067&0.1&0.15&0.183\end{bmatrix} s.

Procedure

  1. Use np.diff(timestamp) to calculate the five frame intervals. Calculate observed FPS as the reciprocal of the mean of these five intervals.
  2. List each interval alongside the reference 1/301/30 s, and mark the start and end times of the longest interval. Plot interval number on the x-axis and frame interval [s] on the y-axis.
  3. Record the assumed requested rate of 30 FPS, the calculated observed FPS, and the number of frames in the timestamp record as separate items.

Results to retain

Items to record and points to check
Interval
Δt [s]
1/Δt by interval [Hz]
Observed delay

Points to check

  • Did you distinguish the total frame count divided by the last timestamp from the interval-based value?
  • Did you check the timestamp units?

3. Region of interest and configuration choices

Starting conditions

Select row=20:80, col=40:120 of the original frame as the ROI, and compare it with the reduced full image.

Procedure

  1. Record the ROI coordinates and size, and the size of the reduced full image.
  2. Explain the differences in the field of view and detail preserved by the two.
  3. If actual camera frames and a frame rate are available, add one image captured using the same principles, and record the backend and resolution.

Results to retain

Items to record and points to check
Method
Region and resolution
Preserved field of view
Remaining detail

Points to check

  • Did you distinguish NumPy rows and columns from image x and y coordinates?
  • Did you label results as hardware results only if you added real image capture?