Alert-Lib

Alert-lib contains classes that provide functionalities related to distance estimation and alerts.

Distance Estimation

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

The StaticDistanceEstimator 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.


// DISCLAIMER: These camera properties are from the camera of a 
// Pixel 1 (G-2PW4100) Android phone, so may cause inaccurate 
// distance values if the capture camera of the input 
// video has different properties.
 const ls::SizeF sensorSize{6.2743998f, 4.7181997f};
 const float focalLength(4.67f);
 const ls::Size frameSize{640, 480};

std::vector<std::shared_ptr<ls::TrackedRecognition>> masterObjectRecognitions;

std::shared_ptr<ls::TrackedRecognition> trackedRecognitionPtr = std::make_shared<ls::TrackedRecognition>();
trackedRecognitionPtr->id = "example_id";
trackedRecognitionPtr->detectionLabel = "car";
trackedRecognitionPtr->trackedLocation = ls::BoundingBox(15, 15, 100, 100);
masterObjectRecognitions.push_back(trackedRecognitionPtr);

 // Static distance estimator
ls::StaticDistanceEstimator distanceEstimator;
distanceEstimator.estimateDistance(masterObjectRecognitions, frameSize, 0, focalLength, 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 frames'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 for Linux provides the feature of alerting the user/driver of Time to Collision. This feature helps to avoid accidents and ensure driver safety. The feature is applicable for car, car-brake-light-on, pedestrian and bicycle. 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

ls::LSDAlertManager contains extra heuristics for alerting the user of possible hazards in their path. This includes 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 TTC value:

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

For ls::LSDAlertManager to fully function, it requires the following inputs:

  • Certain properties of the camera being used. For more information, see ls::LSDCameraProperties.
    • This only needs to be set once per camera setup. This does not include device rotation.
  • The vehicle's current speed continuously fed in via setCurrentSpeed().
  • The latest collection of ls::TrackedRecognition continuously fed in via determineAlerts().

std::vector<std::shared_ptr<ls::TrackedRecognition>> masterObjectRecognitions;

std::shared_ptr<ls::TrackedRecognition> trackedRecognitionPtr = std::make_shared<ls::TrackedRecognition>();
trackedRecognitionPtr->id = "example_id";
trackedRecognitionPtr->detectionLabel = "car";
trackedRecognitionPtr->trackedLocation = ls::BoundingBox(280, 240, 360, 300);
masterObjectRecognitions.push_back(trackedRecognitionPtr);

int frameWidth = 640;
int frameHeight = 480;
auto frameTimestamp = ls::getCurrentTimestamp();

auto managerPtr = ls::LSDAlertManager::make();
 //Configure ls::LSDAlertManager.
addAlertSettings(managerPtr);

// Add callback to receive alerts
auto callbackHandle = managerPtr->addCallback([](const std::vector<ls::LSDAlert>& alerts) {
    // Alerts available via callback and as return of `ls::LSDAlertManager::determineAlerts`
});

managerPtr->determineAlerts(masterObjectRecognitions, frameWidth,frameHeight,frameTimestamp);

void addAlertSettings(const std::shared_ptr<ls::LSDAlertManager> &managerPtr) {
    ls::LSDAlertSettings alertSettings;
    alertSettings.useProximity = true;
    alertSettings.useOnEntry = true;
    alertSettings.enableInfoAlerts = true;
    //Change the speed if you want to see proximity alerts.
    managerPtr->setCurrentSpeed(0);
    managerPtr->setAlertSettings(alertSettings);

    //Camera settings
    ls::LSDCameraProperties cameraProperties;
    // DISCLAIMER: These camera properties are from the camera of a
    // Pixel 1 (G-2PW4100) Android phone, so may cause inaccurate or
    // incorrect alerts if the capture camera of the input
    // video has different properties.
    const ls::SizeF sensorSize{6.2743998f, 4.7181997f};
    cameraProperties.setFocalLength(4.67f);
    cameraProperties.setSensorSize(sensorSize);
    managerPtr->setCameraProperties(cameraProperties);
}

results matching ""

    No results matching ""