Alert-Lib

alert-lib contains classes related to distance estimation, speed calculation, alerts, camera, and AR overlays.

Distance Estimation

The distance filter estimates the distance of an object from the camera.

The StaticDistanceEstimator class uses an assumed width/height and the camera's properties to determine the camera's distance from an object. The estimator works with cars and pedestrians by default, but may be extended if other objects are needed for your use case. Distances are in meters for default values. For any custom values, the distance unit is the same as the provided size.

public void estimateDistance(List<Recognition> recognitions, Size frameSize, int sensorRotation, float focalLength, SizeF sensorSize)

The following list describes the method parameters:

  • recognitions - List of recognitions to process
  • frameSize - Size of the image that recognitions were derived from at 0 rotation
  • sensorRotation - Clockwise rotation to each frame's natural orientation as a multiple of 90 degrees
  • focalLength - Focal length of the capture camera in millimeters
  • sensorSize - Size of the physical camera sensor in millimeters

Note

The distance value for a Recognition may already be available from the ML model.

TTC - Time to Collision

Live Sense SDK provides the feature of alerting the user/driver of Time to Collision. This feature helps to avoid accidents and ensure driver safety. This feature is applicable to car, car-brake-light-on, and pedestrian detections in the vehicle's expected path. Time to Collision, or TTC, is calculated as follows:

Time to Collision (T) = -1 * d / ( Δd / Δt ) when Δd < 0

  • d = distance to the object
  • Δd = change in distance to the object between processed frames
  • Δt = change in time between processed frames

This calculation only applies when the distance to an object is decreasing. Otherwise, TTC is infinite and no alert is generated.

LSDAlertManager contains extra heuristics for alerting user of possible hazards in their path. These include time-to-collision with the leading vehicle and people entering the vehicle's direct path.

The following list describes the different severity of alerts based on the value of TTC:

  • INFO - If T > 2.5secs
  • WARNING - If 1.8secs < T <= 2.5secs
  • ALERT - If T <= 1.8secs

These are the default configured values. The values for WARNING and ALERT can be changed by the following methods:

  • public void setTimeToCollisionWarning(float timeInSeconds)
  • public void setTimeToCollisionAlert(float timeInSeconds)

For LSDAlertManager to fully function it requires the following inputs:

  • Certain properties of the camera being used. For more information, see LSDCameraProperties.
    • This only needs to be set once per camera setup. This does not include device rotation.
  • The vehicle's current speed, normally provided by the device's location services.
    • This should be continuously fed in via setCurrentSpeed() using device accelerometer or GPS.
  • The latest collection of LSDObjectRecognition.
    • Continuously fed in via determineAlerts().

The LSDAlertManager.onAlerts property is available for an asynchronous feed of alerts.

Kotlin

val alertManager = LSDAlertManager()
// Can set the minimum speed to activate certain alerts
//alertManager.setMinimumSpeed(metersPerSecond)

// Set LSDCameraProperties when camera is initialized or changed
// LSDCamera2Controller provides a LSDCameraProperties instance after LSDCamera2Controller.initialize() is called
// If frame shape is modified (ex. custom cropping), provide a LSDCameraProperties with equally modified sensorSize for accurate proximity alerts
alertManager.setCameraProperties(cameraController.cameraProperties)
// Listen for alerts, alerts are also returned by determineAlerts()
alertManager.onAlerts.addListener { alerts: MutableList<LSDAlert> ->
    // Process alerts
}

// When new speed is available
alertManager.setCurrentSpeed(speedMetersPerSecond)

// When new recognitions are available
alertManager.determineAlerts(objectRecognitions, imageWidth, imageHeight, imageRotation, imageTimestamp)

JAVA

LSDAlertManager alertManager = new LSDAlertManager();
// Can set the minimum speed to activate certain alerts
//alertManager.setMinimumSpeed(metersPerSecond)

// Set LSDCameraProperties when camera is initialized or changed
// LSDCamera2Controller provides a LSDCameraProperties instance after LSDCamera2Controller.initialize() is called
// If frame shape is modified (ex. custom cropping), provide a LSDCameraProperties with equally modified sensorSize for accurate proximity alerts
alertManager.setCameraProperties(cameraController.getCameraProperties());
// Listen for alerts, alerts are also returned by determineAlerts()
alertManager.onAlerts.addListener(lsdAlerts -> {
    // Process alerts
});

// When new speed is available.
alertManager.setCurrentSpeed(speedMetersPerSecond);

// When new recognitions are available
alertManager.determineAlerts(objectRecognitions, imageWidth, imageHeight, imageRotation, imageTimestamp);

results matching ""

    No results matching ""