Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion builtin-programs/calibrate/calibrate-page.folk
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ Wish the web server handles route "/calibrate" with hidden true handler {

set camera $QUERY(camera)

# Query the camera resolution for proper aspect ratio in preview (defaults to 1920x1080)
set cameraOpts [dict getdef [lindex [Query! /someone/ wishes $::thisNode uses camera $camera with /...opts/] 0] opts {width 1920 height 1080}]
set cameraWidth [dict get $cameraOpts width]
set cameraHeight [dict get $cameraOpts height]

upvar ^html ^html
html [csubst {
<html>
Expand Down Expand Up @@ -269,6 +274,9 @@ Claim the calibration poses max is \${calibrationPosesMax}
<p>Use this camera preview to debug why printed and/or projected tags aren't being recognized (maybe overexposure, maybe your camera isn't in a good position): <button id="refreshButton">Refresh Preview</button> <input type="checkbox" value="true" id="autoRefreshCheckbox" checked>
<label for="autoRefreshCheckbox">Automatically refresh preview</label> </p><br> <span id="cameraPreview"></span>
<script>
const cameraWidth = $cameraWidth;
const cameraHeight = $cameraHeight;

refreshButton.onclick = function() {
if (typeof cameraFrame !== 'undefined') {
cameraFrame.src = '/camera-frame?uniq=' + Math.random();
Expand All @@ -277,8 +285,10 @@ Claim the calibration poses max is \${calibrationPosesMax}
}
};
function setupCameraPreview() {
const iframeWidth = 600;
const iframeHeight = Math.round(600 * cameraHeight / cameraWidth);
if (autoRefreshCheckbox.checked) {
cameraPreview.innerHTML = `<iframe id="cameraView" src="/camera" width="600" height="338"></iframe>`;
cameraPreview.innerHTML = `<iframe id="cameraView" src="/camera" width="\${iframeWidth}" height="\${iframeHeight}"></iframe>`;
} else {
cameraPreview.innerHTML = `<img id="cameraFrame" src="/camera-frame" style="max-width: 100%">`;
}
Expand Down
7 changes: 5 additions & 2 deletions builtin-programs/web/setup.folk
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,13 @@ folk.watchCollected(`/someone/ wishes the web server handles route "/setup" with
} }] \n]
</fieldset>

[if {$isUsingCamera} { subst {
[if {$isUsingCamera} {
set iframeWidth 600
set iframeHeight [expr {int(600.0 * $usingOpts(height) / $usingOpts(width))}]
subst {
<div style="margin-top: 10px;">
<iframe src="/camera?camera=[string map {/ %2F} $camera]"
width="600" height="338"
width="$iframeWidth" height="$iframeHeight"
style="border: 1px solid #999;"></iframe>
</div>
} }]
Expand Down