Code Monkey home page Code Monkey logo

easyroi's Introduction

stargazers issues forks license

Downloads PyPI version

Helper library for drawing ROI in Computer Vision Applications
Now you can crop the drawn roi's

demo

Table of Contents

About The Project

Tech Stack

File Structure

.  
├── EasyROI  
│   ├── __init__.py  
│   ├── easyROI.py  
│   └── utils.py  
├── input
│   ├── overpass.mp4   
├── output/  
├── dev_main.py             # Code for testing during developing phase
├── test_library.py         # Code for testing during testing phase
├── DEV_README.md           # README for developing phase 
├── LICENSE  
└── README.md 

Getting Started

Prerequisites

  • python>=3.6
  • pip

Installation

  1. Create virtual environment
python3 -m venv venv_easy_roi
source venv_easy_roi/bin/activate
  1. Install EasyROI
pip install EasyROI

If you already have opencv installed:

pip install --no-dependencies EasyROI

Usage

  • Read the instruction in terminal while drawing roi

Using EasyROI in your project

  • Initializing
from EasyROI import EasyROI

roi_helper = EasyROI(verbose=True)

Rectangular roi

rectangle_demo

rect_roi = roi_helper.draw_rectangle(frame, 3)  # quantity=3 specifies number of rectangles to draw

frame_temp = roi_helper.visualize_roi(frame, rect_roi)

Line Roi

line_demo

line_roi = roi_helper.draw_line(frame, 3)  # quantity=3 specifies number of lines to draw

frame_temp = roi_helper.visualize_roi(frame, line_roi)
  • See roi format in - Line

Circle Roi

circle_demo

circle_roi = roi_helper.draw_circle(frame, 3)   # quantity=3 specifies number of circles to draw

frame_temp = roi_helper.visualize_roi(frame, circle_roi)

Polygon Roi

polygon_demo

polygon_roi = roi_helper.draw_polygon(frame, 3) # quantity=3 specifies number of polygons to draw

frame_temp = roi_helper.visualize_roi(frame, polygon_roi)

Cropping drawn roi

polygon_roi = roi_helper.draw_polygon(frame, 3) # quantity=3 specifies number of polygons to draw

cropped_polys = roi_helper.crop_roi(frame, polygon_roi)
  • Can do similarly for rectangular, circle roi
  • Returns dictionary with key value same as roi_label and value as image of cropped version

Formats of roi

Rectangle

quantity = 1

{
    'roi': {   
                0: {'br_x': 573,
                    'br_y': 443,
                    'h'   : 105,
                    'tl_x': 322,
                    'tl_y': 338,
                    'w'   : 251
                }
            },

    'type': 'rectangle'
}

Line

quantity = 2

{
    'roi': {
                0: {
                    'point1': (374, 395), 
                    'point2': (554, 438)
                },

                1: {
                    'point1': (555, 438), 
                    'point2': (830, 361)
                }
            },

    'type': 'line'
}

Circle

quantity = 2

{
    'roi': {
                0: {
                    'center': (330, 355), 
                    'point2': (552, 375), 
                    'radius': 222
                },

                1: {
                    'center': (702, 374), 
                    'point2': (700, 475), 
                    'radius': 101
                }
            },

    'type': 'circle'
}

Polygon

quantity = 2

{
    'roi': {
                0: {
                    'vertices': [
                        (586, 435), 
                        (534, 582), 
                        (200, 504), 
                        (356, 403)
                    ]
                },
                
                1: {
                    'vertices': [
                        (1108, 507),
                        (738, 662),
                        (709, 497),
                        (711, 494),
                        (927, 414)
                    ]
                }
            },

    'type': 'polygon'
}

Future Work

  • See TODO.md for seeing developments of this project

Contributors

Acknowledgements and Resources

easyroi's People

Contributors

saharshleo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.