annotate web/calibrate/Light9Camera.ts @ 2417:ae4b90efb55a

start calibration tool
author drewp@bigasterisk.com
date Mon, 20 May 2024 01:28:12 -0700
parents
children 9bb0eb587d5b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2417
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
1 import debug from "debug";
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
2 import { css, html, LitElement, PropertyValueMap, TemplateResult } from "lit";
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
3 import { customElement, property, state } from "lit/decorators.js";
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
4
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
5 @customElement("light9-camera")
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
6 export class Light9Camera extends LitElement {
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
7 static styles = [
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
8 css`
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
9 :host {
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
10 display: flex;
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
11 }
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
12 #video {
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
13 display: none;
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
14 }
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
15 #stack {
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
16 position: relative;
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
17 width: 640px;
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
18 height: 480px;
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
19 }
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
20 #stack > * {
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
21 position: absolute;
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
22 left: 0;
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
23 top: 0;
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
24 }
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
25 #stack > :first-child {
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
26 position: static;
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
27 }
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
28 #stack > img {
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
29 opacity: 0;
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
30 animation: fadeIn 1s 1s ease-in-out forwards;
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
31 }
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
32 @keyframes fadeIn {
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
33 from {
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
34 opacity: 0;
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
35 }
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
36 to {
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
37 opacity: 1;
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
38 }
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
39 }
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
40 `,
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
41 ];
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
42 videoEl!: HTMLVideoElement;
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
43 canvas!: HTMLCanvasElement;
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
44 ctx!: CanvasRenderingContext2D;
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
45 @state()
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
46 vtrack: MediaStreamTrack | undefined;
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
47
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
48 @property() saturatedPixelCount = 0;
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
49 @property() saturatedPixelFraction = 0;
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
50
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
51 @property() videoSettings: MediaTrackSettings & any = {};
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
52
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
53 render() {
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
54 const saturatedCountDisplay = `${this.saturatedPixelCount} (${(this.saturatedPixelFraction * 100).toFixed(2)}%)`;
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
55
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
56 return html`
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
57 <video id="video"></video>
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
58
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
59 <div id="stack">
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
60 <img src="zebra.png" />
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
61 <canvas id="canvas"></canvas>
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
62 </div>
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
63 <div id="controls">
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
64 <p>saturated pixels: ${saturatedCountDisplay}</p>
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
65 <light9-camera-settings-table .cam=${this} .videoSettings=${this.videoSettings}></light9-camera-settings-table>
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
66 </div>
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
67 `;
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
68 }
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
69
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
70 protected async firstUpdated(_changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>) {
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
71 this.videoEl = this.shadowRoot!.getElementById("video") as HTMLVideoElement;
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
72 this.canvas = this.shadowRoot!.getElementById("canvas") as HTMLCanvasElement;
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
73 this.ctx = this.canvas.getContext("2d", { willReadFrequently: true })!;
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
74
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
75 const constraints: MediaStreamConstraints = {
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
76 video: {
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
77 facingMode: { ideal: "environment" },
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
78 frameRate: { max: 10 },
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
79 },
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
80 };
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
81 const stream = await navigator.mediaDevices.getUserMedia(constraints);
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
82 const t = stream.getVideoTracks()[0];
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
83 await t.applyConstraints({
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
84 brightness: 0,
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
85 contrast: 32,
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
86 colorTemperature: 6600,
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
87 exposureMode: "manual",
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
88 exposureTime: 250,
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
89 whiteBalanceMode: "manual",
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
90 focusMode: "manual",
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
91 focusDistance: 235,
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
92 } as MediaTrackConstraints);
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
93
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
94 this.vtrack = t;
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
95 this.videoEl.srcObject = stream;
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
96 this.videoEl.play();
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
97 this.videoSettings = this.vtrack.getSettings();
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
98
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
99 this.redrawLoop();
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
100 }
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
101
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
102 redrawLoop() {
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
103 if (this.videoEl.videoWidth !== 0 && this.videoEl.videoHeight !== 0) {
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
104 this.redraw();
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
105 }
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
106 // todo: video frames come slower than raf is waiting
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
107 requestAnimationFrame(this.redrawLoop.bind(this));
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
108 }
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
109
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
110 public async set(k: string, v: any) {
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
111 if (!this.vtrack) {
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
112 throw new Error("vtrack");
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
113 }
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
114 await this.vtrack.applyConstraints({ [k]: v });
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
115 this.videoSettings = this.vtrack.getSettings();
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
116 }
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
117
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
118 private redraw() {
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
119 this.canvas.width = this.videoEl.videoWidth;
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
120 this.canvas.height = this.videoEl.videoHeight;
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
121 this.ctx.drawImage(this.videoEl, 0, 0);
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
122 this.makeSaturatedPixelsTransparent();
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
123 }
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
124
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
125 private makeSaturatedPixelsTransparent() {
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
126 const imageData = this.ctx.getImageData(0, 0, this.canvas.width, this.canvas.height);
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
127 const data = imageData.data;
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
128 this.saturatedPixelCount = 0;
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
129 for (let i = 0; i < data.length; i += 4) {
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
130 if (data[i] === 255 || data[i + 1] === 255 || data[i + 2] === 255) {
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
131 this.saturatedPixelCount += 1;
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
132
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
133 data[i + 3] = 0;
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
134 }
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
135 }
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
136 this.saturatedPixelFraction = this.saturatedPixelCount / (data.length / 4);
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
137 this.ctx.putImageData(imageData, 0, 0);
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
138 }
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
139 }
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
140
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
141 @customElement("light9-camera-settings-table")
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
142 export class Light9CameraSettingsTable extends LitElement {
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
143 static styles = [
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
144 css`
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
145 table {
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
146 border-collapse: collapse;
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
147 }
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
148 td {
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
149 border: 1px solid gray;
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
150 padding: 1px 6px;
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
151 }
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
152 `,
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
153 ];
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
154
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
155 boring = [
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
156 "aspectRatio",
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
157 "backgroundBlur",
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
158 "channelCount",
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
159 "deviceId",
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
160 "displaySurface",
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
161 "echoCancellation",
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
162 "eyeGazeCorrection",
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
163 "faceFraming",
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
164 "groupId",
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
165 "latency",
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
166 "noiseSuppression",
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
167 "pointsOfInterest",
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
168 "resizeMode",
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
169 "sampleRate",
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
170 "sampleSize",
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
171 "suppressLocalAudioPlayback",
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
172 "torch",
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
173 "voiceIsolation",
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
174 ];
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
175
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
176 adjustable: Record<string, { min: string; max: string }> = {
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
177 focusDistance: { min: "0", max: "1023" },
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
178 brightness: { min: "0", max: "64" },
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
179 colorTemperature: { min: "2800", max: "6500" },
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
180 exposureTime: { min: "0", max: "400" },
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
181 };
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
182
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
183 @property() cam!: Light9Camera;
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
184 @property() videoSettings: MediaTrackSettings & any = {};
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
185 supportedByBrowser: MediaTrackSupportedConstraints;
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
186 constructor() {
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
187 super();
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
188 this.supportedByBrowser = navigator.mediaDevices.getSupportedConstraints();
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
189 }
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
190 render() {
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
191 const rows: TemplateResult<1>[] = [];
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
192 for (const key of Object.keys(this.supportedByBrowser)) {
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
193 if (!this.boring.includes(key)) {
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
194 this.renderRow(key, rows);
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
195 }
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
196 }
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
197 return html`<table>
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
198 ${rows}
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
199 </table>`;
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
200 }
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
201
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
202 private renderRow(key: string, rows: any[]) {
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
203 let valueDisplay = "";
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
204 if (this.videoSettings[key] !== undefined) {
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
205 valueDisplay = JSON.stringify(this.videoSettings[key]);
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
206 }
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
207 let adjuster = html``;
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
208 let conf = this.adjustable[key];
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
209 if (conf !== undefined) {
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
210 adjuster = html`
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
211 <input type="range" min="${conf.min}" max="${conf.max}" value="${this.videoSettings[key]}" data-param="${key}" @input=${this.setFromSlider} />
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
212 `;
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
213 }
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
214 rows.push(
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
215 html`<tr>
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
216 <td>${key}</td>
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
217 <td>${valueDisplay}</td>
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
218 <td>${adjuster}</td>
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
219 </tr>`
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
220 );
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
221 }
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
222
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
223 async setFromSlider(ev: InputEvent) {
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
224 const el = ev.target as HTMLInputElement;
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
225 await this.cam.set(el.dataset.param as string, parseFloat(el.value));
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
226 }
ae4b90efb55a start calibration tool
drewp@bigasterisk.com
parents:
diff changeset
227 }