Skip to content

Latest commit

 

History

History
80 lines (58 loc) · 4.23 KB

README.md

File metadata and controls

80 lines (58 loc) · 4.23 KB

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+M: 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