- Proceesing the image => Locate the parking lot.
- train the CNN model => use model to detect
-
Suppose we have an image of the parking lot that we can use to evaluate the accuracy of our parking lot detection algorithm.
- This data is a single frame extracted from the video captured by the camera.
-
As shown in the image, the parking space lines are marked in yellow. Therefore, we aim to preserve the yellow lines while converting all other colors to black and white. To achieve this, we will use white and yellow masks to filter out the background.
inspired by:
How to define a threshold value to detect only green colour objects in an image with Python OpenCV?
How to detect two different colors using
cv2.inRange
in Python-OpenCV?
We crop out any parts of the image that are not related to the actual parking lot. For more accurate and precise calculations and predictions down the line.
At this point we now will use hough line transform to find straight lines within our previously detected edges to find and locate likely spots for parking.
Here we pretty much use what we found from the last step to mark areas for parking blocks. This gives us a more focused area to specifically work on from this step forward.
Here we mark and identify the different parking spots found within the lot based on the width of the lines we previously found within the areas we defined. Here like many spots in the code we opted to visualize an output for testing purposes and to better explain the methods.
9. Crop spot images for CNN model (using code and data pre-processing steps before), and train the CNN model
We build on the top of VGG16 with some hyper-parameters:
batch_size = 32
epochs = 15
activation = softmax
optimizers.SGD(lr=0.0001, momentum=0.9)
The model training and testing loss:
10. After all our different methods being executed we finally get our final result which predicts and highlights all the available parking spots as well as the total amount of parking spots within the lot that the neural network found.
For every frame of the video, used for result testing.