Skip to content

Repository files navigation

# Parking Space Detection from a Single Image

This is a small computer vision project that aims to detect parking spaces and determine whether they are occupied or empty using a single image.
Unlike many industrial systems, where the parking area is first captured without any vehicles to create an ideal reference map, this project intentionally uses an image containing occupied parking spaces. This approach introduces several challenges, allowing different problems to be identified and corresponding solutions to be developed.

## Assumptions

In practical applications, surveillance cameras are usually installed at fixed locations. Therefore, the camera angle and perspective remain constant, making the geometric assumptions and calculations used in this project valid. If the camera position changes, the corresponding parameters and assumptions can be adjusted accordingly.

## Handling Illumination and Weather Variations

One possible concern is the effect of changing weather and lighting conditions. In a real-world system, this issue can be addressed by collecting multiple reference images of the parking area under different conditions (e.g., morning, afternoon, cloudy weather, rainy weather, etc.).
When a new image is acquired, it can be compared with all available reference images. The reference image with the smallest difference from the current scene can then be selected and used for parking space analysis. This approach increases the robustness of the system against environmental variations.

## Repository Contents

* **Jupyter Notebook** containing the complete step-by-step analysis.
* **Python utility functions** used throughout the project.
* Explanations of the challenges encountered and the solutions implemented.
* Visualization of intermediate results and final parking space detection.

## Notes

* The project assumes a fixed camera position.
* Thresholds and geometric parameters are image-dependent and may need adjustment for different camera setups.
* The proposed methodology can be extended to multiple reference images to improve robustness against illumination and weather changes.
* The main objective of this project is to explore common challenges in parking space detection and demonstrate practical solutions.

Challenges Encountered

Several issues were observed during the line detection stage:

  1. False Line Detection

    Some detected lines did not correspond to actual parking space boundaries. In particular, two lines on the right side of the image were incorrectly identified as parking lines.

  2. Detection of Unwanted Angled Lines

    The algorithm also detected lines that were neither horizontal nor vertical. Since parking space boundaries in the target image are expected to be aligned with the image axes, these lines should be discarded.

  3. Multiple Detections of the Same Line

    In several cases, a single parking line was represented by multiple overlapping detections, leading to redundant line segments.

    Proposed Solutions

    To address these issues, the following strategies were implemented:

  • Distance-Based Filtering

    The horizontal distance between adjacent parking lines is approximately 80 pixels. Therefore, a minimum distance threshold of 80 pixels was introduced to eliminate false detections and retain only valid parking space boundaries.

  • Angle-Based Filtering

    A function was defined to evaluate the orientation of each detected line. Lines whose angles deviated significantly from 0° or 90° were excluded, ensuring that only horizontal and vertical lines were considered.

  • Line Merging

    To remove duplicate detections, lines separated by less than 10 pixels were grouped together and replaced by their average position. This reduced overlapping detections and produced a cleaner representation of the parking space boundaries.

About

Computer vision project for parking space detection from a single image, including line detection, occupancy analysis, and practical solutions to challenges such as overlapping lines, angle filtering, and varying environmental conditions.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages