# Deviation-lib

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

## Change detection alert

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 several 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 reset the MapObject to “nil”. Else the function will keep comparing detections against the last input.

### 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. If no input is provided, then no alert will be available.

### Usage

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

MapObject is a class attribute of the LSDPixelBufferRecognition class.

var lsdRecognition : LSDPixelBufferRecognition?
let mapObj : MapObject = MapObject()
mapObj.numricValue = speedLimit?.converted(to:.milesPerHour).value
mapObj.timeStamp = Date().millisecondsSince1970
mapObj.location = CLLocation.init(latitude: self.currentLocation.latitude, longitude:self.currentLocation.longitude)
lsdRecognition?.setMapObject(mapObj: mapObj)


The alerts are received in alertReceived delegate method.

  @objc optional func alertReceived(alerts : [LSDAlert])