Skip to content

Commit 2e391a2

Browse files
committed
Show camera preview
1 parent 3bc99f8 commit 2e391a2

File tree

3 files changed

+33
-5
lines changed

3 files changed

+33
-5
lines changed

Software/web-server/calibration_manager.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ async def check_ball_location(self, camera: str = "camera1") -> Dict[str, Any]:
309309
camera: Which camera to use ("camera1" or "camera2")
310310
311311
Returns:
312-
Dict with status and ball location info
312+
Dict with status, ball location info, and image path for display
313313
"""
314314
logger.info(f"Starting ball location check for {camera}")
315315

@@ -348,13 +348,21 @@ async def check_ball_location(self, camera: str = "camera1") -> Dict[str, Any]:
348348
if camera_gain is None:
349349
camera_gain = 6.0
350350

351+
# Create output filename for the captured image
352+
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
353+
output_file = f"ball_location_{camera}_{timestamp}.png"
354+
images_dir = Path.home() / "LM_Shares" / "Images"
355+
images_dir.mkdir(parents=True, exist_ok=True)
356+
output_path = images_dir / output_file
357+
351358
cmd.extend(
352359
[
353360
f"--search_center_x={search_x}",
354361
f"--search_center_y={search_y}",
355362
f"--logging_level={logging_level}",
356363
"--artifact_save_level=all",
357364
f"--camera_gain={camera_gain}",
365+
f"--output_filename={output_path}",
358366
]
359367
)
360368
cmd.extend(self._build_cli_args_from_metadata(camera))
@@ -368,10 +376,19 @@ async def check_ball_location(self, camera: str = "camera1") -> Dict[str, Any]:
368376
self.calibration_status[camera]["message"] = "Ball detected" if ball_info else "Ball not found"
369377
self.calibration_status[camera]["progress"] = 100
370378

379+
image_url = None
380+
if output_path.exists():
381+
image_url = f"/api/images/{output_file}"
382+
logger.info(f"Ball location image saved: {output_path}")
383+
else:
384+
logger.warning(f"Ball location image not found at: {output_path}")
385+
371386
return {
372387
"status": "success",
373388
"ball_found": bool(ball_info),
374389
"ball_info": ball_info,
390+
"image_url": image_url,
391+
"image_path": str(output_path) if output_path.exists() else None,
375392
"output": result.get("output", ""),
376393
}
377394

Software/web-server/static/js/calibration.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ class CalibrationManager {
274274
}
275275

276276
const button = event?.target || event?.currentTarget;
277-
const originalText = button?.textContent || 'Check Ball Location';
277+
const originalText = button?.textContent || 'Verify Ball Placement';
278278

279279
try {
280280
if (button) {
@@ -290,6 +290,17 @@ class CalibrationManager {
290290
const result = await response.json();
291291
const statusDiv = document.getElementById(`${camera}-ball-status`);
292292

293+
if (result.image_url) {
294+
const img = document.getElementById(`${camera}-image`);
295+
img.src = result.image_url + '?t=' + Date.now(); // Cache bust
296+
img.style.display = 'block';
297+
298+
const placeholder = img.parentElement.querySelector('.camera-placeholder');
299+
if (placeholder) {
300+
placeholder.style.display = 'none';
301+
}
302+
}
303+
293304
if (result.ball_found) {
294305
statusDiv.className = 'ball-status success';
295306
statusDiv.textContent = `Ball detected at position (${result.ball_info?.x || 0}, ${result.ball_info?.y || 0})`;

Software/web-server/templates/calibration.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ <h3>Camera 1 - Tee Camera (Top/Angled)</h3>
104104
Calibrate Camera 1
105105
</button>
106106
<button class="btn btn-secondary" onclick="calibration.checkBallLocation('camera1', event)">
107-
Check Ball Location
107+
Verify Ball Placement
108108
</button>
109109
</div>
110110
<div class="ball-status" id="camera1-ball-status"></div>
@@ -123,7 +123,7 @@ <h3>Camera 2 - Flight Camera (Bottom/Straight)</h3>
123123
Calibrate Camera 2
124124
</button>
125125
<button class="btn btn-secondary" onclick="calibration.checkBallLocation('camera2', event)">
126-
Check Ball Location
126+
Verify Ball Placement
127127
</button>
128128
</div>
129129
<div class="ball-status" id="camera2-ball-status"></div>
@@ -212,7 +212,7 @@ <h4>Process Log:</h4>
212212
<h2>Calibration Complete</h2>
213213

214214
<div class="calibration-results">
215-
<div class="success-icon">🎉</div>
215+
<div class="success-icon"></div>
216216

217217
<div class="results-summary">
218218
<h3>Calibration Results:</h3>

0 commit comments

Comments
 (0)