To detect whether an image has a glare or not using computer vision on high-resolution images is very computationally expensive when you are dealing with thousands of images. To overcome this, we can make use of the image metadata to determine the possibility of it having glare or not. The metadata contains:
- “lat”: a float between -90 to 90 that shows the latitude in which the image was taken
- “lon”: a float between -180 to 180 that shows the longitude in which the image was taken
- “epoch”: Linux epoch in second
- “orientation”: a float between -180 to 180 the east-ward orientation of car travel from true north. 0 means north. 90 is east and -90 is west
The API is built on Django and uses pysolar to determine the sun's altitude and azimuthal angle. The algorithm takes in the payload through a POST request and determines the possibility of glare based on the following conditions:
- Azimuthal difference between sun and the direction of the car travel (and hence the direction of forward- facing camera) is less than 30 degrees AND
- Altitude of the sun is less than 45 degrees.
The API expects the input to be in the following format and acceptable values for the fields:
{
“lat”: 49.2699648,
“lon”: -123.1290368,
“epoch”: 1588704959.321,
“orientation”: -10.2,
}
- “lat”: a float between -90 to 90
- “lon”: a float between -180 to 180
- “epoch”: Linux epoch in second
- “orientation”: a float between -180 to 180
{
"glare": true,
"status": 0,
"request_id": 23
}
- glare: True or False depending on the input values. If null there was a problem with payload.
- status:
0: ok
,1: Invalid lat
,2: Invalid lon
,3: Invalid orientation
. - request_id: Each request is saved in the default SQLlite database. This id represents the request number.
-
Go to the root directory of the unzipped folder.
-
From the root directory use the following command in CLI:
sudo docker-compose build
-
Once the above step has been processed use:
sudo docker-compose up
-
In your choice of browser go to the following address: http://0.0.0.0:8000/api/v1/sun_glare_algo/predict
-
Enter the JSON input data and click POST
The source code of the algorithm is present in backend/server/apps/sg/sun_glare_algo/sun_glare.py