Stream camera frames as MJPEG over HTTP with FastAPI.
The endpoints are the same as those of the Odysseus robot's server, so
the pi_camera_line_following example works with either:
GET /odysseus/camera the camera, as an MJPEG stream
GET /odysseus/camera/square-path generated frames of a square path, one
side at a time, as an MJPEG stream
GET /odysseus/camera/frame the latest camera frame as one JPEG
GET /odysseus/camera/info the source, frame size and frame rate
On a Raspberry Pi 5 with a camera module the camera frames come from Picamera2.
Point the camera down at a sheet of paper with a square drawn on it in thick
dark lines. On any other computer, --synthetic draws such a square instead.
The square path needs no camera. Every --period seconds its frame shows the
next side of a square, counterclockwise as seen from above: bottom, right, top,
left. The square is centred in the frame.
Usage
python camera_server.py # Pi camera, port 8000
python camera_server.py --synthetic # generated camera frames
python camera_server.py --help