def get_camera_distancing_weekly_report( cameras: str = "", weeks: int = Query(0), from_date: date = Query((date.today() - timedelta(days=date.today().weekday(), weeks=4)).isoformat()), to_date: date = Query(date.today().isoformat())): """ Returns a weekly report (for the date range specified) with information about the social distancing infractions detected in the cameras <cameras>. **If `weeks` is provided and is a positive number:** - `from_date` and `to_date` are ignored. - Report spans from `weeks*7 + 1` days ago to yesterday. - Taking yesterday as the end of week. **Else:** - Report spans from `from_Date` to `to_date`. - Taking Sunday as the end of week """ cameras = get_cameras(cameras) for camera in cameras: validate_camera_existence(camera) if weeks > 0: # Report from weeks*7 days ago (grouped by week, ending on yesterday) return SocialDistancingMetric.get_weekly_report(cameras, number_of_weeks=weeks) else: # Report from the defined date_range, weeks ending on Sunday. validate_dates(from_date, to_date) return SocialDistancingMetric.get_weekly_report(cameras, from_date=from_date, to_date=to_date)
def get_camera_distancing_live(cameras: str = ""): """ Returns a report with live information about the social distancing infractions detected in the cameras <cameras>. """ cameras = get_cameras(cameras) for camera in cameras: validate_camera_existence(camera) return SocialDistancingMetric.get_live_report(cameras)
def get_camera_distancing_hourly_report(cameras: str = "", date: date = Query(date.today().isoformat())): """ Returns a hourly report (for the date specified) with information about the social distancing infractions detected in the cameras <cameras>. """ cameras = get_cameras(cameras) for camera in cameras: validate_camera_existence(camera) return SocialDistancingMetric.get_hourly_report(cameras, date)
def get_camera_face_mask_detections_live(areas: str = ""): """ Returns a report with live information about the social distancing infractions detected in the areas <areas>. """ areas = get_areas(areas) for area in areas: validate_area_existence(area) cameras = get_cameras_for_areas(areas) return SocialDistancingMetric.get_live_report(cameras)
def get_camera_distancing_daily_report(cameras: str = "", from_date: date = Query((date.today() - timedelta(days=3)).isoformat()), to_date: date = Query(date.today().isoformat())): """ Returns a daily report (for the date range specified) with information about the social distancing infractions detected in the cameras <cameras>. """ validate_dates(from_date, to_date) cameras = get_cameras(cameras) for camera in cameras: validate_camera_existence(camera) return SocialDistancingMetric.get_daily_report(cameras, from_date, to_date)