Skip to content

Normalize OpenCV marker ID shapes in detect_markers and add matrix-safe pytest diagnostics artifacts - #23

Merged
qian-chu merged 3 commits into
mainfrom
copilot/fix-marker-id-normalization
Sep 18, 2026
Merged

qian-chu merged 3 commits into
mainfrom
copilot/fix-marker-id-normalization

Conversation

Copilot AI commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

cv2.aruco.ArucoDetector.detectMarkers() returns marker IDs as either (N,1) elements or scalar-like (N) elements depending on OpenCV/platform; detect_markers() assumed array indexing (marker_id[0]) and crashed on macOS with IndexError. This PR normalizes IDs at use-site and hardens CI output/reporting so matrix test failures are immediately diagnosable.

  • Marker ID Compatibility in detect_markers

    • Added _normalize_marker_id() to coerce detector outputs (7, np.array(7), np.array([7]), np.array([7])[0]-like) into a single int.
    • Replaced direct marker_id[0] usage with the normalized value for both:
      • "marker id"
      • "marker name" ({family}_{id})
  • Focused Regression Coverage

    • Added a dedicated test module for marker ID normalization behavior.
    • Covers scalar and one-element-array representations and asserts the emitted detection fields remain correct (marker id, marker name).
  • CI Diagnostics in .github/workflows/main.yml

    • Updated pytest invocation to include verbose test names and long tracebacks (-vv --tb=long).
    • Added JUnit XML output for every matrix run.
    • Added upload-artifact with if: always() so reports are preserved even on pytest failure.
    • Artifact names include OS/Python dimensions to avoid collisions.
    • Kept Windows MSMF override (OPENCV_VIDEOIO_PRIORITY_MSMF: "0") and used OS-appropriate shell commands for report directory setup.
def _normalize_marker_id(marker_id: int | np.ndarray) -> int:
    return int(np.asarray(marker_id).reshape(-1)[0])

# in detect loop
marker_id_int = _normalize_marker_id(marker_id)
record = {
    "marker id": marker_id_int,
    "marker name": f"{fam_name}_{marker_id_int}",
}

Copilot AI and others added 2 commits September 18, 2026 14:47
Co-authored-by: qian-chu <97355086+qian-chu@users.noreply.github.com>
Co-authored-by: qian-chu <97355086+qian-chu@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix marker ID normalization in detect_markers Normalize OpenCV marker ID shapes in detect_markers and add matrix-safe pytest diagnostics artifacts Sep 18, 2026
Copilot AI requested a review from qian-chu September 18, 2026 14:51
@qian-chu

Copy link
Copy Markdown
Collaborator

LGTM!

Disclosure of Delegation to Generative AI

The authors declare the use of generative AI in the research and writing process. According to the GAIDeT taxonomy (2025), the following tasks were delegated to GAI tools under full human supervision:

  • Code generation
  • Code optimization
  • Validation

The GAI tool used was: GPT-5.4.
Responsibility for the final manuscript lies entirely with the authors.
GAI tools are not listed as authors and do not bear responsibility for the final outcomes.
Declaration submitted by: Qian Chu

@qian-chu
qian-chu marked this pull request as ready for review September 18, 2026 15:34
@qian-chu
qian-chu merged commit 24e3c70 into main Sep 18, 2026
15 checks passed
@qian-chu
qian-chu deleted the copilot/fix-marker-id-normalization branch September 19, 2026 13:42
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