Skip to content

[Bug]: ImportError get_zones_for_point missing in detection.py #81

@dyutishmaan-das

Description

@dyutishmaan-das

Affected Component

Detection (YOLOv8/v9 — services/detection/)

Bug Description

When running the detection demo via make demo or python services/detection/detection.py, the script crashes immediately with an ImportError.

It appears that the project recently migrated zone configurations from hardcoded Python objects to a YAML file, but the detection service was not fully updated to support this change.

Specifically, the following issues occur:

  1. detection.py tries to import get_zones_for_point from services.detection.zones, but this function no longer exists.
  2. detection.py assumes DEFAULT_ZONES is a list of objects with .name and .as_array() attributes, but zones.py now returns a list of dictionaries from the YAML config.

Error Log:

ImportError: cannot import name 'get_zones_for_point' from 'services.detection.zones' (C:\Users\...\Eagle\services\detection\zones.py)

### Steps to Reproduce

1. Clone the repository.
2. Run `make setup` to install all dependencies.
3. Run `make demo` (or execute `python services/detection/detection.py` directly).
4. Observe the `ImportError` crash immediately on startup.

### Expected Behavior

The detection demo should start successfully, open the video stream (webcam or sample video), and display the video feed with bounding boxes and polygon zone overlays without crashing.

### Actual Behavior

The script terminates immediately on startup with the following error:
`ImportError: cannot import name 'get_zones_for_point' from 'services.detection.zones'`

### Python Version

Other (specify in Additional Context)

### Operating System

Windows 11

### Inference Device

CPU

### Error Log / Traceback

```shell
Traceback (most recent call last):
  File "C:\Users\dyuti\Projects\Eagle\services\detection\detection.py", line 23, in <module>
    from services.detection.zones import DEFAULT_ZONES, get_zones_for_point
ImportError: cannot import name 'get_zones_for_point' from 'services.detection.zones' (C:\Users\dyuti\Projects\Eagle\services\detection\zones.py)

Screenshots or Recordings

No response

Additional Context

Note: I am running Python 3.10.0 on Windows (this version wasn't available in the dropdown). However, this is a structural ImportError due to a missing function from a recent refactor, so the issue is independent of the Python version or OS.

Checklist

  • I have searched existing issues and this is not a duplicate.
  • I have tested with the latest version of the main branch.

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions