def post(self): data = request.get_json() url = data['url'] url_response = urllib.request.urlopen(url) img_array = np.array(bytearray(url_response.read()), dtype=np.uint8) img = cv2.imdecode(img_array, -1) v = detectSocialDistancing(img) geolocator = Nominatim(user_agent='https') print(v) if (v[0] / v[1]) * 100 > 30: st = str(data['latitude']) + ', ' + str(data['longitude']) queryObject = { 'latitude': data['latitude'], 'longitude': data['longitude'], 'datetime': datetime.now(), 'imageURL': data['url'], 'type': "Social Distancing Violation", 'address': geolocator.reverse(st).address } query = LocationTable.insert_one(queryObject) print(query) return { "msg": "Total people violating social distancing are : {}".format(v[0]) }
def post(self): data = request.get_json() url = data['url'] url_response = urllib.request.urlopen(url) img_array = np.array(bytearray(url_response.read()), dtype=np.uint8) img = cv2.imdecode(img_array, -1) v = detectSocialDistancing(img) print(v) if (v[0] / v[1]) * 100 > 30: queryObject = { 'latitude': data['latitude'], 'longitude': data['longitude'], 'datetime': datetime.now(), 'imageURL': data['url'], 'type': "Social Distancing Violation" } query = LocationTable.insert_one(queryObject) print(query) return {"msg": "Total people violating the rules are : {}".format(v[0])}