Skip to content

capture_calibration

capture_calibration

Calibration Frame Capture

Connects to the fisheye camera and shows a live preview. Press 'r' to start recording frames (1 per second), 'r' again to stop. Saved frames go to calibration_frames/ for use with calibrate_fisheye.py.

Controls

r Start / stop recording (1 frame per second) q / Esc Quit

Usage

python capture_calibration.py python capture_calibration.py --camera 0 --outdir my_cal_frames

open_camera

open_camera(camera_id)

Open the camera matching mqtt_bridge.py's setup.

Source code in calibration\capture_calibration.py
def open_camera(camera_id):
    """Open the camera matching mqtt_bridge.py's setup."""
    cap = None
    if sys.platform.startswith("linux"):
        cap = cv2.VideoCapture(camera_id, cv2.CAP_V4L2)
        if cap.isOpened():
            cap.set(cv2.CAP_PROP_FOURCC,
                    cv2.VideoWriter_fourcc('M', 'J', 'P', 'G'))
    if cap is None or not cap.isOpened():
        cap = cv2.VideoCapture(camera_id)

    if not cap.isOpened():
        print(f"Error: cannot open camera {camera_id}")
        sys.exit(1)

    cap.set(cv2.CAP_PROP_FRAME_WIDTH, 3840)
    cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 2160)

    w = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
    h = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
    print(f"Camera opened: {w}x{h}")
    return cap