Skip to content

Fix bug when overlaying contour detections on video, and improve tests/documentation#20

Merged
qian-chu merged 6 commits into
mainfrom
dev
Jun 22, 2026
Merged

Fix bug when overlaying contour detections on video, and improve tests/documentation#20
qian-chu merged 6 commits into
mainfrom
dev

Conversation

@qian-chu

Copy link
Copy Markdown
Collaborator

I encountered a bug when using video.overlay_detections to overlay a contour detecction:

File "...\pyneon\vis\video.py", line 97, in _overlay_marker_detections_on_frame
  label = str(int(detection["marker id"])) if show_ids else None

Apparently this is because there is no "marker id" in a contour detection (only "contour name").

Besides, the documentation for find_homographies is not rendering the docstring templates {marker_layout_table} and {homographies} because of the {} in the examples. This is fixed by escaping literal braces.

I also added pyneon.plot_marker_layout to the documentation.

qian-chu added 4 commits June 22, 2026 16:01
…mographies docstr

Add end-to-end mapping tests and related fixtures, plus small API/docs and implementation tweaks.

- Tests: add tests/test_mapping.py to exercise marker/contour detection, plotting, overlaying, homography computation, and applying homographies to gaze/fixations for both native and cloud sample datasets.
- Fixtures: add mapping_dataset_native and mapping_dataset_cloud fixtures in tests/conftest.py.
- API/impl: rename internal helper _overlay_marker_detections_on_frame -> _overlay_detections_on_frame and update label handling so IDs are only rendered when show_ids is True and a marker id is present; update caller site in overlay_detections.
- Docs: add pyneon.plot_marker_layout to reference docs and adjust homography docstring/example formatting (brace escaping/fixed indentation).

These changes add test coverage for the mapping workflow and make the detection overlay code more robust when marker IDs are absent.
Refactor homography computation to use vectorized arrays: remove per-row _reshape_corners, compute marker corner arrays from center/size via NumPy, build surface_pts_lookup with itertuples, and iterate detections using grouped DataFrame frames (handling MultiIndex). Also add explicit corner column extraction and validation. In visualization, make overlay functions robust to unreadable frames by substituting a gray frame (128) instead of raising errors. Misc: small pyproject formatting tweak, update surface_mapping notebook, and rename/update related tests.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a crash when overlaying contour detections on videos (contour detections don’t have a "marker id"), improves the find_homographies docstring rendering by escaping literal braces in examples, and expands mapping-related tests and docs.

Changes:

  • Make video detection overlay robust to contour detections lacking "marker id" (and add gray-frame fallbacks when frames can’t be read).
  • Improve find_homographies implementation (more vectorized) and docstring rendering.
  • Add mapping datasets fixtures + new mapping tests; update Sphinx reference docs to include mapping helpers.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pyneon/vis/video.py Fixes contour overlay crash; adds gray-frame fallback when frame reads fail.
pyneon/video/homography.py Escapes braces in docstring examples and refactors homography computation loop.
tests/test_video.py Updates expectations around unreadable frame 0 (warn + None).
tests/test_video_mapping.py Adds end-to-end tests for plotting/overlay + homography mapping for markers and contours.
tests/conftest.py Adds sample-data fixtures for mapping datasets (native/cloud).
source/reference/video.rst Updates reference page and documents plot_marker_layout.
.github/workflows/main.yml Changes CI trigger behavior for pushes (now only main).

Comment thread pyneon/vis/video.py Outdated
Comment thread pyneon/vis/video.py
Comment thread tests/test_video_mapping.py Outdated
Comment thread .github/workflows/main.yml
qian-chu and others added 2 commits June 22, 2026 18:25
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@qian-chu qian-chu merged commit 5921f85 into main Jun 22, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants