Class GraphicOverlay

java.lang.Object
android.view.View
app.pivo.android.prosdk.tracking.GraphicOverlay
All Implemented Interfaces:
Drawable.Callback, AccessibilityEventSource, KeyEvent.Callback

public class GraphicOverlay
extends View
A view which renders a series of custom graphics to be overlayed 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 GraphicOverlay.Graphic items should use the following methods to convert to view coordinates for the graphics that are drawn:

  1. GraphicOverlay.Graphic.scaleX(float) and GraphicOverlay.Graphic.scaleY(float) adjust the size of the supplied value from the preview scale to the view scale.
  2. GraphicOverlay.Graphic.translateX(float) and GraphicOverlay.Graphic.translateY(float) adjust the coordinate from the preview's coordinate system to the view coordinate system.
  • Field Details

    • trackPaint

      public Paint trackPaint
  • Constructor Details

  • Method Details

    • disableTouching

      public void disableTouching​(boolean disableTouch)
    • setTrackingMethod

      public void setTrackingMethod​(Tracking type)
    • clear

      public void clear()
      Removes all graphics from the overlay.
    • add

      public void add​(GraphicOverlay.Graphic graphic)
      Adds a graphic to the overlay.
    • remove

      public void remove​(GraphicOverlay.Graphic graphic)
      Removes a graphic from the overlay.
    • setCameraInfo

      public void setCameraInfo​(int previewWidth, int previewHeight, boolean frontFacing)
      Sets the camera attributes for size and facing direction, which informs how to transform image coordinates later.
    • setListener

      public void setListener​(IActionSelector listener)
    • setTimerEnabled

      public void setTimerEnabled​(boolean timerEnabled)
    • reset

      public void reset()
    • onDraw

      protected void onDraw​(Canvas canvas)
      Draws the overlay with its associated graphic objects.
      Overrides:
      onDraw in class View
    • onTouchEvent

      public boolean onTouchEvent​(MotionEvent event)
      Overrides:
      onTouchEvent in class View
    • startTrackingFromCenter

      public void startTrackingFromCenter()
      This function is used to calculate object area, when remote button is clicked.