Parking Slot Detection Opencv
For parking spots detection we need an empty lot. Otherwise it will be nearly impossible to determine where are these spots exactly located, mainly if vehicles are not parking at their exact center. For movement detection, we need static camera feed, becouse of used MOG method, which constantly learns what is background and which object are moving. Methods in 26-34 detect parking slot markings in a full-automatic manner. 26 proposed a method that recognizes parking slot markings using a neural network-based color segmentation. 27 detected parking slots by finding parallel line pairs using a specialized filter and Hough transform. Detection of the parking slot and its occupancy in the parking area. This system consists of a sensor based networks and control system for the detection. The limit switches are used as the sensor networks. The limit switches are fixed on each parking area. 5) Monitor the state of a parking slot. The parking slot may be fully in use or free. This system seeks to constantly monitor what is happening in the slot to identify parking spaces that are available or occupied. 6) Collect the time and date of activities happening in a given parking slot. Every time the state of the parking slots.
Abstract:A small example of Opencv + tensorflow~
introduce
Automatic smart parking system is emerging field and attracted computer vision researchers to contribute in this arena of technology. In this paper, we have presented a vision based smart parking framework to assist the drivers in efficiently finding suitable parking slot and reserve it.
Do you often look around the parking lot to find parking spaces? If your cell phone can tell you exactly where the nearest parking space is, is it very cool? Facts have proved that it is relatively easy to solve this problem based on deep learning and OpenCV. The following GIF images highlight all available parking spaces on the parking lot and show the number of available parking spaces. The key is that the process is real-time.
You can find the code I used in Github repo.
Summary of steps
There are two main steps to build this parking detection model:
1. Check all available parking spaces;
2. Determine whether the parking space is empty or occupied;
Because the camera view is installed, we can use OpenCV to map each parking space once. Once you know the location of each parking space, you can use deep learning to predict whether it is empty or not. I have shared an overview of a high-level step involved on my blog. If you are interested in detailed code, please check out my blog.
Detection of all available parking spaces
The basic idea of parking space detection is that all parking points are divided by horizontal lines, and the spacing between parking points in a row is roughly equal. Firstly, Canny edge detection is used to obtain the edge image. I’ve covered up the area where I haven’t parked yet. As follows:
Then I did a transformation on the edge image and drew all the lines that it could recognize. I only choose lines with slopes close to zero to isolate horizontal lines. The output of the transformation is as follows:
As you can see, the Hof transform has done quite well in identifying parking lines, but the output is noisy – several stop lines have been detected many times, and some have been omitted. So how do we solve this problem? Then I start with observation and intuition, and use the coordinates returned by the transformation to gather the X coordinates to determine the main parking lane. Clustering logic is used to identify the interval of lane line x coordinates. So you can identify 12 lanes here. As follows:
If all this looks complicated, don’t worry about 5 — I’ve documented the code step by step on github’s jupyter notebook. Now that I know where all the parking lanes are, I can identify each individual parking space by reasonably assuming that all parking spaces are the same size. I observed the results carefully to ensure that the boundary between points was captured as accurately as possible. At last I was able to mark every parking space. As follows:
After locating each parking space, we can assign an ID to each point, save its coordinates in the dictionary and pick it up so that it can be retrieved later. This is possible because with the camera installed, we don’t need to calculate the position of each point in the view over and over again. For more details, please log on to my blog.
Identify whether the parking space is marked or not
Now that we have a map of each parking space, we can determine whether the parking space is occupied in the following ways:
1. Use OpenCV to check whether the pixel color of parking space in video image is the same as that of empty parking space. This is a simple method, but easy to make mistakes. For example, changes in lighting will change the color of an empty parking space, and this method will not work correctly in a day of light changes. If possible, this logic would treat gray cars as empty parking spaces.
2. Use target detection to identify all cars, and then check whether the car’s position overlaps with the parking space. I made an attempt to find that real-time detection model is really difficult to detect small objects, and the detected vehicles are not more than 30%.
3. Using CNN to detect each parking space and predict whether someone is parking, this method has the best effect.
To build a CNN, we need images of parking spaces with and without cars. I extracted the image of each parking space, saved it in the folder, and then grouped the images. I also shared this training folder on Github.
Because there are nearly 550 parking spaces in 1280×720 pixel images, the size of each parking space is only about 15×60 pixels. Below are the images of empty and occupied parking spaces:
However, because occupied parking spaces and empty parking spaces look very different, this should not be a challenging issue for CNN.
However, I only have about 550 pictures of these two classes, so I decided to use the first 10 layers of VGG and add a single soft Max layer to the output of the VGG model for migration learning. You can find the code of this migration learning model here, with an accuracy of 94%. See below:
Now, I combine parking detection with CNN predictor to construct a parking detector with high accuracy.
I also recorded the code running this on the video stream in notebook.
conclusion
I was amazed at how easy it was to combine different tools and use in-depth learning to build practical applications, and I finished this work in two afternoons.
Several other ideas for further exploration:
1. if it is possible to extend the parking detection logic to any parking map that may use deep learning, it is great that OpenCV restrictive use of each use case.
2. The VGG model used by CNN is a weighting model. We want to try a lighter model.
Cloud server 99 yuan group buying! Laxin can also win cash red envelope! Three million waiting for you to split up!
One Click to win the red envelope immediately: http://click.aliyun.com/m/1000019899/
Parking Slot Detection Opencv
Author: [Direction]Read the original text
Opencv Object Detection
This article is the original content of Yunqi Community, which can not be reproduced without permission.