-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
294 lines (277 loc) · 14.6 KB
/
Copy pathindex.html
File metadata and controls
294 lines (277 loc) · 14.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SiliconAperture</title>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css">
<link rel="icon" type="image/png" href="assets/favicon-96x96.png" sizes="96x96">
<link rel="icon" type="image/svg+xml" href="assets/favicon.svg">
<link rel="shortcut icon" href="assets/favicon.ico">
<link rel="apple-touch-icon" sizes="180x180" href="assets/apple-touch-icon.png">
<link rel="manifest" href="assets/site.webmanifest">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div id="app">
<!-- ═══ LEFT: IMAGE PANEL ═══ -->
<div id="image-panel">
<div class="panel-header">
<div class="brand">
<svg class="brand-logo" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
<defs><clipPath id="brand-hex-clip"><polygon points="10,73 10,27 50,4 90,27 90,73 50,96"/></clipPath></defs>
<polygon points="10,73 10,27 50,4 90,27 90,73 50,96" fill="#130608"/>
<g clip-path="url(#brand-hex-clip)">
<polygon points="50,62 27,100 73,100" fill="#e63946"/>
<polygon points="50,62 5,-10 95,-10" fill="#e63946"/>
</g>
<polygon points="10,73 10,27 50,4 90,27 90,73 50,96" fill="none" stroke="#e63946" stroke-width="5"/>
</svg><span><span class="brand-accent">Silicon</span>Aperture</span></div>
<div class="toolbar">
<button id="btn-reset-marks" disabled>Reset marks</button>
<button id="btn-new-image">New image</button>
</div>
</div>
<div id="step-bar">
<div class="step-chain">
<div class="step-node active" id="step-photo">
<span class="step-icon" data-n="1"></span>
<span class="step-label">Drop image here</span>
</div>
<span class="step-connector">—</span>
<div class="step-node" id="step-sensor">
<span class="step-icon" data-n="2"></span>
<span class="step-label">Enter sensor parameters</span>
</div>
<span class="step-connector">—</span>
<div class="step-node" id="step-mark">
<span class="step-icon" data-n="3"></span>
<span class="step-label">Mark measurement on photo</span>
</div>
<span class="step-connector">—</span>
<div class="step-node" id="step-dist">
<span class="step-icon" data-n="4"></span>
<span class="step-label">Mark distance on map</span>
</div>
</div>
<span id="pixel-readout" class="step-val"></span>
</div>
<div id="image-container">
<canvas id="image-canvas"></canvas>
<div id="drop-overlay">
<div class="drop-inner">
<div class="drop-icon">
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
<defs><clipPath id="sa-hex-clip"><polygon points="10,73 10,27 50,4 90,27 90,73 50,96"/></clipPath></defs>
<polygon points="10,73 10,27 50,4 90,27 90,73 50,96" fill="#130608"/>
<g clip-path="url(#sa-hex-clip)">
<polygon points="50,62 27,100 73,100" fill="#e63946"/>
<polygon points="50,62 5,-10 95,-10" fill="#e63946"/>
</g>
<polygon points="10,73 10,27 50,4 90,27 90,73 50,96" fill="none" stroke="#e63946" stroke-width="5"/>
</svg>
</div>
<div class="drop-msg">Drop a photo here<br><span>or click to browse</span></div>
</div>
</div>
<input type="file" id="file-input" accept="image/*">
<div class="zoom-hint">scroll to zoom · drag to pan · click twice to mark object extent</div>
</div>
</div>
<!-- ═══ RIGHT: CONTROLS PANEL ═══ -->
<div id="controls-panel">
<div class="panel-header">
<div class="panel-title">Image Mensuration</div>
<div class="header-actions">
<a id="github-link" class="icon-btn" href="https://github.com/kluter/SiliconAperture" target="_blank" rel="noopener noreferrer" title="View source on GitHub" aria-label="View source on GitHub">
<svg viewBox="0 0 16 16" width="16" height="16" fill="currentColor" aria-hidden="true">
<path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"/>
</svg>
</a>
<button id="btn-help" class="icon-btn" title="How to use">?</button>
</div>
</div>
<!-- EXIF strip — always visible, prominent -->
<div id="exif-bar">
<div class="exif-cell">
<div class="exif-lbl">Camera</div>
<div class="exif-val" id="exif-camera-val">—</div>
</div>
<div class="exif-cell">
<div class="exif-lbl">Focal length</div>
<div class="exif-val" id="exif-focal-val">—</div>
<div class="exif-sub" id="exif-focal-eq"></div>
</div>
<div class="exif-cell">
<div class="exif-lbl">Image size</div>
<div class="exif-val" id="exif-size-val">—</div>
</div>
<div class="exif-cell">
<div class="exif-lbl">GPS</div>
<div class="exif-val" id="exif-gps-val">—</div>
</div>
</div>
<!-- Camera obscura / similar-triangles diagram -->
<div id="diagram-wrap">
<svg id="diagram-svg" viewBox="-6.5 0 530 132" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
<!-- Sensor (left — inner orientation, short side) -->
<line id="seg-sensor" class="seg" x1="52" y1="16" x2="52" y2="104"/>
<!-- Pixel span marker on sensor -->
<line id="seg-pixels" class="seg px-mark" x1="52" y1="30" x2="52" y2="90"/>
<!-- Focal length (short) -->
<line id="seg-focal" class="seg dashed" x1="52" y1="60" x2="165" y2="60"/>
<!-- Rays: sensor to pinhole -->
<line id="ray-tl" class="seg ray" x1="52" y1="16" x2="165" y2="60"/>
<line id="ray-bl" class="seg ray" x1="52" y1="104" x2="165" y2="60"/>
<!-- Pinhole -->
<circle id="seg-pinhole" class="seg dot" cx="165" cy="60" r="5"/>
<!-- Rays: pinhole to object -->
<line id="ray-tr" class="seg ray" x1="165" y1="60" x2="465" y2="16"/>
<line id="ray-br" class="seg ray" x1="165" y1="60" x2="465" y2="104"/>
<!-- Distance (long) -->
<line id="seg-distance" class="seg dashed" x1="165" y1="60" x2="465" y2="60"/>
<!-- Object (right — real world, long side) -->
<line id="seg-object" class="seg" x1="465" y1="16" x2="465" y2="104"/>
<!-- Labels -->
<text id="diag-lbl-sensor" x="52" y="120" class="diag-lbl" text-anchor="middle">sensor</text>
<text id="diag-lbl-px" x="70" y="74" class="diag-lbl" text-anchor="start">px</text>
<text id="diag-lbl-f" x="108" y="52" class="diag-lbl" text-anchor="middle">f</text>
<text id="diag-lbl-d" x="315" y="52" class="diag-lbl" text-anchor="middle">D</text>
<text id="diag-lbl-object" x="465" y="120" class="diag-lbl" text-anchor="middle">object</text>
<!-- Real-size label (appears when result computed) -->
<text id="diag-lbl-result" x="465" y="10" class="diag-lbl diag-result" text-anchor="middle" style="display:none">size</text>
</svg>
</div>
<!-- Inputs -->
<div id="inputs-section">
<!-- Sensor world -->
<div class="input-group">
<label class="field-label">Sensor
<span id="src-exif" class="src-badge">EXIF</span>
<span id="src-db" class="src-badge">DB</span>
<span id="src-custom" class="src-badge">CUSTOM</span>
</label>
<button id="camera-trigger" type="button">— select camera / phone —</button>
<div class="input-row">
<div class="labeled-input" style="flex:1">
<input type="number" id="sensor-w-input" placeholder="0.00" min="0.1" step="0.01" style="width:100%" autocomplete="off">
<span class="unit-tag">mm W</span>
</div>
<div class="labeled-input" style="flex:1">
<input type="number" id="sensor-h-input" placeholder="0.00" min="0.1" step="0.01" style="width:100%" autocomplete="off">
<span class="unit-tag">mm H</span>
</div>
<div class="labeled-input" style="flex:1">
<input type="number" id="focal-length-input" placeholder="0.00" min="0.1" step="0.01" style="width:100%" autocomplete="off">
<span class="unit-tag">mm f</span>
</div>
</div>
</div>
<!-- Object world -->
<div style="display:flex; gap:10px; border-top:1px solid #1e1e1e; padding-top:10px; margin-top:2px;">
<div class="input-group" style="flex:1">
<label class="field-label">Object span
<span class="field-source" id="span-source">click two points on photo</span>
</label>
<div class="input-row">
<div class="labeled-input" style="flex:1">
<input type="number" id="pixel-span-input" placeholder="—" min="1" step="1" readonly style="width:100%">
<span class="unit-tag">px</span>
</div>
</div>
</div>
<div class="input-group" style="flex:1">
<label class="field-label"><span id="dist-size-label">Distance</span></label>
<div class="input-row">
<div class="labeled-input" id="distance-field" style="flex:1">
<input type="number" id="distance-input" placeholder="0.0" min="0.01" step="0.1" style="width:100%" autocomplete="off">
<span class="unit-tag">m</span>
</div>
<div class="labeled-input" id="known-size-field" style="flex:1; display:none">
<input type="number" id="known-size-input" placeholder="0.0" min="0.01" step="0.1" style="width:100%" autocomplete="off">
<span class="unit-tag">m</span>
</div>
</div>
</div>
</div>
</div>
<!-- Result -->
<div id="result-bar">
<div id="solve-toggle">
<button type="button" class="solve-btn active-solve" data-mode="size">Size</button>
<button type="button" class="solve-btn" data-mode="distance">Distance</button>
</div>
<div class="result-divider"></div>
<div id="result-main">
<div class="result-label" id="result-label">Real-world size</div>
<div class="result-display">
<span id="result-value">—</span>
<span id="result-unit" class="result-unit">m</span>
</div>
<div id="result-eq"></div>
</div>
</div>
<!-- Map — always visible -->
<div id="map-section">
<div id="map-header">
<span class="map-dist-label">Distance</span>
<span id="map-dist-val">camera position → object position</span>
<div id="map-tile-btns">
<button class="tile-btn active-tile" data-tile="esri">Satellite</button>
<button class="tile-btn" data-tile="osm">OSM</button>
<button class="tile-btn" data-tile="carto">Dark</button>
</div>
<button id="btn-map-reset-pts" class="icon-btn" title="Reset measurement points">↺</button>
</div>
<div id="map-coord-row">
<input type="text" id="coord-input" placeholder="paste lat, lng to place a point" autocomplete="off" spellcheck="false">
</div>
<div id="map-container"></div>
</div>
</div>
</div>
<!-- Help overlay -->
<div id="help-card" style="display:none">
<div class="help-inner">
<div class="help-header">
<span>How to use <span class="brand-accent">Silicon</span>Aperture</span>
<button id="btn-help-close" class="icon-btn">✕</button>
</div>
<ol class="help-steps">
<li>Drop a photo onto the left panel.</li>
<li>If the image contains EXIF metadata, camera model, sensor and focal length are detected automatically. Otherwise select your camera from the dropdown or enter sensor dimensions and focal length manually.</li>
<li>Click two points on the photo to mark the object's extent. The pixel span fills in.</li>
<li>Enter the distance to the object in meters, or click two points on the satellite map to measure it.</li>
<li>The real-world size appears as soon as all four inputs are valid.</li>
</ol>
<p class="help-formula-note">Flip the <strong>Solve for</strong> toggle to <strong>Distance</strong> to work it the other way: enter an object's known real-world size and the tool returns the distance to it, then click the object on the satellite map to draw a ring of possible camera positions.</p>
<div class="help-formulas">
<div class="help-formula" style="text-align:center">
<div class="help-formula-label">Solve for size</div>
<code>size = √( (D·tan(Δx/W·sw/f))² + (D·tan(Δy/H·sh/f))² )</code>
</div>
<div class="help-formula" style="text-align:center">
<div class="help-formula-label">Solve for distance</div>
<code>D = size / √( tan(Δx/W·sw/f)² + tan(Δy/H·sh/f)² )</code>
</div>
</div>
<table class="help-legend">
<tr><td>D</td><td>distance to object</td><td>f</td><td>focal length</td></tr>
<tr><td>Δx, Δy</td><td>pixel span per axis</td><td>W, H</td><td>image width / height</td></tr>
<tr><td>sw, sh</td><td>sensor width / height</td><td></td><td></td></tr>
</table>
<p class="help-formula-note">Each axis is solved independently with its matching sensor dimension, then the two real-world components are combined with Pythagoras. Works for marks at any angle.<br><br>Accurate results require the object to be <strong>perpendicular to the camera axis</strong>. If the surface is angled, the apparent extent seen by the lens no longer maps linearly to the true physical size, and the result will be inaccurate.</p>
<div class="help-shortcuts">
<kbd>R</kbd><span>Reset marks</span>
<kbd>N</kbd><span>New image</span>
<kbd>Esc</kbd><span>Close help</span>
</div>
</div>
</div>
<div id="toast-container"></div>
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<script src="https://cdn.jsdelivr.net/npm/exifr/dist/full.umd.min.js"></script>
<script src="js/camera-db.js"></script>
<script src="js/script.js"></script>
</body>
</html>