From the BioPass ID In Car Analytics API package, it is possible to use a specialized image analysis service to ensure that the behavior of people inside vehicles complies with Brazilian traffic regulations. This service allows verifying the number of occupants in the car, identifying the coordinates of each person in the vehicle, and detecting any situation that deviates from the required standards.
The main process certifications carried out include:
- Detection and counting of people;
- Passenger recognition;
- Verification of food or beverage consumption;
- Verification of seatbelt usage;
- Verification of cellphone usage.
To use this service, the client must make the call through the API. The complete documentation is available on the website https://docs.biopassid.com/.
To successfully identify the people inside the car, the image needs to be captured from the vehicle’s dashboard, ensuring both the driver and the passenger are visible. Below is an example of how the request body would look like:
{
"Check": {
"Image": "{{base64}}",
"Coordinates": {{bool}}
}
}
The request header, in turn, is where the content type and your subscription key should be inserted. Below is an example of how the header should be represented:
{
'Content-Type': 'application/json'
'Ocp-Apim-Subscription-Key': '<API-KEY>'
}
Finally, in the request, you should include the parameters specifying that it is a POST method, the URL ‘https://api.biopassid.com/incaranalytics/check_incar’, along with the previously described header and body. Below, we present an example of Python code that makes this request. Examples in other programming languages can be found in our documentation.
import http.client
import json
conn = http.client.HTTPSConnection("api.biopassid.com")
payload = "{\r\n \"Check\": {\r\n \"Image\": \"{{base64}}\",\r\n \"Coordinates\": {{bool}}\r\n }\r\n}"
headers = {
'Content-Type': 'application/json',
'Ocp-Apim-Subscription-Key': '{{subscription-key}}'
}
conn.request("POST", "/incaranalytics/check_incar", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
The response received in the case of a successful operation will include various fields, as described below.
Response fields:
- DetectedPeopleCount: Number of people detected by the operation.
-
DetectedPeople: List of objects containing the coordinates of the people. If the option Coordinates for is set to false during the call or is not provided, this field will not appear in the response. Each object in the list has the following fields, indicating the coordinates of each detected person:
- X: Starting coordinate horizontally.
- Y: Starting coordinate vertically.
- Width: Width of the coordinate horizontally.
- Height: Height of the coordinate vertically.
- IsConformed: Result of the identification operation.
The response message for the provided example can be seen below:
{
"InCar": {
"DetectedPeopleCount": {int},
"DetectedPeople": [{
"X": {int},
"Y": {int},
"Width": {int},
"Height": {int}
}],
"IsConformed": {bool},
}
}
If an error is returned, check whether the body and request content are correctly filled. If you receive a message with the code 200 (OK), it means that your request was successfully processed and completed.