# Deviation-lib

Deviation-lib is a library that contains utilities to detect real time changes.

Change detection helps to detect live changes in road conditions and keep the driver updated. Detected objects / signs are compared against those received as an input (in close vicinity of detections) from various sources like maps, web-services. If there is a change in the detected feature vs. the input received, then an alert will be available.

### Note

Currently, the Change Detection function provides alerts for deviations in speed limits only.

### Requirements

The following list describes a few mandatory inputs required for this function:

• The corresponding ML model needs to be initialized.
• Geolocation and value of the stored feature.
• Updated and latest information is to be provided always so that the detections are compared against the most closest and latest features.
• If no stored feature exists for a particular geolocation, then the input values need to be reset to "0" or "NULL" based on the datatype. Else the function will keep comparing detections against the last input.
• If no input is provided, then no alert will be available.
• Location permission is to be explicitly mentioned in Manifest as well as requested during Runtime from end user.

### Note

Not all raw detections will have a corresponding change detection result. Detections are filtered by an internal logic to remove duplicates i.e., identical object in multiple consecutive frames, and then used for comparison.

### Usage

For change detection to function, it requires an input from the map to be given to the setSpeedLimitFromMap() method. This value is then compared against any detections.

For an example of retrieving the speed limit using the HERE Mobile SDK for Android, see the HERE-SDK-example example application provided with the Live Sense SDK.

int speedLimit = numericSpeedLimitValue;
double longitude = currentLocation.longitude;
double latitude = currentLocation.latitude;
Date timestamp = new Date();
ChangeDetectionManager.getInstance().setSpeedLimitFromMap(speedLimit, longitude, latitude, timestamp);


The alerts are received in changeAlertCallback callback method.

ChangeDetectionManager.getInstance().changeAlertCallback.addListener(featureDeviation -> {
// Process FeatureDeviation data
});


## Heuristic Detection

Heuristic detection automatically processes detections from ML models to provide more accurate output. Output from heuristics processing will be less frequent and delayed compared to the output directly from the ML models.

### Note

Currently, the Heuristic Detection function provides callbacks for Road Signs only.

### Requirements

The following list describes a few mandatory inputs required for this function:

• The corresponding ML model needs to be initialized.
• Fine location permission is to be explicitly mentioned in Manifest as well as requested during Runtime from the end user.

### Usage

Heuristic detections are received via listeners added to HeuristicDetectionManager#recognitionFromHeuristicCallback.

HeuristicDetectionManager.getInstance().recognitionFromHeuristicCallback.addListener(objectRecognition -> {
// Process objectRecognition data
});