Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for rotating a rectangle feature #2132

Closed
patel-zeel opened this issue Sep 19, 2024 · 5 comments
Closed

Support for rotating a rectangle feature #2132

patel-zeel opened this issue Sep 19, 2024 · 5 comments
Labels
Feature Request New feature or request

Comments

@patel-zeel
Copy link

patel-zeel commented Sep 19, 2024

Description

Motivation

Oriented bounding box (OBB) detection applications are increasing, especially in communities working on aerial/satellite imagery. Top computer vision conferences such as CVPR and ICCV have numerous papers proposing new methods to detect OBBs every year. OpenMMLab has a library mmrotate just for OBB detection. Few paperswithcode threads track the state-of-the-art in OBB detection [thread1, thread2].

Proposals

  • P1: geemap drawing tools allow drawing a rectangle as well as a polygon. An OBB is something between the two. It needs 4 coordinates like a quadrilateral (Polygon) to represent itself correctly, but it has to be rectangular. Imagery labeling tools such as label-studio and Microsoft's satellite imagery labeling tool allow drawing a rectangle and then allow to rotate it. I think geemap has the necessary building blocks to make this happen and will immensely benefit the growing OBB community. Specifically, programmatic control of geemap makes it a very attractive tool for OBB labeling.
Screenshot 2024-09-19 at 9 08 47 PM
  • P2: If geemap allows loading existing Polygons, not as a layer but an editable feature, it can be very useful to adjust wrongly predicted bounding boxes. Changing the class value is currently possible in leafmap via a solution proposed here.
@patel-zeel patel-zeel added the Feature Request New feature or request label Sep 19, 2024
@giswqs
Copy link
Member

giswqs commented Sep 19, 2024

This is possible through the ipyleaflet Geoman Draw Control.
https://ipyleaflet.readthedocs.io/en/latest/controls/geoman_draw_control.html

import geemap
from ipyleaflet import Map, GeomanDrawControl

m = geemap.Map(center=(50, 354), zoom=5, draw_ctrl=False)

draw_control = GeomanDrawControl()
draw_control.polyline =  {
    "pathOptions": {
        "color": "#6bc2e5",
        "weight": 8,
        "opacity": 1.0
    }
}
draw_control.polygon = {
    "pathOptions": {
        "fillColor": "#6be5c3",
        "color": "#6be5c3",
        "fillOpacity": 1.0
    }
}
draw_control.circlemarker = {
    "pathOptions": {
        "fillColor": "#efed69",
        "color": "#efed69",
        "fillOpacity": 0.62
    }
}
draw_control.rectangle = {
    "pathOptions": {
        "fillColor": "#fca45d",
        "color": "#fca45d",
        "fillOpacity": 1.0
    }
}

m.add(draw_control)

m

Peek 2024-09-19 12-33

@patel-zeel
Copy link
Author

This is precisely what I thought with P1. Thank you, Prof. @giswqs! For P2, how to load previously saved features and edit their geometry?

@giswqs
Copy link
Member

giswqs commented Sep 19, 2024

I am not sure it if supports loading existing vector data. You need to study their source code to see if it is feasible.
https://www.geoman.io/docs/modes/draw-mode#customize-style
https://github.com/jupyter-widgets/ipyleaflet/blob/master/python/ipyleaflet/ipyleaflet/leaflet.py#L2294

@patel-zeel
Copy link
Author

Sure, Prof. @giswqs. I'll try to figure it out and if it works, will share here for everyone.

@giswqs giswqs closed this as completed Sep 20, 2024
@patel-zeel
Copy link
Author

Prof. @giswqs, how to access the rotated bounding box created by the Geoman Draw Control example shared above? I tried the following methods but they didn't work.

print(m.draw_control)
# None
print(m.draw_features)
# []

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants