Skip to content

Implemented a computer vision project which marks and saves Regions of Interest (ROIs) on live video feeds using pickle, NumPy, and OpenCV. Users can name countries, mark polygons interactively, and save regions for later use.

Notifications You must be signed in to change notification settings

hit1403/MapInteraction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mapinteractor: Interactive Mapping with Hand Gestures

Overview

Mapinteractor is a Python application that allows users to create interactive maps from a live webcam feed. You can define regions on a physical map or image, and then use hand gestures to identify and display information about those regions in real-time. The application uses Streamlit for the user interface and OpenCV for computer vision tasks.

Features

  • Map Calibration: Set four corner points on a webcam feed to create a top-down, warped perspective of your map or image.
  • Region Definition: Draw and save custom polygonal regions (e.g., countries, states) on the calibrated map.
  • Interactive Identification: Use your index finger to point at the defined regions on the map, and the application will highlight the region and display its name.
  • Web-Based UI: A simple and intuitive user interface built with Streamlit to control the different functionalities.

How It Works

The application is divided into three main parts:

  1. Set Corner Points: You first capture a reference frame from your webcam. By clicking on four points, you define the area that will be transformed into a flat, rectangular view. These points are saved for later use.
  2. Add Countries: On the warped map view, you can click to draw polygons around different regions of interest. You'll be prompted to enter a name for each region (e.g., "United States," "Brazil"). These polygons and their names are saved.
  3. Test Your Skills: The application uses hand tracking to find your index finger in the webcam feed. It then maps the position of your finger to the warped map. When your finger enters one of the saved polygons, the application highlights it and displays its name.

Setup and Installation

Prerequisites

  • Python 3.8+
  • A webcam

Dependencies

The project relies on the following Python libraries:

  • streamlit
  • opencv-python
  • cvzone
  • numpy
  • mediapipe

Installation

  1. Clone the repository:

    git clone <repository-url>
    cd Mapinteractor
  2. Create a virtual environment (recommended):

    python -m venv .venv
    source .venv/bin/activate  # On Windows, use `.venv\Scripts\activate`
  3. Install the required libraries:

    pip install streamlit opencv-python cvzone numpy mediapipe

Usage

To run the application, use the following command in your terminal:

streamlit run app.py

This will open a new tab in your web browser with the application's user interface. From the sidebar, you can choose one of the three operations: "Set corner Points," "Add countries," or "Test your world map skills."

Important Note: The current version of the scripts contains hardcoded absolute file paths. You will need to modify these paths in app.py, get_map.py, get_countries.py, and country_name.py to match the file locations on your system.

File Descriptions

  • app.py: The main Streamlit application that provides the user interface.
  • get_map.py: A script to capture the four corner points of the map and save them to map.p.
  • get_countries.py: A script to draw and save polygons for different countries or regions to countries.p.
  • country_name.py: The script for hand tracking and identifying the country being pointed at.
  • map.p: A pickle file that stores the coordinates of the map's corner points.
  • countries.p: A pickle file that stores the polygons and names of the defined countries.

About

Implemented a computer vision project which marks and saves Regions of Interest (ROIs) on live video feeds using pickle, NumPy, and OpenCV. Users can name countries, mark polygons interactively, and save regions for later use.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages