bookmark/calibrate.py
pyr0ball c28afe0ac4 feat: add config loading, calibration script, and production entrypoint
Wires together AppConfig.load() (JSON config -> markers/guide_box),
calibrate.py (one-time empty-platform reference capture), and run.py
(build_strategy dispatch + camera/session/FastAPI wiring via uvicorn)
to complete Phase 1 intake station integration.
2026-07-13 11:08:48 -07:00

30 lines
867 B
Python

import sys
from pathlib import Path
import cv2
from bookmark.camera import CameraSource
def main() -> None:
device_index = int(sys.argv[1]) if len(sys.argv) > 1 else 0
output_path = Path(sys.argv[2]) if len(sys.argv) > 2 else Path("reference.jpg")
camera = CameraSource(device_index=device_index)
camera.open()
print("Clear the platform of any book, then press ENTER to capture the reference frame.")
input()
frame = camera.read_frame()
camera.close()
cv2.imwrite(str(output_path), frame)
print(f"Reference frame saved to {output_path}")
print(
"Next: open the reference image in an editor to note the pixel coordinates of "
"each size-boundary marker and the guide box, then fill them into config.json's "
"\"markers\" and \"guide_box\" fields."
)
if __name__ == "__main__":
main()