supervision icon indicating copy to clipboard operation
supervision copied to clipboard

[CropAnnotator] - mark objects with zoomed in crop

Open SkalskiP opened this issue 1 year ago • 10 comments

Description

Create CropAnnotator - whose task is to mark objects related to sv.Detections with zoomed-in crops.

Below is an example found on the internet. Of course, as part of this task, we would only add the part responsible for the crop.

Screenshot 2024-01-26 at 10 14 45

The API should also allow for the selection of the location of the enlarged crop using sv.Position (above, below, ...), as well as the choice of the zoom_factor.

API

class CropAnnotator(BaseAnnotator):

    def __init__(
        self,
        position: Position = Position.TOP_CENTER,
        zoom_factor: int = 2
    ):
        pass

    def annotate(
        self,
        scene: np.ndarray,
        detections: Detections,
    ) -> np.ndarray:
        pass

Additional

  • Note: Please share a Google Colab with minimal code to test the new feature. We know it's additional work, but it will definitely speed up the review process. Each change must be tested by the reviewer. Setting up a local environment to do this is time-consuming. Please ensure that Google Colab can be accessed without any issues (make it public). Thank you! 🙏🏻

SkalskiP avatar Jan 26 '24 09:01 SkalskiP

Hello there! I would love to be assigned and implement that!

A small correction at the description of the issue, the name of the annotator to be changed in CropAnnotator instead of IconAnnotator. :)

xaristeidou avatar Jan 29 '24 07:01 xaristeidou

@xaristeidou good luck and have fun :)

onuralpszr avatar Jan 29 '24 08:01 onuralpszr

The master of annotators is back in business 🔥! As for IconAnnotator, I copied part of the description from another issue. Sorry for that.

SkalskiP avatar Jan 29 '24 09:01 SkalskiP

Hi @xaristeidou 👋🏻 Did you manage to get started with this task?

SkalskiP avatar Feb 05 '24 17:02 SkalskiP

@SkalskiP In fact yes! I dealt with some bugs in the meanwhile, and now are fixed. I have a question to get some different opinions on implementation.

I have 2 different scenarios in mind. In cases where the cropped part of the image is going to exceed the scene dimensions based on the selected anchor Position:

  1. The cropped part will be placed exactly to the anchor position and the rest of the exceeding cropped part will not be displayed.
  2. The cropped part will be clipped to the edge of the scene, so the anchor position will be dynamically variable.

I would like to hear thoughts on that to continue further with a concept. Below I attach two examples for better representation. In both examples the anchor Position is assumed to be TOP_RIGHT

Scenario 1:

Screenshot 2024-02-05 175000

Scenario 2:

Screenshot 2024-02-05 175015

xaristeidou avatar Feb 05 '24 17:02 xaristeidou

Hi @xaristeidou 👋🏻 ! It's awesome to see the progress.

Let's go with scenario 1. It will be consistent with the behavior of other annotators.

SkalskiP avatar Feb 05 '24 20:02 SkalskiP

@SkalskiP Ok, when it is finished will get back with a PR.

xaristeidou avatar Feb 05 '24 21:02 xaristeidou

Hi @xaristeidou, 👋 supervision-0.19.0 release is getting closer and closer. I would love to include this feature in an upcoming release. Have you been able to move the work on this feature forward? Alternatively, could you open the PR in your current state so we can finish it for you?

SkalskiP avatar Feb 12 '24 18:02 SkalskiP

@SkalskiP Hello!! Sorry for the delay to submit!! Submitted #888 .

xaristeidou avatar Feb 12 '24 20:02 xaristeidou

Hi @xaristeidou 👋🏻 ! No worries!

SkalskiP avatar Feb 13 '24 09:02 SkalskiP

@SkalskiP Maybe we should close the issue due to PR #888 .

xaristeidou avatar Mar 25 '24 21:03 xaristeidou

Fixed via https://github.com/roboflow/supervision/pull/888

onuralpszr avatar Mar 25 '24 21:03 onuralpszr