Course materials · Microprocessor Applications

Camera frames and frame rate

English translation

Learning objectives

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

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.

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

import numpy as np
import matplotlib.pyplot as plt
x,y=np.meshgrid(np.linspace(0,255,160),np.linspace(0,255,120))
frame=np.stack([x,y,255-x],axis=-1).astype(np.uint8)
small=frame[::2,::2]
print(frame.shape,frame.nbytes,small.shape,small.nbytes)
# TODO: Record comparison plots and ratios.

Record results and self-check

Video:

shape:

dtype:

Array bytes:

Ratio to original:

Points to check

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

timestamp=np.array([0,.033,.067,.100,.150,.183])
intervals=np.diff(timestamp)
print('observed FPS',1/intervals.mean())
# TODO: Create tables and plots for each interval.

Record results and self-check

Interval:

Δt [s]:

1/Δt by interval [Hz]:

Observed delay:

Points to check

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

roi=frame[20:80,40:120]
# TODO: Compare the ROI, resized full image, and original in the same panel.

Record results and self-check

Method:

Region and resolution:

Preserved field of view:

Remaining detail:

Points to check