项目作者: visualbuffer

项目描述 :
Automated parking occupancy detection
高级语言: Python
项目地址: git://github.com/visualbuffer/parkingslot.git
创建时间: 2019-05-20T12:16:33Z
项目社区:https://github.com/visualbuffer/parkingslot

开源协议:

下载


PARKING SLOT DETECTION

Finding a vacant spot in a parking lot is a tough task. It is even more difficult to manage such facilities with varying levels of incoming traffic. Which slots are vacant at this instant? When do we need more slots? Are commuters finding it difficult to reach a particular slot?



We currently use either a network of ground mounted occupancy sensors or a large staff to determine some of the answers to these questions. Sensors are quite effective but need maintenance and cost about 40 -80$ per node in unit + installation. A staff only solution is cumbersome and error prone.



One approach to the problem can be using security camera footage to detect parking slot occupancy using deep learning. While there are limitations (clear visibility, trees, shade, lighting, etc.) the approach can be extended to some lots at very low cost.
This code tries to address some of these problems.


PARKING SLOT OCCUPANCY DETECTION


APPROACH TO DETECT OCCUPANCY

The problem can be broken into two parts, detecting where the parking slots are located, and detecting if a slot is occupied. We can manually mark the areas of the parking lots, but this is a cumbersome process, which must be repeated each time we change the camera’s position. A better approach is identifying the slots from the security cam footage itself. Subsequently, each of the identified slots can call a classifier to detect the presence / absence of a car.

MaskRCNN / YOLO provides us with the means to tackle the first problem while RESNET / VGG classifiers can help us detect occupancy.


PARKING SLOT DETECTION

DOWNLOAD THE DATA

DOWNLOAD THE IMAGES [CNRPARK Dataset]

We can use any video feed. For the purpose of demonstration feed from CNRPARK dataset (https://cnrpark.it) has been used. It has a total of 164 parking spaces captured by 9 camera feeds in different climatic conditions and lighting.

  1. # Whole field of view
  2. ! wget http://cnrpark.it/dataset/CNR-EXT_FULL_IMAGE_1000x750.tar
  3. ! tar -xvf CNR-EXT_FULL_IMAGE_1000x750.tar
  4. ! rm CNR-EXT_FULL_IMAGE_1000x750.tar
  5. # Cropped image paths of parking slots labelled as filled / empty
  6. ! wget http://cnrpark.it/dataset/CNR-EXT-Patches-150x150.zip
  7. ! unzip CNR-EXT-Patches-150x150.zip
  8. ! rm CNR-EXT-Patches-150x150.zip
  9. # VOC dataset for specializing yolo
  10. ! wget https://pjreddie.com/media/files/VOCtrainval_11-May-2012.tar
  11. ! wget https://pjreddie.com/media/files/VOCtrainval_06-Nov-2007.tar
  12. ! wget https://pjreddie.com/media/files/VOCtest_06-Nov-2007.tar
  13. ! tar xf VOCtrainval_11-May-2012.tar
  14. ! tar xf VOCtrainval_06-Nov-2007.tar
  15. ! tar xf VOCtest_06-Nov-2007.tar
  16. ! rm -rf VOCtrainval_11-May-2012.tar
  17. ! rm -rf VOCtrainval_06-Nov-2007.tar
  18. ! rm -rf VOCtest_06-Nov-2007.tar

DOWNLOAD PRETRAINED MODEL WEIGHTS

I have used both maskrcnn and yolo. Maskrcnn unsurprisingly detects finer objects in the corners while yolo misses out on a few slots even after it has been specialized to detect only car classes.

Detecting Parking Slots using MASKRCNN

  1. # YOLO
  2. wget https://pjreddie.com/media/files/yolov3.weights
  3. python ./convert.py ./yolov3.cfg yolov3.weights model_data/yolo.h5
  4. # MASKRCNN
  5. wget "https://github.com/matterport/Mask_RCNN/releases/download/v2.0/mask_rcnn_coco.h5"

Specialize YOLO to cars

  1. # Load Voc Data
  2. ! python voc_annotation.py
  3. # SPECIALIZE YOLO TO CARS
  4. ! python yolo_training.py

DETECTION

  1. ! python Parking_Slot_mask_rcnn.py
  2. ! python resnet_occupancy.py