app.ArgonPark package
Submodules
app.ArgonPark.argonPark module
- class app.ArgonPark.argonPark.parkingLot(parking_locations, path, img_scale=1)
Bases:
objectClass that loads a map and an AI model for a parking lot occupancy detection. Contains decision algorithms for parking Lot occupancy. Takes images as inputs and returns occupancy status with images.
- calculate_iou(idx, boxes, area_treshold=0.75)
Calculates the intersection over union of a box and a polygon.
- Args:
idx (rtree.index): Index of intersected boxes boxes (list): List of detection boxes
- evaulate_occupancy(img, overlap=0.8)
Evaluates the occupancy of the parking lot.
- Args:
img (np matrix): Image to evaluate overlap (float, optional): Overlap treshold for detection. Defaults to 0.75. debug (bool, optional): Saves image if True. Defaults to False.
- Returns:
int: Number of occupied parking spaces
- get_device() device
Gets device to be used for machine learning.
- Args:
debug (bool, optional): Prints selected device. Defaults to False.
- Returns:
torch.device: Device for torch to use
- load_model(path)
Loads a state dict onto a model.
- Args:
path (str): Path to the state dict
- make_pred(img, treshold=0.9)
Makes a prediction on a single image in a batch.
- Args:
model (torch): Model to inference with img_batch (torch.tensor): Image batch containing single image treshold (float, optional): Detection treshold, will throw warning if below. Defaults to 0.9.
- Returns:
pred_boxes: Two X and Y coordinates for the bounding box pred_score: Score of individual detections 0-1
- plot_to_image(debug=False)
Draws polygons over parking places according to the active mapping and occupancy. Args:
img (np matrix): A cv2 image to draw on. debug (bool, optional): If true, the function will save the image. Defaults to False.
- Returns:
image (np matrix): Image with colored polygons drawn over parking spaces.
- reload_JSON(path)
Reloads the JSON map file for the parking lot.
- Args:
path (str): Path to the JSON file
- resize_image(img)
Resizes an image to the desired size.
- Args:
img (np matrix): Image to resize
- Returns:
np matrix: Resized image
- show_inference(treshold=0.9, debug=False)
Shows the inference on an image, with marked parking slots. Goes through the whole inference process.
- Args:
img (np matrix) Image ready by cv2 treshold (float, optional): Treshold to flag as a detection. Defaults to 0.9. debug (bool, optional): When True saves image. Defaults to False.
- Returns:
np matrix: Image with detetions marked