Skip to content

prikshitgautam27/geometrical_detection_using_python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🧠 Shape Detection with OpenCV This project uses OpenCV to detect and label geometric shapes (like triangles, rectangles, squares, circles, etc.) in an image. It applies contour detection and polygon approximation to identify shapes based on the number of vertices.

📁 Project Structure geo_detection_using_python.py shapes.png README.md 🚀 How It Works Image Loading: Reads the input image ().

Preprocessing: Converts the image to grayscale and applies binary thresholding.

Contour Detection: Finds contours in the thresholded image.

Shape Approximation: Approximates each contour to a polygon.

Shape Classification: Labels shapes based on the number of vertices:

3 → Triangle

4 → Square or Rectangle (based on aspect ratio)

5 → Pentagon

10 → Star

🛠️ Requirements Python 3.x

OpenCV (cv2)

Install OpenCV using pip:

bash pip install opencv-python 📸 Input Image Place your input image (shapes.jpg) in the same directory as the script, or update the path in the code accordingly.

▶️ Usage Run the script using:

bash python geo_detection_using_python.py If the image is not found, you'll see a helpful error message. Make sure the path is correct!

🧪 Sample Output The script will open a window displaying the original image with detected shapes labeled. Each shape is outlined and tagged with its name.

🧯 Troubleshooting Image not loading? Check the file name and path. Use an absolute path if needed:

python img = cv2.imread(r'C:\path\to\your\image\shapes.jpg') Window not showing? Ensure you're not running in a headless environment (like some IDEs or remote terminals). Use a local Python interpreter.

📌 License This project is open-source and free to use for educational and personal purposes.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages