EasyStack Docs

EasyCamera

EasyCamera detects balls with a webcam. It creates a VisionPortal and a built-in pipeline for you, filters the detections by color, size and shape, and gives you the position, size, distance and aiming values of the ball.

#Creating an EasyCamera

Pass the hardware map and the webcam name. The optional size sets the resolution:

Java
EasyCamera camera = new EasyCamera(hardwareMap, "webcam")
        .setColor(EasyCamera.BallColor.PURPLE)
        .setBallDiameter(5, DistanceUnit.INCH)
        .setFov(78)
        .setAimGain(0.8)
        .setAimTolerance(0.05);

camera.start();

Call update() every loop and stop() at the end:

Java
camera.update();
if (camera.hasBall()) {
    double distance = camera.getBallDistance(DistanceUnit.INCH);
}
camera.stop();

#Lifecycle

  • start(), stop(), pause(), resume(): control the camera.
  • update(): reads the latest detections.
  • isRunning(), isStreaming(), getFps(): state of the camera.

#Reading Detections

  • hasBall(), getBallCount(): whether there is a ball and how many.
  • getBall(), getBalls(): the best ball, or all balls, as Ball objects.
  • getBallX(), getBallY(): the position of the ball relative to the center of the image.
  • getBallSize(): the size of the ball in the image.
  • getBallAngle(): the horizontal angle of the ball.
  • getBallColor(): PURPLE or GREEN.
  • getBallDistance(unit): the estimated distance. It needs the ball diameter and the field of view.

#Detection Settings

  • setColor(color): which ball color to look for.
  • setColorRange(color, range): a custom color range.
  • setMinSize(fraction): ignores balls smaller than this fraction of the image.
  • setMinCircularity(value): ignores shapes that are not round enough.
  • setRegion(left, top, right, bottom): only looks inside a part of the image.
  • setBlur(size): blurs the image before detecting.
  • setFov(degrees), setBallDiameter(diameter, unit): needed for distance.

#Aiming

getAimError(), getAimPower(), isAligned(), setAimGain, setAimDeadband, setAimTolerance, setAimMaxPower and setAimDirection work as described in the Vision tab.

#Camera Controls

  • setExposure(ms) / setAutoExposure()
  • setGain(gain)
  • setWhiteBalance(kelvin) / setAutoWhiteBalance()
  • setFocus(length) / setAutoFocus()

Fixed exposure and white balance give more stable colors than the automatic modes.

#Display and Debug

  • showLiveView(), hideLiveView(), setLiveView(boolean): the preview on the Robot Controller screen.
  • saveFrame(fileName): saves the current frame.
  • addTelemetry(telemetry): adds the detection values to telemetry.
  • getPortal(): the underlying VisionPortal.

Last updated 2026-11-16

EasyStack - FTC Java library

This site records page views of visitors to understand how the documentation is used. Nothing is sold or shared with third parties.