An annotation library that draws overlays on the Raspberry Pi’s camera preview.
Annotations include bounding boxes, text overlays, and points. Annotations support partial opacity, however only with respect to the content in the preview. A transparent fill value will cover up previously drawn overlay under it, but not the camera content under it. A color of None can be given, which will then not cover up overlay content drawn under the region.
Note: Overlays do not persist through to the storage layer so images saved from the camera, will not contain overlays.
Annotator(camera, bg_color=None, default_color=None, dimensions=None)¶
Utility for managing annotations on the camera preview.
- camera – picamera.PiCamera camera object to overlay on top of.
- bg_color – PIL.ImageColor (with alpha) for the background of the overlays.
- default_color – PIL.ImageColor (with alpha) default for the drawn content.
bounding_box(rect, outline=None, fill=None)¶
Draws a bounding box around the specified rectangle.
- rect – (x1, y1, x2, y2) rectangle to be drawn - where (x1,y1) and (x2, y2) are opposite corners of the desired rectangle.
- outline – PIL.ImageColor with which to draw the outline (defaults to the configured default_color).
- fill – PIL.ImageColor with which to fill the rectangel (defaults to None
- will not cover up drawings under the region. (which) –
Clears the contents of the overlay - leaving only the plain background.
point(location, radius=1, color=None)¶
Draws a point of the given size at the given location.
- location – (x,y) center of the point to be drawn.
- radius – the radius of the point to be drawn.
- color – The color to draw the point in (defaults to default_color).
Removes the overlay from the screen.
text(location, text, color=None)¶
Draws the given text at the given location.
- location – (x,y) point at which to draw the text (upper left corner).
- text – string to be drawn.
- color – PIL.ImageColor to draw the string in (defaults to default_color).
Updates the contents of the overlay.