├── Images ├── image1.jpg ├── image2.jpg ├── image3.jpg ├── image4.jpg ├── image5.jpg ├── image6.jpg ├── image7.jpg ├── image8.jpg └── image9.jpg ├── SMART PARKING SYSTEM ├── bg.jpg ├── car.jpg ├── parking.m └── parking.txt ├── LICENSE └── README.md /Images/image1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekapk/SMART-PARKING-SYSTEM/HEAD/Images/image1.jpg -------------------------------------------------------------------------------- /Images/image2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekapk/SMART-PARKING-SYSTEM/HEAD/Images/image2.jpg -------------------------------------------------------------------------------- /Images/image3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekapk/SMART-PARKING-SYSTEM/HEAD/Images/image3.jpg -------------------------------------------------------------------------------- /Images/image4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekapk/SMART-PARKING-SYSTEM/HEAD/Images/image4.jpg -------------------------------------------------------------------------------- /Images/image5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekapk/SMART-PARKING-SYSTEM/HEAD/Images/image5.jpg -------------------------------------------------------------------------------- /Images/image6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekapk/SMART-PARKING-SYSTEM/HEAD/Images/image6.jpg -------------------------------------------------------------------------------- /Images/image7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekapk/SMART-PARKING-SYSTEM/HEAD/Images/image7.jpg -------------------------------------------------------------------------------- /Images/image8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekapk/SMART-PARKING-SYSTEM/HEAD/Images/image8.jpg -------------------------------------------------------------------------------- /Images/image9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekapk/SMART-PARKING-SYSTEM/HEAD/Images/image9.jpg -------------------------------------------------------------------------------- /SMART PARKING SYSTEM/bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekapk/SMART-PARKING-SYSTEM/HEAD/SMART PARKING SYSTEM/bg.jpg -------------------------------------------------------------------------------- /SMART PARKING SYSTEM/car.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekapk/SMART-PARKING-SYSTEM/HEAD/SMART PARKING SYSTEM/car.jpg -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 ABHISHEK KUMAR GUPTA 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /SMART PARKING SYSTEM/parking.m: -------------------------------------------------------------------------------- 1 | %PROGRAM FOR SMART PARKING SYSYTEM 2 | %made by - 3 | %ABHISHEK KUMAR GUPTA ITGGV BILASPUR 4 | %SHIVANGI VARSHNEY JIIT NOIDA 5 | %SHREYA SINGH MMMUT GORAKHPUR 6 | % ASHISH SINGH AIT KANPUR 7 | 8 | image = imread('C:\Users\hp\Documents\MATLAB\car.jpg'); %To read Cars parked in parking area. 9 | background = imread('C:\Users\hp\Documents\MATLAB\bg.jpg'); %To read background image or initial image of parking area 10 | img = double(rgb2gray(image));%convert to gray 11 | bg = double(rgb2gray(background));%convert 2nd image to gray 12 | [height width] = size(img); %image size? 13 | %ITS WORK FOR WHOLE PARKING SYSTEM 14 | totalslot=36; %Given Total number of slot in the parking area. 15 | %Foreground Detection 16 | thresh=11; 17 | fr_diff = abs(img-bg); 18 | for j = 1:width 19 | for k = 1:height 20 | if (fr_diff(k,j)>thresh) 21 | fg(k,j) = img(k,j); 22 | else 23 | fg(k,j) = 0; 24 | end 25 | end 26 | end 27 | park=sprintf('(Orignal Frame) Parking Area with %d slot',totalslot); 28 | subplot(2,2,1) , imshow(image), title (park); 29 | subplot(2,2,2) , imshow(mat2gray(img)), title ('converted Frame'); 30 | subplot(2,2,3) , imshow(mat2gray(bg)), title ('BACKGND Frame '); 31 | 32 | sd=imadjust(fg);% adjust the image intensity values to the color map 33 | level=graythresh(sd); 34 | m=imnoise(sd,'gaussian',0,0.025);% apply Gaussian noise 35 | k=wiener2(m,[5,5]);%filtering using Weiner filter 36 | bw=im2bw(k,level); 37 | bw2=imfill(bw,'holes'); 38 | bw3 = bwareaopen(bw2,5000); 39 | labeled = bwlabel(bw3,8); 40 | %Blob measurements 41 | blobMeasurements = regionprops(labeled,'all'); 42 | numberofcars = size(blobMeasurements, 1); 43 | cars=sprintf('[FOREGROUND] , Total space available is %d',totalslot-numberofcars); 44 | subplot(2,2,4) , imagesc(labeled), title (cars); 45 | hold off; 46 | 47 | %CONDITION TO CHECK THE VACANT SPACE 48 | %IF YES then it divide it itno 6 parts as 6 LANEs are there then for each 49 | %lane image processing is applied as before and lane with vacant space 50 | %comes first with their space. 51 | %LANE number are like 52 | % LANE 1 LANE 2 53 | % LANE 3 LANE 4 54 | % LANE 5 LANE 6 55 | 56 | if((totalslot-numberofcars)>0); 57 | fprintf('You can enter into the parking area'); 58 | fprintf('\n Number of car present'); 59 | disp(numberofcars);% display number of cars 60 | fprintf('Number of vacant space present present'); 61 | disp(totalslot-numberofcars); 62 | fprintf('PARKING AREA STRUCTURE with LANE:- \n LANE 1\t\t LANE 2 '); 63 | fprintf('\n LANE 3\t\t LANE4 \n LANE 5\t\t LANE 6'); 64 | %These code just divide the image of full parking area into 6 parts as 3 65 | %rows and 2 coloums. 66 | r3=int32(height/3); 67 | c2=int32(width/2); 68 | img1=img(1:r3,1:c2); 69 | img2=img(1:r3,c2+1:end); 70 | img3=img(1+r3:2*r3,1:c2); 71 | img4=img(1+r3:2*r3,c2+1:end); 72 | img5=img(2*r3+1:end,1:c2); 73 | img6=img(2*r3+1:end,c2+1:end); 74 | imga={img1 img2 img3 img4 img5 img6}; %An Array iscreated which store 6 image. 75 | bg1=bg(1:r3,1:c2); 76 | bg2=bg(1:r3,c2+1:end); 77 | bg3=bg(1+r3:2*r3,1:c2); 78 | bg4=bg(1+r3:2*r3,c2+1:end); 79 | bg5=bg(2*r3+1:end,1:c2); 80 | bg6=bg(2*r3+1:end,c2+1:end); 81 | bga={bg1 bg2 bg3 bg4 bg5 bg6}; 82 | 83 | % LOOP is taken from LANE 6 to LANE 1 for better understandibilty. 84 | % And again previos process is taken for each lane for vacant space 85 | % detection. 86 | for a=6:-1:1 87 | totalslota=6; %Also all variables are changed by adding a as suffix. 88 | imgb=imga{a}; 89 | 90 | bgb=bga{a}; 91 | [heighta widtha] = size(imgb); 92 | thresha=11; 93 | fr_diffa = abs(imgb-bgb); 94 | for j = 1:widtha 95 | for k = 1:heighta 96 | if (fr_diffa(k,j)>thresha) 97 | fga(k,j) = imgb(k,j); 98 | else 99 | fga(k,j) = 0; 100 | end 101 | end 102 | end 103 | 104 | sda=imadjust(fga);% adjust the image intensity values to the color map 105 | levela=graythresh(sda); 106 | ma=imnoise(sda,'gaussian',0,0.025);% apply Gaussian noise 107 | ka=wiener2(ma,[5,5]);%filtering using Weiner filter 108 | bwa=im2bw(ka,level); 109 | bw2a=imfill(bwa,'holes'); 110 | bw3a = bwareaopen(bw2a,5000); 111 | labeleda = bwlabel(bw3a,8); 112 | 113 | blobMeasurementsa = regionprops(labeleda,'all'); 114 | numberofcarsa = size(blobMeasurementsa, 1); 115 | %If lane is available with vacant slot then this statement is true and car will get its direction. 116 | if((totalslota-numberofcarsa)>0) 117 | fprintf('\n \nGo to Lane %d',a); 118 | fprintf('\n Number of car present'); 119 | disp(numberofcarsa);% display number of cars 120 | fprintf('Number of vacant space present present'); 121 | disp(totalslota-numberofcarsa); 122 | figure, subplot(2,2,1), imshow(image), title('Whole parking area'); 123 | lane=sprintf('Lane %d is availabe with vacant slot',a); 124 | subplot(2,2,2) , imshow(mat2gray(imgb)), title (lane); 125 | subplot(2,2,3) , imshow(mat2gray(bgb)), title ('BACKGND Frame '); 126 | cars=sprintf('[FOREGROUND] , Total space available in lane %d is %d',a,totalslota-numberofcarsa); 127 | subplot(2,2,4) , imagesc(labeleda), title (cars); 128 | hold off; 129 | break; 130 | end 131 | 132 | end 133 | else 134 | fprintf('\n No space available in parking area.\n Exit'); 135 | % If whole parking area is full then this statement will execute. 136 | end 137 | 138 | 139 | 140 | -------------------------------------------------------------------------------- /SMART PARKING SYSTEM/parking.txt: -------------------------------------------------------------------------------- 1 | %PROGRAM FOR SMART PARKING SYSYTEM 2 | %made by - 3 | %ABHISHEK KUMAR GUPTA ITGGV BILASPUR 4 | %SHIVANGI VARSHNEY JIIT NOIDA 5 | %SHREYA SINGH MMMUT GORAKHPUR 6 | % ASHISH SINGH AIT KANPUR 7 | 8 | image = imread('C:\Users\hp\Documents\MATLAB\car.jpg'); %To read Cars parked in parking area. 9 | background = imread('C:\Users\hp\Documents\MATLAB\bg.jpg'); %To read background image or initial image of parking area 10 | img = double(rgb2gray(image));%convert to gray 11 | bg = double(rgb2gray(background));%convert 2nd image to gray 12 | [height width] = size(img); %image size? 13 | %ITS WORK FOR WHOLE PARKING SYSTEM 14 | totalslot=36; %Given Total number of slot in the parking area. 15 | %Foreground Detection 16 | thresh=11; 17 | fr_diff = abs(img-bg); 18 | for j = 1:width 19 | for k = 1:height 20 | if (fr_diff(k,j)>thresh) 21 | fg(k,j) = img(k,j); 22 | else 23 | fg(k,j) = 0; 24 | end 25 | end 26 | end 27 | park=sprintf('(Orignal Frame) Parking Area with %d slot',totalslot); 28 | subplot(2,2,1) , imshow(image), title (park); 29 | subplot(2,2,2) , imshow(mat2gray(img)), title ('converted Frame'); 30 | subplot(2,2,3) , imshow(mat2gray(bg)), title ('BACKGND Frame '); 31 | 32 | sd=imadjust(fg);% adjust the image intensity values to the color map 33 | level=graythresh(sd); 34 | m=imnoise(sd,'gaussian',0,0.025);% apply Gaussian noise 35 | k=wiener2(m,[5,5]);%filtering using Weiner filter 36 | bw=im2bw(k,level); 37 | bw2=imfill(bw,'holes'); 38 | bw3 = bwareaopen(bw2,5000); 39 | labeled = bwlabel(bw3,8); 40 | %Blob measurements 41 | blobMeasurements = regionprops(labeled,'all'); 42 | numberofcars = size(blobMeasurements, 1); 43 | cars=sprintf('[FOREGROUND] , Total space available is %d',totalslot-numberofcars); 44 | subplot(2,2,4) , imagesc(labeled), title (cars); 45 | hold off; 46 | 47 | %CONDITION TO CHECK THE VACANT SPACE 48 | %IF YES then it divide it itno 6 parts as 6 LANEs are there then for each 49 | %lane image processing is applied as before and lane with vacant space 50 | %comes first with their space. 51 | %LANE number are like 52 | % LANE 1 LANE 2 53 | % LANE 3 LANE 4 54 | % LANE 5 LANE 6 55 | 56 | if((totalslot-numberofcars)>0); 57 | fprintf('You can enter into the parking area'); 58 | fprintf('\n Number of car present'); 59 | disp(numberofcars);% display number of cars 60 | fprintf('Number of vacant space present present'); 61 | disp(totalslot-numberofcars); 62 | fprintf('PARKING AREA STRUCTURE with LANE:- \n LANE 1\t\t LANE 2 '); 63 | fprintf('\n LANE 3\t\t LANE4 \n LANE 5\t\t LANE 6'); 64 | %These code just divide the image of full parking area into 6 parts as 3 65 | %rows and 2 coloums. 66 | r3=int32(height/3); 67 | c2=int32(width/2); 68 | img1=img(1:r3,1:c2); 69 | img2=img(1:r3,c2+1:end); 70 | img3=img(1+r3:2*r3,1:c2); 71 | img4=img(1+r3:2*r3,c2+1:end); 72 | img5=img(2*r3+1:end,1:c2); 73 | img6=img(2*r3+1:end,c2+1:end); 74 | imga={img1 img2 img3 img4 img5 img6}; %An Array iscreated which store 6 image. 75 | bg1=bg(1:r3,1:c2); 76 | bg2=bg(1:r3,c2+1:end); 77 | bg3=bg(1+r3:2*r3,1:c2); 78 | bg4=bg(1+r3:2*r3,c2+1:end); 79 | bg5=bg(2*r3+1:end,1:c2); 80 | bg6=bg(2*r3+1:end,c2+1:end); 81 | bga={bg1 bg2 bg3 bg4 bg5 bg6}; 82 | 83 | % LOOP is taken from LANE 6 to LANE 1 for better understandibilty. 84 | % And again previos process is taken for each lane for vacant space 85 | % detection. 86 | for a=6:-1:1 87 | totalslota=6; %Also all variables are changed by adding a as suffix. 88 | imgb=imga{a}; 89 | 90 | bgb=bga{a}; 91 | [heighta widtha] = size(imgb); 92 | thresha=11; 93 | fr_diffa = abs(imgb-bgb); 94 | for j = 1:widtha 95 | for k = 1:heighta 96 | if (fr_diffa(k,j)>thresha) 97 | fga(k,j) = imgb(k,j); 98 | else 99 | fga(k,j) = 0; 100 | end 101 | end 102 | end 103 | 104 | sda=imadjust(fga);% adjust the image intensity values to the color map 105 | levela=graythresh(sda); 106 | ma=imnoise(sda,'gaussian',0,0.025);% apply Gaussian noise 107 | ka=wiener2(ma,[5,5]);%filtering using Weiner filter 108 | bwa=im2bw(ka,level); 109 | bw2a=imfill(bwa,'holes'); 110 | bw3a = bwareaopen(bw2a,5000); 111 | labeleda = bwlabel(bw3a,8); 112 | 113 | blobMeasurementsa = regionprops(labeleda,'all'); 114 | numberofcarsa = size(blobMeasurementsa, 1); 115 | %If lane is available with vacant slot then this statement is true and car will get its direction. 116 | if((totalslota-numberofcarsa)>0) 117 | fprintf('\n \nGo to Lane %d',a); 118 | fprintf('\n Number of car present'); 119 | disp(numberofcarsa);% display number of cars 120 | fprintf('Number of vacant space present present'); 121 | disp(totalslota-numberofcarsa); 122 | figure, subplot(2,2,1), imshow(image), title('Whole parking area'); 123 | lane=sprintf('Lane %d is availabe with vacant slot',a); 124 | subplot(2,2,2) , imshow(mat2gray(imgb)), title (lane); 125 | subplot(2,2,3) , imshow(mat2gray(bgb)), title ('BACKGND Frame '); 126 | cars=sprintf('[FOREGROUND] , Total space available in lane %d is %d',a,totalslota-numberofcarsa); 127 | subplot(2,2,4) , imagesc(labeleda), title (cars); 128 | hold off; 129 | break; 130 | end 131 | 132 | end 133 | else 134 | fprintf('\n No space available in parking area.\n Exit'); 135 | % If whole parking area is full then this statement will execute. 136 | end 137 | 138 | 139 | 140 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
4 |
5 |
6 |
Computerized systems being an integral part of the current era, an automated parking system is one of its most commonly used applications. The aim of this model is to build up and implement an automatic parking system that will detect the parking space with the help of image processing technique of the parking lot as well as reduce the human power. The smart parking system will able to have fewer interaction of humans. In additions to that, it has parking guidance system that can demonstrate and guide user towards a parking space. With the problems of ever increasing urban traffic congestion and the ever increasing shortage of space, the parking lots need to be well-equipped with parking space detection. The proposed system helps in counting the number of parked vehicles and, identifying the number of spots available. The system detects cars through images instead of electronic sensors embedded on the floors. A camera is installed at a high and fixed position in the parking lot. An image of empty parking lot is taken as reference and then image of parking lot with cars is taken. Both the images are subtracted to find the numbers of parking slots available.
10 |
11 |
Nowadays, car has become a necessity; it is no more a luxury especially for the working people. People even purchase car on installments. When talking about metropolitan, then traffic jams have become quite common recently during large number of vehicles. Also, we cannot deny the existence of the cars in our daily life. Whenever we go out by car, we face problems to find an available parking space. When driver enters a certain parking lot, the first thing that he does is to look for some sign which tells whether the parking lot is fully occupied, partly occupied or vacant. . He also does not know how many parking slots are there and where to find a parking division for his car. Some of the parking divisions may remain unoccupied even when the total occupancy is high. This causes ineffective use of parking divisions as well as traffics jams around the entrance of parking lot. Therefore, by offering drivers with relevant information about the parking lot while entering the parking lot becomes an important issue. When driver enters a certain parking lot, the driver takes a long time just to find an available parking space. Counting Available Parking Space using Image Processing helps to solve the problem that the driver faces at low cost. The system uses image processing to detect the existence of the car and also provides information such as number of available parking space. The system captures image using CCTV cameras and processes the image to count the available parking space. The system basically is implement to plan, analyze, design, development and testing. The development of this system will use techniques of image processing that will be implemented in each phase of the methodology. This system gives information about the number of available parking space. It will provide benefit to all the drivers when they enter the parking lot. The system uses image processing, since the whole area in the parking lot can be observed with relatively few cameras. Other than that, the system is compact and the cost is not high. The image of a parking lot is taken by a surveillance camera set at some height in the parking lot. MATLAB is used as software platform in this project. 14 |
15 |The main flow of the framework is shown in the Fig-1. Videos are acquired from the top view of the parking arena with the help of a fixed camera. Video is segmented into frames. Then from each segment a key frame is extracted and further processing is applied on this key frame, to reduce the computational complexity. 18 |
19 |
21 |
22 |
23 |
In the initial stage, an image is captured by steady CCTV camera at time of installation which is the background reference image. This reference image does not contain any cars. The main purpose is to identify the parking slots in the image. The camera which is used to take the images is fixed at a certain position and it faces a fixed direction all the time.
27 |
In this step, the picture of parking space containing cars is taken with the help of a high-definition camera.
31 | The image frame containing six lane image is divided lane-wise.
32 | The image data is then supplied to the MATLAB software for further processing.
33 |
The RGB image acquired is then converted to gray-scale image and then binary image is created in the Image segmentation module. The equation used for the conversion to gray-scale image is
37 | Gray= 0.229R+0.587G+0.11B
38 | The gray scale image of the parking space with cars. From the resulting gray-scale image, binary image is obtained using thresholding technique. The binary image contains all the information about the position and shape of interest. The threshold level is set in such a way that the objects of interest are made into white and the rest of the image black.
39 |
The binary image contains a lot of noise which is removed using morphological operations and filters such as the Weiner filter. The holes are removed with the help of imfill and bwareaopen function. 43 |
44 |
46 |
47 |
48 |
In order to detect the cars, blob analysis is done using predefined functions in MATLAB and the number of cars is counted. 52 |
53 |
55 |
56 |
57 |
The main steps of the proposed algorithm for parking space detection are:
61 |
73 |
74 |
75 |
There are many automated car parking systems already available using technologies such as GSM, wireless transmitter, etc. This project was especially chosen for the purpose of learning more about image processing, as it is one of the most relevant technologies of our times and used in numerous other applications. 79 | The parking space detection system based on image processing in MATLAB was designed and tested. It is possible to manage large area by just using several CCTV. It is consistent in detecting incoming cars because it uses actual car images. It is cheap and easy-installed because of the simple equipment. Drivers can get useful real-time parking lot information from this system by the guidance information display. Future researchers can focus on allocation specific location to customers already registered from online parking management system. 80 |
81 |Command window of MATLAB after the execution of code. 84 |
85 |
87 |
88 |
89 |
Two output figures are there after the execution of code.
92 | Figure 1 – Observation of the Whole parking area .
93 | Figure 2 – Observation of the each lane in parking area and the vacant lane is shown.
94 |
97 |
98 |
99 |
102 |
103 |
104 |