GraphicOverlay

class GraphicOverlay(context: <ERROR CLASS>, attrs: <ERROR CLASS>)

A view which renders a series of custom graphics to be overlaid on top of an associated preview (i.e., the camera preview). The creator can add graphics objects, update the objects, and remove them, triggering the appropriate drawing and invalidation within the view.

Supports scaling and mirroring of the graphics relative the camera's preview properties. The idea is that detection items are expressed in terms of a preview size, but need to be scaled up to the full view size, and also mirrored in the case of the front-facing camera.

Associated Graphic items should use .translateX and .translateY to convert to view coordinate from the preview's coordinate.

Constructors

Link copied to clipboard
fun GraphicOverlay(context: <ERROR CLASS>, attrs: <ERROR CLASS>)

Types

Link copied to clipboard
abstract class Graphic

Base class for a custom graphics object to be rendered within the graphic overlay. Subclass this and implement the Graphic.draw method to define the graphics element. Add instances to the overlay using GraphicOverlay.add.

Functions

Link copied to clipboard
fun add(graphic: GraphicOverlay.Graphic)

Adds a graphic to the overlay.

Link copied to clipboard
fun clear()

Removes all graphics from the overlay.

Link copied to clipboard
open fun onDraw(canvas: <ERROR CLASS>)

Draws the overlay with its associated graphic objects.

Link copied to clipboard
fun setCameraInfo(cameraSource: CameraSource)

Sets the camera attributes for size and facing direction, which informs how to transform image coordinates later.

Link copied to clipboard
fun translateRect(rect: <ERROR CLASS>): <ERROR CLASS>

Adjusts the rect's coordinate from the preview's coordinate system to the view coordinate system.

Link copied to clipboard
fun translateX(x: Float): Float
Link copied to clipboard
fun translateY(y: Float): Float