COSC6373 HomeWork-3: Parking Lot Vacancy Detector Solved

45.00 $ 22.50 $

Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: . zip solution files instantly, after Payment


5/5 - (1 vote)

A public infrastructure has various parking lots. The parking lots get completely occupied very often and the public visiting the infrastructure spend too much time looking for a parking space, unaware that the parking lot is completely occupied. They would like to implement an automated solution to convey this information by displaying the number of available parking spaces at the entrance to the parking lot.



These parking lots are overlooked be surveillance cameras. The task is to leverage them to detect and count the empty parking spots.

Data set:

The data set consists of images from three separate parking lots parking1a, parking1b and parking2. Each of the parking has data set sorted for three different scenarios cloudy, rainy and sunny. Each single day is represented by the folder, for example the folder (e.g. PKLot/parking/cloudy/2012-12-12/) contains multiple snapshot images (like 2012_12_12_10_00_05.jpg) and the corresponding ground truth file (like 2012_12_12_10_00_05.xml).



Ground Truth(.xml)

Each image in the parking2 has 100 annotated parking spaces (see image below), along with the location, and occupancy information of the parking spot (Every image is supplemented with a ground truth file. For example (parking2/cloudy/2012-09-12/2012-09-12_06_05_16.jpg) has the ground truth file (parking2/cloudy/2012-09-12/2012-09-12_06_05_16.xml).


XML File description:

Space: each parking spot

Id: Space ID

Occupied: 0 – unoccupied, 1-occupied



Center: Of the rectangle

Size: of the rectangle

Angle: orientation of the rectangle Contour:

Points on the contour

Please note that OpenCV python does not have rotatedRect data structure. One would have to come up with your own logic to extract the bounding box.





Assignment steps:

  1. Create a training dataset
  2. Train a cascade classifier.
  3. Car Detection: Use the classifier to detect cars in a test image.
  4. Parking spot analysis application: Use the detected cars to decide if a parking spot is empty.

Cascade Classifier Training:

  1. Training set (3 Pts):
    1. Use Sunny scenario in each parking lot set to create your training set.
    2. Write a python program to extract training images using the XML file.
      1. Use any XML parser library to read the xml file and extract training images. Example below
  1. Train your cascade classifier (3 Pts)

(OpenCV           provides           utilities           to           train           cascade            classifier:

  1. Please provide examples of the sample dataset used for positives and negatives and report and justify the number of positive and negative samples used along with the no of stages used to train the cascade classifier and justify in the report.
  2. Use two sets of features to train your classifier
    1. HAAR – Haar-like features
    2. LBP – Local binary patterns
    3. Report performance of the classifier that is chosen 3. Car Detection (3 Pts):
  3. Use images from rainy and cloudy datasets to test your algorithm
  4. Write a python program that takes the cascade classifier parameters as input and a test image (from rainy and cloudy datasets) and performs car detection
  5. Test your detection using both sets of features, Haar and LBP 4. Parking lot analysis (3 Pts):
  6. Using the detected cars, and the location of the parking spots, determine, if a parking spot is occupied or empty.
  7. Use the ground truth to compare and summarize your results.
    1. Test 25 images each from rainy and cloudy (total 50 tests) dataset and report the true positives, false positive, accuracy.
    2. Some scenarios might have multiple cars but the parking spots might not be annotated, report your results only with respect to the annotated parking spaces and ignore the rest.
  • Populate the table below with your findings.








  Training TP FP Accuracy
Stages No.          of


No.            of



  1. Report (3 Pts):
  1. Document your findings in the report
  2. In each of the steps of training, testing, and performance analysis, please include in your report, with example images, a discussion of the following:
    1. what challenges or limitation do you see in each step and what could be done to improve the same
    2. compare/show or discuss expected difference(s) before and after the improvement action.



  1. Submit code on Github
  2. All coding must be done using python
  3. Use tools available in OpenCV.



  1. Dataset can be downloaded at: