Code Monkey home page Code Monkey logo

roi_picker's Introduction

ROI Picker

ROI Picker is a simple tool to visualize region-of-interests (ROIs) and edit them. It is common for many computer vision tasks to define or select ROIs on an image. ROI picker can provide simple GUI to add, modify, and remove ROIs without complex packages or libraries. ROI Picker is written with Python and OpenCV, and it works with a single Python file, roi_picker.py.

ROI Picker now supports the following ROI shapes. Of course, users can extend more through class inheritance or modification.

  • A set of points
  • A set of line segments
  • A polygon

The above shapes are all represented as [(x1, y1), (x2, y2), ..., (xn, yn)].

How to Run ROI Picker

  • Prerequisite
    • If you don't install OpenCV, please install OpenCV: pip install opencv-python.
  • Command-line usage
    • python roi_picker.py image_file [-r roi_file.json] [-c config_file.json]
      • -r (or --roi_file): Specify a ROI file which contains ROI data (default: image_file.json)
      • -c (or --config_file): Specify a configuration file which can change visualization and GUI interface (default: roi_picker.json)
      • ๐Ÿ“ Note) If a default file does not exist, ROI Picker just starts with empty ROI or with its initial configuration.
  • Demo examples
    • python roi_picker.py demo/miraehall_satellite.png
      • Start ROI Picker with the default ROI file (demo/miraehall_satellite.json) and default configuration file (roi_picker.json)
    • python roi_picker.py demo/miraehall_220722.png -r demo/miraehall_camera.json
      • Start ROI Picker with the specific ROI file (demo/miraehall_image.json)
    • python roi_picker.py demo/miraehall_satellite.png -c demo/bold_style.json
      • Start ROI Picker with its default ROI file with specific configuration file (demo/bold_style.json)
      • ๐Ÿ“ Note) You can customize visualization and keyboard shortcuts by changing a configuration file. Please refer ROIPicker::get_default_config() in roi_picker.py file.
  • Extension examples

GUI Interface

๐Ÿ“ Note) ROI Picker provides minimal GUI without any menu or button for simplicity. Its GUI inputs are totally based on mouse and keyboard.

  • Mouse actions

    • Click: Select a ROI
      • If you click at an existing point, the ROI which contains the point is selected.
    • Double Click: Add or delete a point
      • If you double click at an existing point, the point will be removed.
      • If you double click on an existing line (for line segment or polygon), a new point will be inserted on the line.
      • If you double click on an image, a new point will be added.
    • Ctrl+Drag: Move the clicked point
  • Keyboard shortcuts

    • ESC: Terminate ROI Picker
    • Tab: Select the next ROI
    • Ctrl+P: Add a new set of points
    • Ctrl+L: Add a new set of line segment
    • Ctrl+G: Add a new polygon
    • Ctrl+R: Renew ROI Picker (Clear all ROIs)
    • Ctrl+D: Delete the selected ROI
    • Ctrl+I: Import ROI data from the ROI file
    • Ctrl+E: Export ROI data to the ROI file
    • Ctrl+F: Export configuration to a JSON file
    • Ctrl+Z: Show and hide the image zoom
    • Ctrl+T: Show and hide the status of the selected ROI
    • +: Zoom up the image
    • -: Zoom down the image

Screenshots

You can see the following demo if you run the above three usage examples, respectively.

๐Ÿ“ Note) Please remember that you can customize visualization and keyboard shortcuts when you apply your own configuration file (e.g. demo/bold_style.json). The following example is same data only with a different configuration file.

Authors

roi_picker's People

Contributors

ncquy avatar sunglok avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  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.