Skip to content

Add PTZ calibration app and calibrated move parameters#335

Open
MateoLostanlen wants to merge 14 commits intodevelopfrom
calibrate_reolink_cam
Open

Add PTZ calibration app and calibrated move parameters#335
MateoLostanlen wants to merge 14 commits intodevelopfrom
calibrate_reolink_cam

Conversation

@MateoLostanlen
Copy link
Copy Markdown
Member

@MateoLostanlen MateoLostanlen commented Mar 31, 2026

Summary

  • Add tools/ptz_calibration_app.py — Streamlit app for calibrating PTZ motor speed tables with automated ORB keypoint matching
  • Recalibrate all speed/bias tables for both 823A16 and 823S2 (pan + tilt) using server-side timing
  • Add zoom-aware speed selection: use full speed table at zoom 0, speed 1 only when zoomed in
  • Add micro-pulse support: zoom to 41 then move+stop for precise small-angle nudges

Key changes

routes_control.py

  • Updated PAN_SPEEDS, PAN_BIAS, TILT_SPEEDS, TILT_BIAS for both camera models
  • _pick_speed() now accepts zoom param — restricts to speed 1 when zoom > 0
  • Extracted _execute_axis() helper in click_to_move (removes pan/tilt duplication)
  • Micro-pulse zooms to 41 before firing for consistent displacement (~1.6° pan, ~2.1° tilt on 823A16)
  • Skip threshold changed from hardcoded 0.5° to bias(speed1) / 2
  • Added /control/speed_tables endpoint for external tools
  • Server-side duration parameter: move+sleep+stop in single API call (no VPN latency)

tools/ptz_calibration_app.py

  • Automated calibration via ORB keypoint matching (2000 features, Lowe's ratio test)
  • Zoom sweep mode to measure speed vs zoom across multiple levels
  • Manual annotation fallback for micro-pulse at high zoom
  • Click-to-move accuracy test tab
  • Fetches speed tables from API to avoid duplication
  • Incremental JSON save during long sweeps

tools/ptz_zoom_speed_calibration_report.md — Research data showing Reolink internally caps PTZ speed when zoomed in

tools/README.md — Step-by-step calibration guide

Context

Previous speed tables were calibrated through VPN with separate move/stop API calls, adding 50-200ms uncontrolled latency to each measurement. Server-side timing eliminates
this. A zoom sweep revealed Reolink cameras limit motor speed at zoom > 0 (all speeds cap to ~1.5°/s), so higher speeds are only useful at zoom 0.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.59%. Comparing base (f8b6e05) to head (a07e09f).
⚠️ Report is 3 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #335      +/-   ##
===========================================
- Coverage    79.97%   72.59%   -7.39%     
===========================================
  Files            7        7              
  Lines          824      602     -222     
===========================================
- Hits           659      437     -222     
  Misses         165      165              
Flag Coverage Δ
unittests 72.59% <ø> (-7.39%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

When the target angle is below the calibrated bias at speed 1,
fire a 50ms impulse instead of skipping the move. Applies to both
/click_to_move and /move endpoints. Add micro-pulse calibration
section to the calibration app (zoom 41 default for precision).
Add duration parameter to /move endpoint so move+sleep+stop
happens on the Pi. Update calibration app to use single API
calls for all movements.
- update 823A16 and 823S2 pan/tilt speed and bias tables (zoom 0)
- add zoom-aware speed selection: speed 1 only when zoom > 0
- micro-pulse zooms to 41 for consistent small displacement
- add auto keypoint matching (ORB) for hands-free calibration
- add zoom sweep mode to measure speed vs zoom relationship
- add /control/speed_tables endpoint, calibration app fetches from API
- add calibration report and tools README
- fetch speed tables from /control/speed_tables endpoint (single source of truth)
- click-to-move: zoom-aware speed selection, micro-pulse support
- skip threshold based on bias/2 instead of hardcoded 0.5 deg
- zoom settle time scales with zoom delta
- update reference tables to match routes_control.py
- move route: add zoom param, force speed=1 when zoom>0 with warning
- click_to_move route: remove zoom manipulation in micro-impulse, add warning when zoom>0
- client: add click_to_move, get_speed_tables methods; add duration/zoom params to move_camera; log warnings when zoom>0
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.

1 participant