Skip to content
This repository has been archived by the owner on Mar 19, 2023. It is now read-only.

Create class for ROI #184

Open
robmarkcole opened this issue Jan 10, 2021 · 2 comments
Open

Create class for ROI #184

robmarkcole opened this issue Jan 10, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@robmarkcole
Copy link
Owner

robmarkcole commented Jan 10, 2021

The ROI should be abstracted using a class. The class will implement a point_in_roi method that accepts a single x,y location and returns a boolean. We can keep a list of ROI on the image processing entity, then just iterate over them to filter each object. Pillow implements various shapes so stick to these:

Since we are always defining points as xy pairs, perhaps change the config to be a list of points like:

points:
  - x: 0
    y: 10
  - x: 20
    y: 30

The rectangle and circle are then just defined by two points, and a polygon by an arbitrary number of points.

Alternatively could adopt the approach of frigate, where a ROI (frigate calls them masks) is defined as a list of xy points, e.g.

- rectangle, 0,10,10,30
- poly, 0,10,10,30,40,50,50,60

This results in much more succinct config.
A nice compromise might be to combine approaches, so we have config like:

roi:
  - name: drive
     shape: rectangle
     points: 0,10,10,30

This allows validation of the number of points.

Note that shapely includes the required methods to implement point_in_roi but shapely itself has many C dependencies and we dont want to make this a new HA dependency

@robmarkcole
Copy link
Owner Author

This is only worth doing if we are going to add the polygon support, and since that is going to be quite complex to configure (probably requiring a dedicated tool to assist) need to think carefully about this

@robmarkcole
Copy link
Owner Author

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

No branches or pull requests

1 participant