A camera delivers video from a camera, e.g.,
a webcam, as an image.
camera->open
starts the camera. Each new frame is copied into the same
camera<-image,
so a bitmap that displays this image shows the video, and
camera<-message
is executed:
new(C, camera), send(Window, display, bitmap(C?image)), send(C, open).
The image is replaced by the frame, so its size is the size of the
frames. If camera<-texture
is an sdl_texture, the frames go there instead. They keep the format of
the camera and an sdl_layer shows them in an sdl_window without
converting them on the CPU, which is much cheaper for large frames. The
user may have to give permission to use the camera. Until this is
decided, camera<-status
is waiting.
<-cameras. @nil
uses the first camera.waiting while the user
has to decide whether the application may use the camera and denied
if the user refused.<-status
when it changes.<-image,
keeping their format. Motion JPEG frames are decoded.size is given, the camera uses
the size it supports that is closest: the same size or else the smallest
larger size, using the highest frame rate. Otherwise the camera chooses,
often its largest size. Large frames take time to process. Fails with a
report if there is no such camera.