diff --git a/docker-compose.yaml b/docker-compose.yaml index 0d3eb4b..5c84fbe 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -17,7 +17,10 @@ name: approbotwebcam # Portainer: Stack → Web editor → dieses YAML → Deploy. # APP_PATH = /absoluter/pfad/zum/appRobotWebcam # -# Firewall: TCP 8444 (Viewer + Stream + API) +# Netz: hängt am externen Bridge-Netz "approbot_default" → vom HTTPS-Proxy im +# selben Netz erreichbar als http://AppRobotWebcam:8444 (oder webcam:8444). +# Firewall: TCP 8444 am Host nur für direkten LAN-Zugriff (ports:-Mapping). Läuft +# alles über den Proxy → ports:-Zeile raus, dann ist am Host nichts offen. # # Zugriff: # Viewer: http://:8444/ @@ -42,7 +45,14 @@ services: image: approbotwebcam:latest container_name: AppRobotWebcam restart: unless-stopped - network_mode: host + # Hängt am externen Netz approbot_default (statt host-Mode) → der HTTPS-Proxy im + # selben Netz erreicht den Container per Name (http://AppRobotWebcam:8444). + networks: + - approbot_default + # 8444 am Host veröffentlicht → direkter LAN-Zugriff (http://:8444) bleibt. + # Wenn ALLES über den Proxy läuft, diesen ports-Block entfernen → proxy-only. + ports: + - "8444:8444" command: sh -c "npm install --omit=dev && node server.js" volumes: - ${APP_PATH:-.}:/usr/src/app @@ -68,6 +78,14 @@ services: # - ON_DEMAND=true # Live nur bei Zuschauern (Default); 'false' = dauerhaft an # - IDLE_GRACE_MS=15000 # Karenz nach letztem Zuschauer vor dem Stop +# ── Netzwerk ──────────────────────────────────────────────────────────────────── +# Externes, bereits existierendes Bridge-Netz (vom Stack "approbot"). Wird hier nur +# referenziert, nicht erstellt. Prüfen: docker network inspect approbot_default +networks: + approbot_default: + external: true + name: approbot_default + # ── Hinweise ──────────────────────────────────────────────────────────────────── # • Neue oder geänderte Kamera: cameras.json anpassen + Redeploy (kein Code-Änderung). # by-id-Namen ermitteln: ls -la /dev/v4l/by-id/ diff --git a/test/files/20260606_140132_cam0_front.jpg b/test/files/20260606_140132_cam0_front.jpg deleted file mode 100644 index e995499..0000000 Binary files a/test/files/20260606_140132_cam0_front.jpg and /dev/null differ diff --git a/test/files/20260606_140335_cam0_front.jpg b/test/files/20260606_140335_cam0_front.jpg deleted file mode 100644 index 2c1f84d..0000000 Binary files a/test/files/20260606_140335_cam0_front.jpg and /dev/null differ diff --git a/test/files/20260606_140335_cam2_right.jpg b/test/files/20260606_140335_cam2_right.jpg deleted file mode 100644 index c6c4968..0000000 Binary files a/test/files/20260606_140335_cam2_right.jpg and /dev/null differ diff --git a/test/files/cam0/20260606_145135_cam0_front.jpg b/test/files/cam0/20260606_145135_cam0_front.jpg new file mode 100644 index 0000000..63d08ee Binary files /dev/null and b/test/files/cam0/20260606_145135_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_145223_cam0_front.jpg b/test/files/cam0/20260606_145223_cam0_front.jpg new file mode 100644 index 0000000..55074e0 Binary files /dev/null and b/test/files/cam0/20260606_145223_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_145249_cam0_front.jpg b/test/files/cam0/20260606_145249_cam0_front.jpg new file mode 100644 index 0000000..63c2158 Binary files /dev/null and b/test/files/cam0/20260606_145249_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_145310_cam0_front.jpg b/test/files/cam0/20260606_145310_cam0_front.jpg new file mode 100644 index 0000000..26dc939 Binary files /dev/null and b/test/files/cam0/20260606_145310_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_145331_cam0_front.jpg b/test/files/cam0/20260606_145331_cam0_front.jpg new file mode 100644 index 0000000..9f668d7 Binary files /dev/null and b/test/files/cam0/20260606_145331_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_145404_cam0_front.jpg b/test/files/cam0/20260606_145404_cam0_front.jpg new file mode 100644 index 0000000..4dc25ed Binary files /dev/null and b/test/files/cam0/20260606_145404_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_145415_cam0_front.jpg b/test/files/cam0/20260606_145415_cam0_front.jpg new file mode 100644 index 0000000..e30e4db Binary files /dev/null and b/test/files/cam0/20260606_145415_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_145444_cam0_front.jpg b/test/files/cam0/20260606_145444_cam0_front.jpg new file mode 100644 index 0000000..5a281c0 Binary files /dev/null and b/test/files/cam0/20260606_145444_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_145505_cam0_front.jpg b/test/files/cam0/20260606_145505_cam0_front.jpg new file mode 100644 index 0000000..184a313 Binary files /dev/null and b/test/files/cam0/20260606_145505_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_145528_cam0_front.jpg b/test/files/cam0/20260606_145528_cam0_front.jpg new file mode 100644 index 0000000..306b011 Binary files /dev/null and b/test/files/cam0/20260606_145528_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_145542_cam0_front.jpg b/test/files/cam0/20260606_145542_cam0_front.jpg new file mode 100644 index 0000000..f7b2338 Binary files /dev/null and b/test/files/cam0/20260606_145542_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_153744_cam0_front.jpg b/test/files/cam0/20260606_153744_cam0_front.jpg new file mode 100644 index 0000000..75fa745 Binary files /dev/null and b/test/files/cam0/20260606_153744_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_153808_cam0_front.jpg b/test/files/cam0/20260606_153808_cam0_front.jpg new file mode 100644 index 0000000..ad3772e Binary files /dev/null and b/test/files/cam0/20260606_153808_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_153845_cam0_front.jpg b/test/files/cam0/20260606_153845_cam0_front.jpg new file mode 100644 index 0000000..6bd4179 Binary files /dev/null and b/test/files/cam0/20260606_153845_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_153855_cam0_front.jpg b/test/files/cam0/20260606_153855_cam0_front.jpg new file mode 100644 index 0000000..3e6d770 Binary files /dev/null and b/test/files/cam0/20260606_153855_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_153918_cam0_front.jpg b/test/files/cam0/20260606_153918_cam0_front.jpg new file mode 100644 index 0000000..5655f90 Binary files /dev/null and b/test/files/cam0/20260606_153918_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_153928_cam0_front.jpg b/test/files/cam0/20260606_153928_cam0_front.jpg new file mode 100644 index 0000000..2d3afc6 Binary files /dev/null and b/test/files/cam0/20260606_153928_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_153949_cam0_front.jpg b/test/files/cam0/20260606_153949_cam0_front.jpg new file mode 100644 index 0000000..24294c7 Binary files /dev/null and b/test/files/cam0/20260606_153949_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_154021_cam0_front.jpg b/test/files/cam0/20260606_154021_cam0_front.jpg new file mode 100644 index 0000000..8201d4a Binary files /dev/null and b/test/files/cam0/20260606_154021_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_154050_cam0_front.jpg b/test/files/cam0/20260606_154050_cam0_front.jpg new file mode 100644 index 0000000..d498408 Binary files /dev/null and b/test/files/cam0/20260606_154050_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_154108_cam0_front.jpg b/test/files/cam0/20260606_154108_cam0_front.jpg new file mode 100644 index 0000000..f29101e Binary files /dev/null and b/test/files/cam0/20260606_154108_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_154127_cam0_front.jpg b/test/files/cam0/20260606_154127_cam0_front.jpg new file mode 100644 index 0000000..b589b40 Binary files /dev/null and b/test/files/cam0/20260606_154127_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_154150_cam0_front.jpg b/test/files/cam0/20260606_154150_cam0_front.jpg new file mode 100644 index 0000000..c467f29 Binary files /dev/null and b/test/files/cam0/20260606_154150_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_154220_cam0_front.jpg b/test/files/cam0/20260606_154220_cam0_front.jpg new file mode 100644 index 0000000..bf11270 Binary files /dev/null and b/test/files/cam0/20260606_154220_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_154237_cam0_front.jpg b/test/files/cam0/20260606_154237_cam0_front.jpg new file mode 100644 index 0000000..3ca6333 Binary files /dev/null and b/test/files/cam0/20260606_154237_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_154303_cam0_front.jpg b/test/files/cam0/20260606_154303_cam0_front.jpg new file mode 100644 index 0000000..4c93393 Binary files /dev/null and b/test/files/cam0/20260606_154303_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_160853_cam0_front.jpg b/test/files/cam0/20260606_160853_cam0_front.jpg new file mode 100644 index 0000000..6b53f61 Binary files /dev/null and b/test/files/cam0/20260606_160853_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_160926_cam0_front.jpg b/test/files/cam0/20260606_160926_cam0_front.jpg new file mode 100644 index 0000000..b3e9f63 Binary files /dev/null and b/test/files/cam0/20260606_160926_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_161001_cam0_front.jpg b/test/files/cam0/20260606_161001_cam0_front.jpg new file mode 100644 index 0000000..6d01587 Binary files /dev/null and b/test/files/cam0/20260606_161001_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_161026_cam0_front.jpg b/test/files/cam0/20260606_161026_cam0_front.jpg new file mode 100644 index 0000000..37396a9 Binary files /dev/null and b/test/files/cam0/20260606_161026_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_161052_cam0_front.jpg b/test/files/cam0/20260606_161052_cam0_front.jpg new file mode 100644 index 0000000..f5e06d1 Binary files /dev/null and b/test/files/cam0/20260606_161052_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_161119_cam0_front.jpg b/test/files/cam0/20260606_161119_cam0_front.jpg new file mode 100644 index 0000000..6fb4d47 Binary files /dev/null and b/test/files/cam0/20260606_161119_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_161144_cam0_front.jpg b/test/files/cam0/20260606_161144_cam0_front.jpg new file mode 100644 index 0000000..243927a Binary files /dev/null and b/test/files/cam0/20260606_161144_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_161207_cam0_front.jpg b/test/files/cam0/20260606_161207_cam0_front.jpg new file mode 100644 index 0000000..0f6f4bc Binary files /dev/null and b/test/files/cam0/20260606_161207_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_161237_cam0_front.jpg b/test/files/cam0/20260606_161237_cam0_front.jpg new file mode 100644 index 0000000..f88c98e Binary files /dev/null and b/test/files/cam0/20260606_161237_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_161259_cam0_front.jpg b/test/files/cam0/20260606_161259_cam0_front.jpg new file mode 100644 index 0000000..72c3362 Binary files /dev/null and b/test/files/cam0/20260606_161259_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_161325_cam0_front.jpg b/test/files/cam0/20260606_161325_cam0_front.jpg new file mode 100644 index 0000000..dc1f1fb Binary files /dev/null and b/test/files/cam0/20260606_161325_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_161352_cam0_front.jpg b/test/files/cam0/20260606_161352_cam0_front.jpg new file mode 100644 index 0000000..515a44d Binary files /dev/null and b/test/files/cam0/20260606_161352_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_161422_cam0_front.jpg b/test/files/cam0/20260606_161422_cam0_front.jpg new file mode 100644 index 0000000..75b28dd Binary files /dev/null and b/test/files/cam0/20260606_161422_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_161449_cam0_front.jpg b/test/files/cam0/20260606_161449_cam0_front.jpg new file mode 100644 index 0000000..0f38276 Binary files /dev/null and b/test/files/cam0/20260606_161449_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_161525_cam0_front.jpg b/test/files/cam0/20260606_161525_cam0_front.jpg new file mode 100644 index 0000000..02fb271 Binary files /dev/null and b/test/files/cam0/20260606_161525_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_161552_cam0_front.jpg b/test/files/cam0/20260606_161552_cam0_front.jpg new file mode 100644 index 0000000..1545118 Binary files /dev/null and b/test/files/cam0/20260606_161552_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_161627_cam0_front.jpg b/test/files/cam0/20260606_161627_cam0_front.jpg new file mode 100644 index 0000000..02331a6 Binary files /dev/null and b/test/files/cam0/20260606_161627_cam0_front.jpg differ diff --git a/test/files/cam0/20260606_161650_cam0_front.jpg b/test/files/cam0/20260606_161650_cam0_front.jpg new file mode 100644 index 0000000..5f1c7df Binary files /dev/null and b/test/files/cam0/20260606_161650_cam0_front.jpg differ diff --git a/test/files/cam0/calibration.npz b/test/files/cam0/calibration.npz new file mode 100644 index 0000000..f705b71 Binary files /dev/null and b/test/files/cam0/calibration.npz differ diff --git a/test/files/cam0/callibriate.py b/test/files/cam0/callibriate.py new file mode 100644 index 0000000..4d8439f --- /dev/null +++ b/test/files/cam0/callibriate.py @@ -0,0 +1,99 @@ + +import cv2 +import numpy as np +import glob + +# +# Create calibration .npz from checkerboard images +# + +# Parameters +CHECKERBOARD = (10, 7) # inner corners +square_size = 25.0 / 1000.0 # 25 mm -> meters + +# Prepare object points +objp = np.zeros((CHECKERBOARD[0] * CHECKERBOARD[1], 3), np.float32) +objp[:, :2] = np.mgrid[0:CHECKERBOARD[0], 0:CHECKERBOARD[1]].T.reshape(-1, 2) +objp *= square_size + +objpoints = [] # 3D points +imgpoints = [] # 2D points + +# Load images +images = glob.glob("*.jpg") +print("Found images:", len(images)) + +img_size = None + +for fname in images: + img = cv2.imread(fname) + + print(f"Processing {fname}...") + if img is None: + print(f"Warning: could not read {fname}") + continue + + gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) + + # Save image size once + if img_size is None: + img_size = gray.shape[::-1] + + print(f" Gray") + ret, corners = cv2.findChessboardCorners( + gray, + CHECKERBOARD, + flags=cv2.CALIB_CB_ADAPTIVE_THRESH + + cv2.CALIB_CB_NORMALIZE_IMAGE + + cv2.CALIB_CB_FAST_CHECK + ) + print(" Corners found") + + if ret: + corners2 = cv2.cornerSubPix( + gray, + corners, + (11, 11), + (-1, -1), + (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 1e-6) + ) + + objpoints.append(objp) + imgpoints.append(corners2) + + print(f"✅ Corners found in {fname}") + else: + print(f"❌ No corners found in {fname}") + +print(f"\nTotal valid images: {len(objpoints)} / {len(images)}" ) +# Sanity checks +if img_size is None: + raise RuntimeError("No images were successfully loaded.") + +if len(objpoints) == 0: + raise RuntimeError("No chessboard corners detected in any image. Calibration failed.") + +print("\n=== Sanity Checks Passed ===") +# Calibration +ret, K, D, rvecs, tvecs = cv2.calibrateCamera( + objpoints, + imgpoints, + img_size, + None, + None +) + + +print("\n=== Calibration Results ===") +print("RMS reprojection error:", ret) +print("Camera matrix:\n", K) +print("Distortion coefficients:\n", D) + +# Save calibration +np.savez( + "calibration.npz", + camera_matrix=K, + dist_coeffs=D +) + +print("\n✅ Calibration saved to calibration_XPro2_16mm.npz") diff --git a/test/files/20260606_140335_cam1_left.jpg b/test/files/cam1/20260606_140335_cam1_left.jpg similarity index 100% rename from test/files/20260606_140335_cam1_left.jpg rename to test/files/cam1/20260606_140335_cam1_left.jpg diff --git a/test/files/cam1/20260606_145135_cam1_left.jpg b/test/files/cam1/20260606_145135_cam1_left.jpg new file mode 100644 index 0000000..0012cb2 Binary files /dev/null and b/test/files/cam1/20260606_145135_cam1_left.jpg differ diff --git a/test/files/cam1/20260606_145404_cam1_left.jpg b/test/files/cam1/20260606_145404_cam1_left.jpg new file mode 100644 index 0000000..417f356 Binary files /dev/null and b/test/files/cam1/20260606_145404_cam1_left.jpg differ diff --git a/test/files/cam1/20260606_145528_cam1_left.jpg b/test/files/cam1/20260606_145528_cam1_left.jpg new file mode 100644 index 0000000..3ad098b Binary files /dev/null and b/test/files/cam1/20260606_145528_cam1_left.jpg differ diff --git a/test/files/cam1/20260606_145605_cam1_left.jpg b/test/files/cam1/20260606_145605_cam1_left.jpg new file mode 100644 index 0000000..a50e525 Binary files /dev/null and b/test/files/cam1/20260606_145605_cam1_left.jpg differ diff --git a/test/files/cam1/20260606_153744_cam1_left.jpg b/test/files/cam1/20260606_153744_cam1_left.jpg new file mode 100644 index 0000000..94dcfa6 Binary files /dev/null and b/test/files/cam1/20260606_153744_cam1_left.jpg differ diff --git a/test/files/cam1/20260606_153918_cam1_left.jpg b/test/files/cam1/20260606_153918_cam1_left.jpg new file mode 100644 index 0000000..58038d3 Binary files /dev/null and b/test/files/cam1/20260606_153918_cam1_left.jpg differ diff --git a/test/files/cam1/20260606_153949_cam1_left.jpg b/test/files/cam1/20260606_153949_cam1_left.jpg new file mode 100644 index 0000000..054f04b Binary files /dev/null and b/test/files/cam1/20260606_153949_cam1_left.jpg differ diff --git a/test/files/cam1/20260606_154050_cam1_left.jpg b/test/files/cam1/20260606_154050_cam1_left.jpg new file mode 100644 index 0000000..6d75f47 Binary files /dev/null and b/test/files/cam1/20260606_154050_cam1_left.jpg differ diff --git a/test/files/cam1/20260606_154127_cam1_left.jpg b/test/files/cam1/20260606_154127_cam1_left.jpg new file mode 100644 index 0000000..3abc12e Binary files /dev/null and b/test/files/cam1/20260606_154127_cam1_left.jpg differ diff --git a/test/files/cam1/20260606_154220_cam1_left.jpg b/test/files/cam1/20260606_154220_cam1_left.jpg new file mode 100644 index 0000000..bf339ba Binary files /dev/null and b/test/files/cam1/20260606_154220_cam1_left.jpg differ diff --git a/test/files/cam1/20260606_154303_cam1_left.jpg b/test/files/cam1/20260606_154303_cam1_left.jpg new file mode 100644 index 0000000..d1718c6 Binary files /dev/null and b/test/files/cam1/20260606_154303_cam1_left.jpg differ diff --git a/test/files/cam1/20260606_160853_cam1_left.jpg b/test/files/cam1/20260606_160853_cam1_left.jpg new file mode 100644 index 0000000..7bc86cc Binary files /dev/null and b/test/files/cam1/20260606_160853_cam1_left.jpg differ diff --git a/test/files/cam1/20260606_161001_cam1_left.jpg b/test/files/cam1/20260606_161001_cam1_left.jpg new file mode 100644 index 0000000..3dcff7e Binary files /dev/null and b/test/files/cam1/20260606_161001_cam1_left.jpg differ diff --git a/test/files/cam1/20260606_161052_cam1_left.jpg b/test/files/cam1/20260606_161052_cam1_left.jpg new file mode 100644 index 0000000..8cc3a6f Binary files /dev/null and b/test/files/cam1/20260606_161052_cam1_left.jpg differ diff --git a/test/files/cam1/20260606_161144_cam1_left.jpg b/test/files/cam1/20260606_161144_cam1_left.jpg new file mode 100644 index 0000000..0de964f Binary files /dev/null and b/test/files/cam1/20260606_161144_cam1_left.jpg differ diff --git a/test/files/cam1/20260606_161237_cam1_left.jpg b/test/files/cam1/20260606_161237_cam1_left.jpg new file mode 100644 index 0000000..24c3c25 Binary files /dev/null and b/test/files/cam1/20260606_161237_cam1_left.jpg differ diff --git a/test/files/cam1/20260606_161325_cam1_left.jpg b/test/files/cam1/20260606_161325_cam1_left.jpg new file mode 100644 index 0000000..350c318 Binary files /dev/null and b/test/files/cam1/20260606_161325_cam1_left.jpg differ diff --git a/test/files/cam1/20260606_161422_cam1_left.jpg b/test/files/cam1/20260606_161422_cam1_left.jpg new file mode 100644 index 0000000..6a5b9ce Binary files /dev/null and b/test/files/cam1/20260606_161422_cam1_left.jpg differ diff --git a/test/files/cam1/20260606_161525_cam1_left.jpg b/test/files/cam1/20260606_161525_cam1_left.jpg new file mode 100644 index 0000000..753ceab Binary files /dev/null and b/test/files/cam1/20260606_161525_cam1_left.jpg differ diff --git a/test/files/cam1/20260606_161627_cam1_left.jpg b/test/files/cam1/20260606_161627_cam1_left.jpg new file mode 100644 index 0000000..c768f58 Binary files /dev/null and b/test/files/cam1/20260606_161627_cam1_left.jpg differ diff --git a/test/files/cam1/calibration.npz b/test/files/cam1/calibration.npz new file mode 100644 index 0000000..2887aa7 Binary files /dev/null and b/test/files/cam1/calibration.npz differ diff --git a/test/files/cam1/callibriate.py b/test/files/cam1/callibriate.py new file mode 100644 index 0000000..4d8439f --- /dev/null +++ b/test/files/cam1/callibriate.py @@ -0,0 +1,99 @@ + +import cv2 +import numpy as np +import glob + +# +# Create calibration .npz from checkerboard images +# + +# Parameters +CHECKERBOARD = (10, 7) # inner corners +square_size = 25.0 / 1000.0 # 25 mm -> meters + +# Prepare object points +objp = np.zeros((CHECKERBOARD[0] * CHECKERBOARD[1], 3), np.float32) +objp[:, :2] = np.mgrid[0:CHECKERBOARD[0], 0:CHECKERBOARD[1]].T.reshape(-1, 2) +objp *= square_size + +objpoints = [] # 3D points +imgpoints = [] # 2D points + +# Load images +images = glob.glob("*.jpg") +print("Found images:", len(images)) + +img_size = None + +for fname in images: + img = cv2.imread(fname) + + print(f"Processing {fname}...") + if img is None: + print(f"Warning: could not read {fname}") + continue + + gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) + + # Save image size once + if img_size is None: + img_size = gray.shape[::-1] + + print(f" Gray") + ret, corners = cv2.findChessboardCorners( + gray, + CHECKERBOARD, + flags=cv2.CALIB_CB_ADAPTIVE_THRESH + + cv2.CALIB_CB_NORMALIZE_IMAGE + + cv2.CALIB_CB_FAST_CHECK + ) + print(" Corners found") + + if ret: + corners2 = cv2.cornerSubPix( + gray, + corners, + (11, 11), + (-1, -1), + (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 1e-6) + ) + + objpoints.append(objp) + imgpoints.append(corners2) + + print(f"✅ Corners found in {fname}") + else: + print(f"❌ No corners found in {fname}") + +print(f"\nTotal valid images: {len(objpoints)} / {len(images)}" ) +# Sanity checks +if img_size is None: + raise RuntimeError("No images were successfully loaded.") + +if len(objpoints) == 0: + raise RuntimeError("No chessboard corners detected in any image. Calibration failed.") + +print("\n=== Sanity Checks Passed ===") +# Calibration +ret, K, D, rvecs, tvecs = cv2.calibrateCamera( + objpoints, + imgpoints, + img_size, + None, + None +) + + +print("\n=== Calibration Results ===") +print("RMS reprojection error:", ret) +print("Camera matrix:\n", K) +print("Distortion coefficients:\n", D) + +# Save calibration +np.savez( + "calibration.npz", + camera_matrix=K, + dist_coeffs=D +) + +print("\n✅ Calibration saved to calibration_XPro2_16mm.npz") diff --git a/test/files/cam2/20260606_145014_cam2_right.jpg b/test/files/cam2/20260606_145014_cam2_right.jpg new file mode 100644 index 0000000..e38484c Binary files /dev/null and b/test/files/cam2/20260606_145014_cam2_right.jpg differ diff --git a/test/files/cam2/20260606_145223_cam2_right.jpg b/test/files/cam2/20260606_145223_cam2_right.jpg new file mode 100644 index 0000000..9ca7c7b Binary files /dev/null and b/test/files/cam2/20260606_145223_cam2_right.jpg differ diff --git a/test/files/cam2/20260606_145249_cam2_right.jpg b/test/files/cam2/20260606_145249_cam2_right.jpg new file mode 100644 index 0000000..86d950c Binary files /dev/null and b/test/files/cam2/20260606_145249_cam2_right.jpg differ diff --git a/test/files/cam2/20260606_145310_cam2_right.jpg b/test/files/cam2/20260606_145310_cam2_right.jpg new file mode 100644 index 0000000..4abc65f Binary files /dev/null and b/test/files/cam2/20260606_145310_cam2_right.jpg differ diff --git a/test/files/cam2/20260606_145331_cam2_right.jpg b/test/files/cam2/20260606_145331_cam2_right.jpg new file mode 100644 index 0000000..b4c259f Binary files /dev/null and b/test/files/cam2/20260606_145331_cam2_right.jpg differ diff --git a/test/files/cam2/20260606_145404_cam2_right.jpg b/test/files/cam2/20260606_145404_cam2_right.jpg new file mode 100644 index 0000000..09900f8 Binary files /dev/null and b/test/files/cam2/20260606_145404_cam2_right.jpg differ diff --git a/test/files/cam2/20260606_145415_cam2_right.jpg b/test/files/cam2/20260606_145415_cam2_right.jpg new file mode 100644 index 0000000..6c0cc7d Binary files /dev/null and b/test/files/cam2/20260606_145415_cam2_right.jpg differ diff --git a/test/files/cam2/20260606_145444_cam2_right.jpg b/test/files/cam2/20260606_145444_cam2_right.jpg new file mode 100644 index 0000000..58e7ab0 Binary files /dev/null and b/test/files/cam2/20260606_145444_cam2_right.jpg differ diff --git a/test/files/cam2/20260606_145528_cam2_right.jpg b/test/files/cam2/20260606_145528_cam2_right.jpg new file mode 100644 index 0000000..4c68175 Binary files /dev/null and b/test/files/cam2/20260606_145528_cam2_right.jpg differ diff --git a/test/files/cam2/20260606_145542_cam2_right.jpg b/test/files/cam2/20260606_145542_cam2_right.jpg new file mode 100644 index 0000000..ab67dc5 Binary files /dev/null and b/test/files/cam2/20260606_145542_cam2_right.jpg differ diff --git a/test/files/cam2/20260606_145605_cam2_right.jpg b/test/files/cam2/20260606_145605_cam2_right.jpg new file mode 100644 index 0000000..2e9bb9c Binary files /dev/null and b/test/files/cam2/20260606_145605_cam2_right.jpg differ diff --git a/test/files/cam2/20260606_153702_cam2_right.jpg b/test/files/cam2/20260606_153702_cam2_right.jpg new file mode 100644 index 0000000..ff0417e Binary files /dev/null and b/test/files/cam2/20260606_153702_cam2_right.jpg differ diff --git a/test/files/cam2/20260606_153744_cam2_right.jpg b/test/files/cam2/20260606_153744_cam2_right.jpg new file mode 100644 index 0000000..9f5cf11 Binary files /dev/null and b/test/files/cam2/20260606_153744_cam2_right.jpg differ diff --git a/test/files/cam2/20260606_153808_cam2_right.jpg b/test/files/cam2/20260606_153808_cam2_right.jpg new file mode 100644 index 0000000..0945651 Binary files /dev/null and b/test/files/cam2/20260606_153808_cam2_right.jpg differ diff --git a/test/files/cam2/20260606_153845_cam2_right.jpg b/test/files/cam2/20260606_153845_cam2_right.jpg new file mode 100644 index 0000000..37824f3 Binary files /dev/null and b/test/files/cam2/20260606_153845_cam2_right.jpg differ diff --git a/test/files/cam2/20260606_153855_cam2_right.jpg b/test/files/cam2/20260606_153855_cam2_right.jpg new file mode 100644 index 0000000..66c4f7f Binary files /dev/null and b/test/files/cam2/20260606_153855_cam2_right.jpg differ diff --git a/test/files/cam2/20260606_153918_cam2_right.jpg b/test/files/cam2/20260606_153918_cam2_right.jpg new file mode 100644 index 0000000..c608e12 Binary files /dev/null and b/test/files/cam2/20260606_153918_cam2_right.jpg differ diff --git a/test/files/cam2/20260606_153928_cam2_right.jpg b/test/files/cam2/20260606_153928_cam2_right.jpg new file mode 100644 index 0000000..52663ef Binary files /dev/null and b/test/files/cam2/20260606_153928_cam2_right.jpg differ diff --git a/test/files/cam2/20260606_153949_cam2_right.jpg b/test/files/cam2/20260606_153949_cam2_right.jpg new file mode 100644 index 0000000..db19e39 Binary files /dev/null and b/test/files/cam2/20260606_153949_cam2_right.jpg differ diff --git a/test/files/cam2/20260606_154021_cam2_right.jpg b/test/files/cam2/20260606_154021_cam2_right.jpg new file mode 100644 index 0000000..30971b4 Binary files /dev/null and b/test/files/cam2/20260606_154021_cam2_right.jpg differ diff --git a/test/files/cam2/20260606_154050_cam2_right.jpg b/test/files/cam2/20260606_154050_cam2_right.jpg new file mode 100644 index 0000000..7435159 Binary files /dev/null and b/test/files/cam2/20260606_154050_cam2_right.jpg differ diff --git a/test/files/cam2/20260606_154108_cam2_right.jpg b/test/files/cam2/20260606_154108_cam2_right.jpg new file mode 100644 index 0000000..bfeda31 Binary files /dev/null and b/test/files/cam2/20260606_154108_cam2_right.jpg differ diff --git a/test/files/cam2/20260606_154127_cam2_right.jpg b/test/files/cam2/20260606_154127_cam2_right.jpg new file mode 100644 index 0000000..7e0e989 Binary files /dev/null and b/test/files/cam2/20260606_154127_cam2_right.jpg differ diff --git a/test/files/cam2/20260606_160853_cam2_right.jpg b/test/files/cam2/20260606_160853_cam2_right.jpg new file mode 100644 index 0000000..7bec6c4 Binary files /dev/null and b/test/files/cam2/20260606_160853_cam2_right.jpg differ diff --git a/test/files/cam2/20260606_160926_cam2_right.jpg b/test/files/cam2/20260606_160926_cam2_right.jpg new file mode 100644 index 0000000..efbc68b Binary files /dev/null and b/test/files/cam2/20260606_160926_cam2_right.jpg differ diff --git a/test/files/cam2/20260606_161001_cam2_right.jpg b/test/files/cam2/20260606_161001_cam2_right.jpg new file mode 100644 index 0000000..85a2880 Binary files /dev/null and b/test/files/cam2/20260606_161001_cam2_right.jpg differ diff --git a/test/files/cam2/20260606_161052_cam2_right.jpg b/test/files/cam2/20260606_161052_cam2_right.jpg new file mode 100644 index 0000000..d56e035 Binary files /dev/null and b/test/files/cam2/20260606_161052_cam2_right.jpg differ diff --git a/test/files/cam2/20260606_161119_cam2_right.jpg b/test/files/cam2/20260606_161119_cam2_right.jpg new file mode 100644 index 0000000..59e0af9 Binary files /dev/null and b/test/files/cam2/20260606_161119_cam2_right.jpg differ diff --git a/test/files/cam2/20260606_161144_cam2_right.jpg b/test/files/cam2/20260606_161144_cam2_right.jpg new file mode 100644 index 0000000..0d2e530 Binary files /dev/null and b/test/files/cam2/20260606_161144_cam2_right.jpg differ diff --git a/test/files/cam2/20260606_161207_cam2_right.jpg b/test/files/cam2/20260606_161207_cam2_right.jpg new file mode 100644 index 0000000..80757fe Binary files /dev/null and b/test/files/cam2/20260606_161207_cam2_right.jpg differ diff --git a/test/files/cam2/20260606_161237_cam2_right.jpg b/test/files/cam2/20260606_161237_cam2_right.jpg new file mode 100644 index 0000000..2b3a953 Binary files /dev/null and b/test/files/cam2/20260606_161237_cam2_right.jpg differ diff --git a/test/files/cam2/20260606_161259_cam2_right.jpg b/test/files/cam2/20260606_161259_cam2_right.jpg new file mode 100644 index 0000000..f58c673 Binary files /dev/null and b/test/files/cam2/20260606_161259_cam2_right.jpg differ diff --git a/test/files/cam2/20260606_161325_cam2_right.jpg b/test/files/cam2/20260606_161325_cam2_right.jpg new file mode 100644 index 0000000..77b4a1e Binary files /dev/null and b/test/files/cam2/20260606_161325_cam2_right.jpg differ diff --git a/test/files/cam2/20260606_161352_cam2_right.jpg b/test/files/cam2/20260606_161352_cam2_right.jpg new file mode 100644 index 0000000..9b61bf2 Binary files /dev/null and b/test/files/cam2/20260606_161352_cam2_right.jpg differ diff --git a/test/files/cam2/20260606_161422_cam2_right.jpg b/test/files/cam2/20260606_161422_cam2_right.jpg new file mode 100644 index 0000000..fde6ce7 Binary files /dev/null and b/test/files/cam2/20260606_161422_cam2_right.jpg differ diff --git a/test/files/cam2/20260606_161449_cam2_right.jpg b/test/files/cam2/20260606_161449_cam2_right.jpg new file mode 100644 index 0000000..be6f806 Binary files /dev/null and b/test/files/cam2/20260606_161449_cam2_right.jpg differ diff --git a/test/files/cam2/20260606_161525_cam2_right.jpg b/test/files/cam2/20260606_161525_cam2_right.jpg new file mode 100644 index 0000000..d21116c Binary files /dev/null and b/test/files/cam2/20260606_161525_cam2_right.jpg differ diff --git a/test/files/cam2/20260606_161552_cam2_right.jpg b/test/files/cam2/20260606_161552_cam2_right.jpg new file mode 100644 index 0000000..547fe44 Binary files /dev/null and b/test/files/cam2/20260606_161552_cam2_right.jpg differ diff --git a/test/files/cam2/20260606_161627_cam2_right.jpg b/test/files/cam2/20260606_161627_cam2_right.jpg new file mode 100644 index 0000000..39e176d Binary files /dev/null and b/test/files/cam2/20260606_161627_cam2_right.jpg differ diff --git a/test/files/cam2/20260606_161650_cam2_right.jpg b/test/files/cam2/20260606_161650_cam2_right.jpg new file mode 100644 index 0000000..3388184 Binary files /dev/null and b/test/files/cam2/20260606_161650_cam2_right.jpg differ diff --git a/test/files/cam2/calibration_c922.npz b/test/files/cam2/calibration_c922.npz new file mode 100644 index 0000000..6128aa0 Binary files /dev/null and b/test/files/cam2/calibration_c922.npz differ diff --git a/test/files/cam2/callibriate.py b/test/files/cam2/callibriate.py new file mode 100644 index 0000000..14ecbc1 --- /dev/null +++ b/test/files/cam2/callibriate.py @@ -0,0 +1,99 @@ + +import cv2 +import numpy as np +import glob + +# +# Create calibration .npz from checkerboard images +# + +# Parameters +CHECKERBOARD = (10, 7) # inner corners +square_size = 25.0 / 1000.0 # 25 mm -> meters + +# Prepare object points +objp = np.zeros((CHECKERBOARD[0] * CHECKERBOARD[1], 3), np.float32) +objp[:, :2] = np.mgrid[0:CHECKERBOARD[0], 0:CHECKERBOARD[1]].T.reshape(-1, 2) +objp *= square_size + +objpoints = [] # 3D points +imgpoints = [] # 2D points + +# Load images +images = glob.glob("*.jpg") +print("Found images:", len(images)) + +img_size = None + +for fname in images: + img = cv2.imread(fname) + + print(f"Processing {fname}...") + if img is None: + print(f"Warning: could not read {fname}") + continue + + gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) + + # Save image size once + if img_size is None: + img_size = gray.shape[::-1] + + print(f" Gray") + ret, corners = cv2.findChessboardCorners( + gray, + CHECKERBOARD, + flags=cv2.CALIB_CB_ADAPTIVE_THRESH + + cv2.CALIB_CB_NORMALIZE_IMAGE + + cv2.CALIB_CB_FAST_CHECK + ) + print(" Corners found") + + if ret: + corners2 = cv2.cornerSubPix( + gray, + corners, + (11, 11), + (-1, -1), + (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 1e-6) + ) + + objpoints.append(objp) + imgpoints.append(corners2) + + print(f"✅ Corners found in {fname}") + else: + print(f"❌ No corners found in {fname}") + +print(f"\nTotal valid images: {len(objpoints)} / {len(images)}" ) +# Sanity checks +if img_size is None: + raise RuntimeError("No images were successfully loaded.") + +if len(objpoints) == 0: + raise RuntimeError("No chessboard corners detected in any image. Calibration failed.") + +print("\n=== Sanity Checks Passed ===") +# Calibration +ret, K, D, rvecs, tvecs = cv2.calibrateCamera( + objpoints, + imgpoints, + img_size, + None, + None +) + + +print("\n=== Calibration Results ===") +print("RMS reprojection error:", ret) +print("Camera matrix:\n", K) +print("Distortion coefficients:\n", D) + +# Save calibration +np.savez( + "calibration_XPro2_16mm.npz", + camera_matrix=K, + dist_coeffs=D +) + +print("\n✅ Calibration saved to calibration_XPro2_16mm.npz")