@wemap/camera 8.0.1 → 8.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/wemap-camera.es.js +623 -0
- package/dist/wemap-camera.es.js.map +1 -0
- package/index.d.ts +17 -0
- package/package.json +3 -2
|
@@ -0,0 +1,623 @@
|
|
|
1
|
+
import { BarcodeFormat, MultiFormatReader, DecodeHintType, BinaryBitmap, HybridBinarizer, RGBLuminanceSource } from '@zxing/library';
|
|
2
|
+
export { BarcodeFormat } from '@zxing/library';
|
|
3
|
+
import EventEmitter from 'events';
|
|
4
|
+
import Logger from '@wemap/logger';
|
|
5
|
+
|
|
6
|
+
class SharedCameras extends EventEmitter {
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Singleton pattern.
|
|
10
|
+
* @returns {SharedCameras}
|
|
11
|
+
*/
|
|
12
|
+
static get instance() {
|
|
13
|
+
if (!this._instance) {
|
|
14
|
+
this._instance = new SharedCameras();
|
|
15
|
+
}
|
|
16
|
+
return this._instance;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** @type {{container: Node, camera: Camera}[]} */
|
|
20
|
+
_list = [];
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @param {Camera} camera
|
|
24
|
+
* @param {Node}
|
|
25
|
+
*/
|
|
26
|
+
_add(camera, container) {
|
|
27
|
+
const obj = {
|
|
28
|
+
camera,
|
|
29
|
+
container
|
|
30
|
+
};
|
|
31
|
+
this._list.push(obj);
|
|
32
|
+
this.emit('added', obj);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @param {Camera} camera
|
|
37
|
+
*/
|
|
38
|
+
_remove(camera) {
|
|
39
|
+
this._list = this._list.filter(({ camera: _camera }) => _camera !== camera);
|
|
40
|
+
this.emit('removed', { camera });
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @returns {{container: Node, camera: Camera}[]}
|
|
45
|
+
*/
|
|
46
|
+
get list() {
|
|
47
|
+
return this._list;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @param {Node} container
|
|
52
|
+
* @returns {?Camera}
|
|
53
|
+
*/
|
|
54
|
+
getCameraByContainer(container) {
|
|
55
|
+
for (const {
|
|
56
|
+
camera, container: _container
|
|
57
|
+
} of this._list) {
|
|
58
|
+
if (container === _container) {
|
|
59
|
+
return camera;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
var SharedCameras$1 = SharedCameras.instance;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @param {number} angle
|
|
70
|
+
* @param {number} aspectRatio
|
|
71
|
+
* @returns {number}
|
|
72
|
+
*/
|
|
73
|
+
function convertFov(angle, aspectRatio) {
|
|
74
|
+
return 2 * Math.atan(Math.tan((angle / 180 * Math.PI) / 2) * aspectRatio) * 180 / Math.PI;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @param {HTMLDivElement} videoContainer
|
|
79
|
+
* @param {HTMLVideoElement} videoElement
|
|
80
|
+
* @param {number} hardwareVerticalFov
|
|
81
|
+
* @returns {object}
|
|
82
|
+
*/
|
|
83
|
+
function calcDisplayedFov(videoContainer, videoElement, hardwareVerticalFov) {
|
|
84
|
+
|
|
85
|
+
const sourceWidth = videoElement.videoWidth;
|
|
86
|
+
const sourceHeight = videoElement.videoHeight;
|
|
87
|
+
|
|
88
|
+
const containerWidth = videoContainer.offsetWidth;
|
|
89
|
+
const containerHeight = videoContainer.offsetHeight;
|
|
90
|
+
|
|
91
|
+
const sourceAspect = sourceWidth / sourceHeight;
|
|
92
|
+
const screenAspect = containerWidth / containerHeight;
|
|
93
|
+
|
|
94
|
+
let fovV = hardwareVerticalFov;
|
|
95
|
+
let fovH = convertFov(fovV, sourceAspect);
|
|
96
|
+
|
|
97
|
+
if (screenAspect < sourceAspect) {
|
|
98
|
+
fovH = convertFov(fovV, screenAspect);
|
|
99
|
+
} else {
|
|
100
|
+
fovV = convertFov(fovH, 1 / screenAspect);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return {
|
|
104
|
+
vertical: fovV,
|
|
105
|
+
horizontal: fovH
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* @param {HTMLCanvasElement} canvas
|
|
111
|
+
* @param {string} type
|
|
112
|
+
* @param {any} quality
|
|
113
|
+
* @returns {string}
|
|
114
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL
|
|
115
|
+
*/
|
|
116
|
+
function canvasToBase64(canvas, type = 'image/png', quality = null) {
|
|
117
|
+
return canvas
|
|
118
|
+
.toDataURL(type, quality)
|
|
119
|
+
.substring(('data:' + type + ';base64,').length);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Creates a pinhole camera from dimensions and a field of view
|
|
124
|
+
* Distortions are not considered
|
|
125
|
+
*
|
|
126
|
+
* @param {number} width the camera width
|
|
127
|
+
* @param {number} height the camera height
|
|
128
|
+
* @param {number} fovOfWidth the field of view along the width axis in radians
|
|
129
|
+
* @returns {object} the calibration matrix
|
|
130
|
+
*/
|
|
131
|
+
function createCameraCalibrationFromWidthHeightFov(width, height, fovOfWidth) {
|
|
132
|
+
|
|
133
|
+
const fovOfHeight = 2 * Math.atan(height * Math.tan(fovOfWidth / 2) / width);
|
|
134
|
+
|
|
135
|
+
const fx = width / (2 * Math.tan(0.5 * fovOfWidth));
|
|
136
|
+
const fy = height / (2 * Math.tan(0.5 * fovOfHeight));
|
|
137
|
+
const cx = width / 2;
|
|
138
|
+
const cy = height / 2;
|
|
139
|
+
|
|
140
|
+
return {
|
|
141
|
+
intrinsic: [fx, 0, cx, 0, fy, cy, 0, 0, 1],
|
|
142
|
+
distortions: [0, 0, 0, 0, 0]
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* @param {HTMLCanvasElement} imageCanvas
|
|
148
|
+
*/
|
|
149
|
+
function convertToGrayscale(imageCanvas) {
|
|
150
|
+
const ctx = imageCanvas.getContext('2d');
|
|
151
|
+
const imgData = ctx.getImageData(0, 0, imageCanvas.width, imageCanvas.height);
|
|
152
|
+
const pixels = imgData.data;
|
|
153
|
+
for (let i = 0; i < pixels.length; i += 4) {
|
|
154
|
+
|
|
155
|
+
const lightness = parseInt((pixels[i] + pixels[i + 1] + pixels[i + 2]) / 3, 10);
|
|
156
|
+
pixels[i] = lightness;
|
|
157
|
+
pixels[i + 1] = lightness;
|
|
158
|
+
pixels[i + 2] = lightness;
|
|
159
|
+
}
|
|
160
|
+
ctx.putImageData(imgData, 0, 0);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Reduce image size and keep aspect ratio
|
|
165
|
+
* @param {HTMLCanvasElement} imageCanvas
|
|
166
|
+
*/
|
|
167
|
+
function reduceImageSize(imageCanvas, maxWidth, maxHeight = null) {
|
|
168
|
+
|
|
169
|
+
let newWidth = imageCanvas.width;
|
|
170
|
+
let newHeight = imageCanvas.height;
|
|
171
|
+
|
|
172
|
+
if (maxHeight !== null) {
|
|
173
|
+
if (newWidth > maxWidth) {
|
|
174
|
+
newHeight *= maxWidth / newWidth;
|
|
175
|
+
newWidth = maxWidth;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (newHeight > maxHeight) {
|
|
179
|
+
newWidth *= maxHeight / newHeight;
|
|
180
|
+
newHeight = maxHeight;
|
|
181
|
+
}
|
|
182
|
+
} else {
|
|
183
|
+
const aspectRatio = imageCanvas.width / imageCanvas.height;
|
|
184
|
+
if (imageCanvas.width > imageCanvas.height) {
|
|
185
|
+
if (imageCanvas.width > maxWidth) {
|
|
186
|
+
newWidth = maxWidth;
|
|
187
|
+
newHeight = maxWidth / aspectRatio;
|
|
188
|
+
}
|
|
189
|
+
} else if (imageCanvas.height > maxWidth) {
|
|
190
|
+
newHeight = maxWidth;
|
|
191
|
+
newWidth = maxWidth * aspectRatio;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
if (newWidth === imageCanvas.width
|
|
197
|
+
&& newHeight === imageCanvas.height) {
|
|
198
|
+
return imageCanvas;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const newCanvas = document.createElement('canvas');
|
|
202
|
+
const newContext = newCanvas.getContext('2d');
|
|
203
|
+
|
|
204
|
+
newCanvas.width = newWidth;
|
|
205
|
+
newCanvas.height = newHeight;
|
|
206
|
+
newContext.drawImage(imageCanvas, 0, 0, newCanvas.width, newCanvas.height);
|
|
207
|
+
|
|
208
|
+
return newCanvas;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
var CameraUtils = /*#__PURE__*/Object.freeze({
|
|
212
|
+
__proto__: null,
|
|
213
|
+
convertFov: convertFov,
|
|
214
|
+
calcDisplayedFov: calcDisplayedFov,
|
|
215
|
+
canvasToBase64: canvasToBase64,
|
|
216
|
+
createCameraCalibrationFromWidthHeightFov: createCameraCalibrationFromWidthHeightFov,
|
|
217
|
+
convertToGrayscale: convertToGrayscale,
|
|
218
|
+
reduceImageSize: reduceImageSize
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
// Helped from https://github.com/jeromeetienne/AR.js/blob/master/three.js/src/threex/threex-artoolkitsource.js
|
|
222
|
+
|
|
223
|
+
// Camera preview will fill component bounds without transformations.
|
|
224
|
+
// If the component aspect ratio is different from camera aspect ratio,
|
|
225
|
+
// camera preview is extended then cropped.
|
|
226
|
+
class Camera extends EventEmitter {
|
|
227
|
+
|
|
228
|
+
static State = {
|
|
229
|
+
STOPPED: 'stopped',
|
|
230
|
+
STARTING: 'starting',
|
|
231
|
+
STARTED: 'started',
|
|
232
|
+
STOPPING: 'stopping'
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
static DEFAULT_OPTIONS = {
|
|
236
|
+
width: 1024,
|
|
237
|
+
height: 768,
|
|
238
|
+
resizeOnWindowChange: false
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
static GENERIC_HARDWARE_VERTICAL_FOV = 60;
|
|
242
|
+
|
|
243
|
+
videoContainer;
|
|
244
|
+
videoElement;
|
|
245
|
+
|
|
246
|
+
fov = null;
|
|
247
|
+
|
|
248
|
+
_state = Camera.State.STOPPED;
|
|
249
|
+
|
|
250
|
+
_hardwareVerticalFov = Camera.GENERIC_HARDWARE_VERTICAL_FOV;
|
|
251
|
+
_resizeOnWindowChange;
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* @param {Node} container
|
|
255
|
+
* @param {{width: number, height: number, resizeOnWindowChange: boolean}} options
|
|
256
|
+
*/
|
|
257
|
+
constructor(container, options = {}) {
|
|
258
|
+
super();
|
|
259
|
+
|
|
260
|
+
options = Object.assign({}, Camera.DEFAULT_OPTIONS, options);
|
|
261
|
+
|
|
262
|
+
SharedCameras$1._add(this, container);
|
|
263
|
+
|
|
264
|
+
this.videoContainer = container;
|
|
265
|
+
|
|
266
|
+
this._resizeOnWindowChange = options.resizeOnWindowChange;
|
|
267
|
+
this._userMediaConstraints = {
|
|
268
|
+
audio: false,
|
|
269
|
+
video: {
|
|
270
|
+
facingMode: 'environment',
|
|
271
|
+
width: { ideal: options.width },
|
|
272
|
+
height: { ideal: options.height },
|
|
273
|
+
resizeMode: 'none'
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
this.videoContainer.style.overflow = 'hidden';
|
|
278
|
+
|
|
279
|
+
this.videoElement = document.createElement('video');
|
|
280
|
+
this.videoElement.setAttribute('id', 'wemap-camera');
|
|
281
|
+
this.videoElement.setAttribute('preload', 'none');
|
|
282
|
+
this.videoElement.setAttribute('muted', '');
|
|
283
|
+
this.videoElement.setAttribute('playsinline', '');
|
|
284
|
+
this.videoContainer.appendChild(this.videoElement);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
async start(videoMediaConstraints = null) {
|
|
288
|
+
|
|
289
|
+
if (this._state !== Camera.State.STOPPED) {
|
|
290
|
+
throw new Error('Camera is already started');
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
if (this._state === Camera.State.STOPPING) {
|
|
294
|
+
await new Promise(resolve => this.once('stopped', resolve));
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
this._state = Camera.State.STARTING;
|
|
298
|
+
this.emit('starting');
|
|
299
|
+
|
|
300
|
+
await Camera.checkAvailability();
|
|
301
|
+
|
|
302
|
+
if (videoMediaConstraints) {
|
|
303
|
+
Object.assign(this._userMediaConstraints.video,
|
|
304
|
+
this._userMediaConstraints.video, videoMediaConstraints);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
const stream = await navigator.mediaDevices.getUserMedia(this._userMediaConstraints);
|
|
308
|
+
|
|
309
|
+
// Listeners have to be set before srcObject assigment or they can be never called
|
|
310
|
+
this.videoElement.oncanplaythrough = () => this.videoElement.play();
|
|
311
|
+
const metadataPr = new Promise(resolve => (this.videoElement.onloadedmetadata = resolve));
|
|
312
|
+
|
|
313
|
+
this.videoElement.srcObject = this.videoStream = stream;
|
|
314
|
+
await metadataPr;
|
|
315
|
+
|
|
316
|
+
this._resizeElement();
|
|
317
|
+
this._computeFov();
|
|
318
|
+
|
|
319
|
+
if (this._resizeOnWindowChange) {
|
|
320
|
+
window.addEventListener('resize', this.notifyContainerSizeChanged);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
this._state = Camera.State.STARTED;
|
|
324
|
+
this.emit('started', {
|
|
325
|
+
videoElement: this.videoElement,
|
|
326
|
+
stream
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
async stop() {
|
|
331
|
+
|
|
332
|
+
if (this._state === Camera.State.STOPPED) {
|
|
333
|
+
throw new Error('Camera is already stopped');
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
if (this._state === Camera.State.STARTING) {
|
|
337
|
+
await new Promise(resolve => this.once('started', resolve));
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
this._state = Camera.State.STOPPING;
|
|
341
|
+
this.emit('stopping', this);
|
|
342
|
+
|
|
343
|
+
if (this.videoStream && this.videoStream.stop) {
|
|
344
|
+
// compatibility with old JS API
|
|
345
|
+
this.videoStream.stop();
|
|
346
|
+
} else if (this.videoStream) {
|
|
347
|
+
// new JS API
|
|
348
|
+
this.videoStream.getVideoTracks().forEach(track => track.stop());
|
|
349
|
+
}
|
|
350
|
+
this.videoStream = null;
|
|
351
|
+
this.videoElement.srcObject = null;
|
|
352
|
+
|
|
353
|
+
if (this._resizeOnWindowChange) {
|
|
354
|
+
window.removeEventListener('resize', this.notifyContainerSizeChanged);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
this._state = Camera.State.STOPPED;
|
|
358
|
+
this.emit('stopped', this);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
release() {
|
|
362
|
+
this.videoContainer.removeChild(this.videoElement);
|
|
363
|
+
SharedCameras$1._remove(this);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
static async checkAvailability(testUserMedia = false) {
|
|
367
|
+
|
|
368
|
+
if (!navigator.mediaDevices) {
|
|
369
|
+
throw new Error('navigator.mediaDevices not present in your browser');
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
if (!navigator.mediaDevices.enumerateDevices) {
|
|
373
|
+
throw new Error('navigator.mediaDevices.enumerateDevices not present in your browser');
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
if (!navigator.mediaDevices.getUserMedia) {
|
|
377
|
+
throw new Error('navigator.mediaDevices.getUserMedia not present in your browser');
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
const devices = await navigator.mediaDevices.enumerateDevices();
|
|
381
|
+
if (!devices.find(device => device.kind === 'videoinput')) {
|
|
382
|
+
throw new Error('No camera found');
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
if (testUserMedia) {
|
|
386
|
+
const stream = await navigator.mediaDevices.getUserMedia({
|
|
387
|
+
audio: false, video: { facingMode: 'environment' }
|
|
388
|
+
});
|
|
389
|
+
if (stream.stop) {
|
|
390
|
+
stream.stop();
|
|
391
|
+
} else {
|
|
392
|
+
stream.getVideoTracks().forEach(track => track.stop());
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
get state() {
|
|
398
|
+
return this._state;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
get hardwareVerticalFov() {
|
|
402
|
+
return this._hardwareVerticalFov;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
set hardwareVerticalFov(hardwareVerticalFov) {
|
|
406
|
+
this._hardwareVerticalFov = hardwareVerticalFov;
|
|
407
|
+
this._computeFov();
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
notifyContainerSizeChanged = () => {
|
|
411
|
+
this._resizeElement();
|
|
412
|
+
this._computeFov();
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
_resizeElement = () => {
|
|
416
|
+
|
|
417
|
+
if (!this.videoElement) {
|
|
418
|
+
throw new Error('No video element found');
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
const sourceWidth = this.videoElement.videoWidth;
|
|
422
|
+
const sourceHeight = this.videoElement.videoHeight;
|
|
423
|
+
|
|
424
|
+
const containerWidth = this.videoContainer.offsetWidth;
|
|
425
|
+
const containerHeight = this.videoContainer.offsetHeight;
|
|
426
|
+
|
|
427
|
+
const sourceAspect = sourceWidth / sourceHeight;
|
|
428
|
+
const screenAspect = containerWidth / containerHeight;
|
|
429
|
+
|
|
430
|
+
if (screenAspect < sourceAspect) {
|
|
431
|
+
|
|
432
|
+
const newWidth = sourceAspect * containerHeight;
|
|
433
|
+
this.videoElement.style.width = newWidth + 'px';
|
|
434
|
+
this.videoElement.style.marginLeft = -(newWidth - containerWidth) / 2 + 'px';
|
|
435
|
+
|
|
436
|
+
this.videoElement.style.height = containerHeight + 'px';
|
|
437
|
+
this.videoElement.style.marginTop = '0px';
|
|
438
|
+
|
|
439
|
+
} else {
|
|
440
|
+
|
|
441
|
+
const newHeight = 1 / (sourceAspect / containerWidth);
|
|
442
|
+
this.videoElement.style.height = newHeight + 'px';
|
|
443
|
+
this.videoElement.style.marginTop = -(newHeight - containerHeight) / 2 + 'px';
|
|
444
|
+
|
|
445
|
+
this.videoElement.style.width = containerWidth + 'px';
|
|
446
|
+
this.videoElement.style.marginLeft = '0px';
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
_computeFov = () => {
|
|
452
|
+
|
|
453
|
+
this.fov = calcDisplayedFov(
|
|
454
|
+
this.videoContainer,
|
|
455
|
+
this.videoElement,
|
|
456
|
+
this._hardwareVerticalFov
|
|
457
|
+
);
|
|
458
|
+
|
|
459
|
+
this.emit('fov.changed', this.fov);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* @returns {Promise<HTMLCanvasElement>}
|
|
464
|
+
*/
|
|
465
|
+
get currentImage() {
|
|
466
|
+
|
|
467
|
+
if (this._state !== Camera.State.STARTED) {
|
|
468
|
+
Logger.warn('Trying to access image but video is not started');
|
|
469
|
+
return null;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
const { videoWidth: width, videoHeight: height } = this.videoElement;
|
|
473
|
+
const canvas = document.createElement('canvas');
|
|
474
|
+
const context = canvas.getContext('2d');
|
|
475
|
+
// context.filter = 'grayscale(100%)';
|
|
476
|
+
|
|
477
|
+
canvas.width = width;
|
|
478
|
+
canvas.height = height;
|
|
479
|
+
|
|
480
|
+
context.drawImage(this.videoElement, 0, 0, width, height);
|
|
481
|
+
return Promise.resolve(canvas);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
/* eslint-disable max-statements */
|
|
486
|
+
|
|
487
|
+
class QrCodeScanner extends EventEmitter {
|
|
488
|
+
|
|
489
|
+
static DEFAULT_FORMATS = [
|
|
490
|
+
BarcodeFormat.QR_CODE,
|
|
491
|
+
BarcodeFormat.DATA_MATRIX,
|
|
492
|
+
BarcodeFormat.CODABAR
|
|
493
|
+
];
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* @type {Camera}
|
|
497
|
+
*/
|
|
498
|
+
_camera;
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* @type {HTMLVideoElement}
|
|
502
|
+
*/
|
|
503
|
+
_videoElement;
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* @type {HTMLCanvasElement}
|
|
507
|
+
*/
|
|
508
|
+
_canvas;
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* @type {CanvasRenderingContext2D}
|
|
512
|
+
*/
|
|
513
|
+
_ctx;
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* @type {MultiFormatReader}
|
|
517
|
+
*/
|
|
518
|
+
_codeReader;
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* @type {number}
|
|
522
|
+
*/
|
|
523
|
+
_intervalTime;
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* @type {number}
|
|
527
|
+
*/
|
|
528
|
+
_intervalTick;
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* @type {boolean}
|
|
532
|
+
*/
|
|
533
|
+
_isStarted = false;
|
|
534
|
+
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* @param {Camera} camera
|
|
538
|
+
*/
|
|
539
|
+
constructor(camera) {
|
|
540
|
+
super();
|
|
541
|
+
|
|
542
|
+
this._camera = camera;
|
|
543
|
+
this._videoElement = camera.videoElement;
|
|
544
|
+
|
|
545
|
+
this._codeReader = new MultiFormatReader();
|
|
546
|
+
|
|
547
|
+
this._canvas = document.createElement('canvas');
|
|
548
|
+
this._ctx = this._canvas.getContext('2d');
|
|
549
|
+
|
|
550
|
+
this._camera.on('started', () => this._tryStart());
|
|
551
|
+
this._camera.on('stopped', () => this._stop());
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
start(intervalTime = 500, formats = QrCodeScanner.DEFAULT_FORMATS) {
|
|
555
|
+
this._intervalTime = intervalTime;
|
|
556
|
+
|
|
557
|
+
if (this._isStarted) {
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
560
|
+
this._isStarted = true;
|
|
561
|
+
|
|
562
|
+
const hints = new Map();
|
|
563
|
+
hints.set(DecodeHintType.POSSIBLE_FORMATS, formats);
|
|
564
|
+
this._codeReader.setHints(hints);
|
|
565
|
+
|
|
566
|
+
this._tryStart();
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
stop() {
|
|
570
|
+
this._isStarted = false;
|
|
571
|
+
this._stop();
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
_tryStart() {
|
|
575
|
+
|
|
576
|
+
if (!this._isStarted || this._camera.state !== Camera.State.STARTED) {
|
|
577
|
+
return;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
this._width = this._videoElement.videoWidth;
|
|
581
|
+
this._height = this._videoElement.videoHeight;
|
|
582
|
+
this._canvas.width = this._width;
|
|
583
|
+
this._canvas.height = this._height;
|
|
584
|
+
this._luminances = new Uint8Array(this._width * this._height);
|
|
585
|
+
|
|
586
|
+
this._intervalTick = setInterval(() => this._onFrame(), this._intervalTime);
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
_stop() {
|
|
590
|
+
clearInterval(this._intervalTick);
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
_onFrame() {
|
|
594
|
+
|
|
595
|
+
if (!this._width || !this._height) {
|
|
596
|
+
return;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
this._ctx.drawImage(this._videoElement, 0, 0, this._width, this._height);
|
|
600
|
+
const img = this._ctx.getImageData(0, 0, this._width, this._height);
|
|
601
|
+
|
|
602
|
+
for (let i = 0; i < this._luminances.length; i++) {
|
|
603
|
+
// eslint-disable-next-line no-bitwise
|
|
604
|
+
this._luminances[i] = ((img.data[i * 4] + img.data[i * 4 + 1] * 2 + img.data[i * 4 + 2]) / 4) & 0xFF;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
const binaryBitmap = new BinaryBitmap(
|
|
608
|
+
new HybridBinarizer(
|
|
609
|
+
new RGBLuminanceSource(this._luminances, this._width, this._height)
|
|
610
|
+
)
|
|
611
|
+
);
|
|
612
|
+
|
|
613
|
+
try {
|
|
614
|
+
const result = this._codeReader.decodeWithState(binaryBitmap);
|
|
615
|
+
this.emit('scan', result.getText());
|
|
616
|
+
} catch (e) {
|
|
617
|
+
// do nothing
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
export { Camera, CameraUtils, QrCodeScanner, SharedCameras$1 as SharedCameras };
|
|
623
|
+
//# sourceMappingURL=wemap-camera.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wemap-camera.es.js","sources":["../src/SharedCameras.js","../src/CameraUtils.js","../src/Camera.js","../src/QrCodeScanner.js"],"sourcesContent":["import EventEmitter from 'events';\n\nimport Camera from './Camera.js';\n\nclass SharedCameras extends EventEmitter {\n\n /**\n * Singleton pattern.\n * @returns {SharedCameras}\n */\n static get instance() {\n if (!this._instance) {\n this._instance = new SharedCameras();\n }\n return this._instance;\n }\n\n /** @type {{container: Node, camera: Camera}[]} */\n _list = [];\n\n /**\n * @param {Camera} camera\n * @param {Node}\n */\n _add(camera, container) {\n const obj = {\n camera,\n container\n };\n this._list.push(obj);\n this.emit('added', obj);\n }\n\n /**\n * @param {Camera} camera\n */\n _remove(camera) {\n this._list = this._list.filter(({ camera: _camera }) => _camera !== camera);\n this.emit('removed', { camera });\n }\n\n /**\n * @returns {{container: Node, camera: Camera}[]}\n */\n get list() {\n return this._list;\n }\n\n /**\n * @param {Node} container\n * @returns {?Camera}\n */\n getCameraByContainer(container) {\n for (const {\n camera, container: _container\n } of this._list) {\n if (container === _container) {\n return camera;\n }\n }\n return null;\n }\n}\n\nexport default SharedCameras.instance;\n","/**\n * @param {number} angle\n * @param {number} aspectRatio\n * @returns {number}\n */\nexport function convertFov(angle, aspectRatio) {\n return 2 * Math.atan(Math.tan((angle / 180 * Math.PI) / 2) * aspectRatio) * 180 / Math.PI;\n}\n\n/**\n * @param {HTMLDivElement} videoContainer\n * @param {HTMLVideoElement} videoElement\n * @param {number} hardwareVerticalFov\n * @returns {object}\n */\nexport function calcDisplayedFov(videoContainer, videoElement, hardwareVerticalFov) {\n\n const sourceWidth = videoElement.videoWidth;\n const sourceHeight = videoElement.videoHeight;\n\n const containerWidth = videoContainer.offsetWidth;\n const containerHeight = videoContainer.offsetHeight;\n\n const sourceAspect = sourceWidth / sourceHeight;\n const screenAspect = containerWidth / containerHeight;\n\n let fovV = hardwareVerticalFov;\n let fovH = convertFov(fovV, sourceAspect);\n\n if (screenAspect < sourceAspect) {\n fovH = convertFov(fovV, screenAspect);\n } else {\n fovV = convertFov(fovH, 1 / screenAspect);\n }\n\n return {\n vertical: fovV,\n horizontal: fovH\n };\n}\n\n/**\n * @param {HTMLCanvasElement} canvas\n * @param {string} type\n * @param {any} quality\n * @returns {string}\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL\n */\nexport function canvasToBase64(canvas, type = 'image/png', quality = null) {\n return canvas\n .toDataURL(type, quality)\n .substring(('data:' + type + ';base64,').length);\n}\n\n/**\n * Creates a pinhole camera from dimensions and a field of view\n * Distortions are not considered\n *\n * @param {number} width the camera width\n * @param {number} height the camera height\n * @param {number} fovOfWidth the field of view along the width axis in radians\n * @returns {object} the calibration matrix\n */\nexport function createCameraCalibrationFromWidthHeightFov(width, height, fovOfWidth) {\n\n const fovOfHeight = 2 * Math.atan(height * Math.tan(fovOfWidth / 2) / width);\n\n const fx = width / (2 * Math.tan(0.5 * fovOfWidth));\n const fy = height / (2 * Math.tan(0.5 * fovOfHeight));\n const cx = width / 2;\n const cy = height / 2;\n\n return {\n intrinsic: [fx, 0, cx, 0, fy, cy, 0, 0, 1],\n distortions: [0, 0, 0, 0, 0]\n };\n}\n\n/**\n * @param {HTMLCanvasElement} imageCanvas\n */\nexport function convertToGrayscale(imageCanvas) {\n const ctx = imageCanvas.getContext('2d');\n const imgData = ctx.getImageData(0, 0, imageCanvas.width, imageCanvas.height);\n const pixels = imgData.data;\n for (let i = 0; i < pixels.length; i += 4) {\n\n const lightness = parseInt((pixels[i] + pixels[i + 1] + pixels[i + 2]) / 3, 10);\n pixels[i] = lightness;\n pixels[i + 1] = lightness;\n pixels[i + 2] = lightness;\n }\n ctx.putImageData(imgData, 0, 0);\n}\n\n/**\n * Reduce image size and keep aspect ratio\n * @param {HTMLCanvasElement} imageCanvas\n */\nexport function reduceImageSize(imageCanvas, maxWidth, maxHeight = null) {\n\n let newWidth = imageCanvas.width;\n let newHeight = imageCanvas.height;\n\n if (maxHeight !== null) {\n if (newWidth > maxWidth) {\n newHeight *= maxWidth / newWidth;\n newWidth = maxWidth;\n }\n\n if (newHeight > maxHeight) {\n newWidth *= maxHeight / newHeight;\n newHeight = maxHeight;\n }\n } else {\n const aspectRatio = imageCanvas.width / imageCanvas.height;\n if (imageCanvas.width > imageCanvas.height) {\n if (imageCanvas.width > maxWidth) {\n newWidth = maxWidth;\n newHeight = maxWidth / aspectRatio;\n }\n } else if (imageCanvas.height > maxWidth) {\n newHeight = maxWidth;\n newWidth = maxWidth * aspectRatio;\n }\n }\n\n\n if (newWidth === imageCanvas.width\n && newHeight === imageCanvas.height) {\n return imageCanvas;\n }\n\n const newCanvas = document.createElement('canvas');\n const newContext = newCanvas.getContext('2d');\n\n newCanvas.width = newWidth;\n newCanvas.height = newHeight;\n newContext.drawImage(imageCanvas, 0, 0, newCanvas.width, newCanvas.height);\n\n return newCanvas;\n}\n\n","import EventEmitter from 'events';\n\nimport Logger from '@wemap/logger';\nimport SharedCameras from './SharedCameras.js';\nimport { calcDisplayedFov } from './CameraUtils.js';\n\n// Helped from https://github.com/jeromeetienne/AR.js/blob/master/three.js/src/threex/threex-artoolkitsource.js\n\n// Camera preview will fill component bounds without transformations.\n// If the component aspect ratio is different from camera aspect ratio,\n// camera preview is extended then cropped.\nclass Camera extends EventEmitter {\n\n static State = {\n STOPPED: 'stopped',\n STARTING: 'starting',\n STARTED: 'started',\n STOPPING: 'stopping'\n }\n\n static DEFAULT_OPTIONS = {\n width: 1024,\n height: 768,\n resizeOnWindowChange: false\n };\n\n static GENERIC_HARDWARE_VERTICAL_FOV = 60;\n\n videoContainer;\n videoElement;\n\n fov = null;\n\n _state = Camera.State.STOPPED;\n\n _hardwareVerticalFov = Camera.GENERIC_HARDWARE_VERTICAL_FOV;\n _resizeOnWindowChange;\n\n /**\n * @param {Node} container\n * @param {{width: number, height: number, resizeOnWindowChange: boolean}} options\n */\n constructor(container, options = {}) {\n super();\n\n options = Object.assign({}, Camera.DEFAULT_OPTIONS, options);\n\n SharedCameras._add(this, container);\n\n this.videoContainer = container;\n\n this._resizeOnWindowChange = options.resizeOnWindowChange;\n this._userMediaConstraints = {\n audio: false,\n video: {\n facingMode: 'environment',\n width: { ideal: options.width },\n height: { ideal: options.height },\n resizeMode: 'none'\n }\n };\n\n this.videoContainer.style.overflow = 'hidden';\n\n this.videoElement = document.createElement('video');\n this.videoElement.setAttribute('id', 'wemap-camera');\n this.videoElement.setAttribute('preload', 'none');\n this.videoElement.setAttribute('muted', '');\n this.videoElement.setAttribute('playsinline', '');\n this.videoContainer.appendChild(this.videoElement);\n }\n\n async start(videoMediaConstraints = null) {\n\n if (this._state !== Camera.State.STOPPED) {\n throw new Error('Camera is already started');\n }\n\n if (this._state === Camera.State.STOPPING) {\n await new Promise(resolve => this.once('stopped', resolve));\n }\n\n this._state = Camera.State.STARTING;\n this.emit('starting');\n\n await Camera.checkAvailability();\n\n if (videoMediaConstraints) {\n Object.assign(this._userMediaConstraints.video,\n this._userMediaConstraints.video, videoMediaConstraints);\n }\n\n const stream = await navigator.mediaDevices.getUserMedia(this._userMediaConstraints);\n\n // Listeners have to be set before srcObject assigment or they can be never called\n this.videoElement.oncanplaythrough = () => this.videoElement.play();\n const metadataPr = new Promise(resolve => (this.videoElement.onloadedmetadata = resolve));\n\n this.videoElement.srcObject = this.videoStream = stream;\n await metadataPr;\n\n this._resizeElement();\n this._computeFov();\n\n if (this._resizeOnWindowChange) {\n window.addEventListener('resize', this.notifyContainerSizeChanged);\n }\n\n this._state = Camera.State.STARTED;\n this.emit('started', {\n videoElement: this.videoElement,\n stream\n });\n }\n\n async stop() {\n\n if (this._state === Camera.State.STOPPED) {\n throw new Error('Camera is already stopped');\n }\n\n if (this._state === Camera.State.STARTING) {\n await new Promise(resolve => this.once('started', resolve));\n }\n\n this._state = Camera.State.STOPPING;\n this.emit('stopping', this);\n\n if (this.videoStream && this.videoStream.stop) {\n // compatibility with old JS API\n this.videoStream.stop();\n } else if (this.videoStream) {\n // new JS API\n this.videoStream.getVideoTracks().forEach(track => track.stop());\n }\n this.videoStream = null;\n this.videoElement.srcObject = null;\n\n if (this._resizeOnWindowChange) {\n window.removeEventListener('resize', this.notifyContainerSizeChanged);\n }\n\n this._state = Camera.State.STOPPED;\n this.emit('stopped', this);\n }\n\n release() {\n this.videoContainer.removeChild(this.videoElement);\n SharedCameras._remove(this);\n }\n\n static async checkAvailability(testUserMedia = false) {\n\n if (!navigator.mediaDevices) {\n throw new Error('navigator.mediaDevices not present in your browser');\n }\n\n if (!navigator.mediaDevices.enumerateDevices) {\n throw new Error('navigator.mediaDevices.enumerateDevices not present in your browser');\n }\n\n if (!navigator.mediaDevices.getUserMedia) {\n throw new Error('navigator.mediaDevices.getUserMedia not present in your browser');\n }\n\n const devices = await navigator.mediaDevices.enumerateDevices();\n if (!devices.find(device => device.kind === 'videoinput')) {\n throw new Error('No camera found');\n }\n\n if (testUserMedia) {\n const stream = await navigator.mediaDevices.getUserMedia({\n audio: false, video: { facingMode: 'environment' }\n });\n if (stream.stop) {\n stream.stop();\n } else {\n stream.getVideoTracks().forEach(track => track.stop());\n }\n }\n }\n\n get state() {\n return this._state;\n }\n\n get hardwareVerticalFov() {\n return this._hardwareVerticalFov;\n }\n\n set hardwareVerticalFov(hardwareVerticalFov) {\n this._hardwareVerticalFov = hardwareVerticalFov;\n this._computeFov();\n }\n\n notifyContainerSizeChanged = () => {\n this._resizeElement();\n this._computeFov();\n }\n\n _resizeElement = () => {\n\n if (!this.videoElement) {\n throw new Error('No video element found');\n }\n\n const sourceWidth = this.videoElement.videoWidth;\n const sourceHeight = this.videoElement.videoHeight;\n\n const containerWidth = this.videoContainer.offsetWidth;\n const containerHeight = this.videoContainer.offsetHeight;\n\n const sourceAspect = sourceWidth / sourceHeight;\n const screenAspect = containerWidth / containerHeight;\n\n if (screenAspect < sourceAspect) {\n\n const newWidth = sourceAspect * containerHeight;\n this.videoElement.style.width = newWidth + 'px';\n this.videoElement.style.marginLeft = -(newWidth - containerWidth) / 2 + 'px';\n\n this.videoElement.style.height = containerHeight + 'px';\n this.videoElement.style.marginTop = '0px';\n\n } else {\n\n const newHeight = 1 / (sourceAspect / containerWidth);\n this.videoElement.style.height = newHeight + 'px';\n this.videoElement.style.marginTop = -(newHeight - containerHeight) / 2 + 'px';\n\n this.videoElement.style.width = containerWidth + 'px';\n this.videoElement.style.marginLeft = '0px';\n }\n\n }\n\n _computeFov = () => {\n\n this.fov = calcDisplayedFov(\n this.videoContainer,\n this.videoElement,\n this._hardwareVerticalFov\n );\n\n this.emit('fov.changed', this.fov);\n }\n\n /**\n * @returns {Promise<HTMLCanvasElement>}\n */\n get currentImage() {\n\n if (this._state !== Camera.State.STARTED) {\n Logger.warn('Trying to access image but video is not started');\n return null;\n }\n\n const { videoWidth: width, videoHeight: height } = this.videoElement;\n const canvas = document.createElement('canvas');\n const context = canvas.getContext('2d');\n // context.filter = 'grayscale(100%)';\n\n canvas.width = width;\n canvas.height = height;\n\n context.drawImage(this.videoElement, 0, 0, width, height);\n return Promise.resolve(canvas);\n }\n}\n\nexport default Camera;\n","/* eslint-disable max-statements */\nimport EventEmitter from 'events';\nimport {\n MultiFormatReader,\n BarcodeFormat,\n DecodeHintType,\n RGBLuminanceSource,\n BinaryBitmap,\n HybridBinarizer\n} from '@zxing/library';\n\nimport Camera from './Camera.js';\n\nclass QrCodeScanner extends EventEmitter {\n\n static DEFAULT_FORMATS = [\n BarcodeFormat.QR_CODE,\n BarcodeFormat.DATA_MATRIX,\n BarcodeFormat.CODABAR\n ];\n\n /**\n * @type {Camera}\n */\n _camera;\n\n /**\n * @type {HTMLVideoElement}\n */\n _videoElement;\n\n /**\n * @type {HTMLCanvasElement}\n */\n _canvas;\n\n /**\n * @type {CanvasRenderingContext2D}\n */\n _ctx;\n\n /**\n * @type {MultiFormatReader}\n */\n _codeReader;\n\n /**\n * @type {number}\n */\n _intervalTime;\n\n /**\n * @type {number}\n */\n _intervalTick;\n\n /**\n * @type {boolean}\n */\n _isStarted = false;\n\n\n /**\n * @param {Camera} camera\n */\n constructor(camera) {\n super();\n\n this._camera = camera;\n this._videoElement = camera.videoElement;\n\n this._codeReader = new MultiFormatReader();\n\n this._canvas = document.createElement('canvas');\n this._ctx = this._canvas.getContext('2d');\n\n this._camera.on('started', () => this._tryStart());\n this._camera.on('stopped', () => this._stop());\n }\n\n start(intervalTime = 500, formats = QrCodeScanner.DEFAULT_FORMATS) {\n this._intervalTime = intervalTime;\n\n if (this._isStarted) {\n return;\n }\n this._isStarted = true;\n\n const hints = new Map();\n hints.set(DecodeHintType.POSSIBLE_FORMATS, formats);\n this._codeReader.setHints(hints);\n\n this._tryStart();\n }\n\n stop() {\n this._isStarted = false;\n this._stop();\n }\n\n _tryStart() {\n\n if (!this._isStarted || this._camera.state !== Camera.State.STARTED) {\n return;\n }\n\n this._width = this._videoElement.videoWidth;\n this._height = this._videoElement.videoHeight;\n this._canvas.width = this._width;\n this._canvas.height = this._height;\n this._luminances = new Uint8Array(this._width * this._height);\n\n this._intervalTick = setInterval(() => this._onFrame(), this._intervalTime);\n }\n\n _stop() {\n clearInterval(this._intervalTick);\n }\n\n _onFrame() {\n\n if (!this._width || !this._height) {\n return;\n }\n\n this._ctx.drawImage(this._videoElement, 0, 0, this._width, this._height);\n const img = this._ctx.getImageData(0, 0, this._width, this._height);\n\n for (let i = 0; i < this._luminances.length; i++) {\n // eslint-disable-next-line no-bitwise\n this._luminances[i] = ((img.data[i * 4] + img.data[i * 4 + 1] * 2 + img.data[i * 4 + 2]) / 4) & 0xFF;\n }\n\n const binaryBitmap = new BinaryBitmap(\n new HybridBinarizer(\n new RGBLuminanceSource(this._luminances, this._width, this._height)\n )\n );\n\n try {\n const result = this._codeReader.decodeWithState(binaryBitmap);\n this.emit('scan', result.getText());\n } catch (e) {\n // do nothing\n }\n }\n}\n\nexport default QrCodeScanner;\n"],"names":["SharedCameras"],"mappings":";;;;;AAIA,MAAM,aAAa,SAAS,YAAY,CAAC;AACzC;AACA;AACA;AACA;AACA;AACA,IAAI,WAAW,QAAQ,GAAG;AAC1B,QAAQ,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;AAC7B,YAAY,IAAI,CAAC,SAAS,GAAG,IAAI,aAAa,EAAE,CAAC;AACjD,SAAS;AACT,QAAQ,OAAO,IAAI,CAAC,SAAS,CAAC;AAC9B,KAAK;AACL;AACA;AACA,IAAI,KAAK,GAAG,EAAE;AACd;AACA;AACA;AACA;AACA;AACA,IAAI,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE;AAC5B,QAAQ,MAAM,GAAG,GAAG;AACpB,YAAY,MAAM;AAClB,YAAY,SAAS;AACrB,SAAS,CAAC;AACV,QAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7B,QAAQ,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;AAChC,KAAK;AACL;AACA;AACA;AACA;AACA,IAAI,OAAO,CAAC,MAAM,EAAE;AACpB,QAAQ,IAAI,CAAC,K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AI,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;AACjH,SAAS;AACT;AACA,QAAQ,MAAM,YAAY,GAAG,IAAI,YAAY;AAC7C,YAAY,IAAI,eAAe;AAC/B,gBAAgB,IAAI,kBAAkB,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC;AACnF,aAAa;AACb,SAAS,CAAC;AACV;AACA,QAAQ,IAAI;AACZ,YAAY,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;AAC1E,YAAY,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;AAChD,SAAS,CAAC,OAAO,CAAC,EAAE;AACpB;AACA,SAAS;AACT,KAAK;AACL;;;;"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare module '@wemap/camera' {
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export type IntrinsicParams = [number, number, number, number, number, number, number, number, number];
|
|
5
|
+
export type DistortionsParams = [number, number, number, number, number];
|
|
6
|
+
|
|
7
|
+
export type Calibration = {
|
|
8
|
+
intrinsic: IntrinsicParams,
|
|
9
|
+
distortions?: DistortionsParams
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export class CameraUtils {
|
|
13
|
+
static createCameraCalibrationFromWidthHeightFov(width: number, height: number, fovOfWidth: number): Calibration;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
}
|
package/package.json
CHANGED
|
@@ -5,13 +5,14 @@
|
|
|
5
5
|
],
|
|
6
6
|
"description": "Wemap Camera utils package",
|
|
7
7
|
"main": "index.js",
|
|
8
|
+
"types": "index.d.ts",
|
|
8
9
|
"repository": {
|
|
9
10
|
"type": "git",
|
|
10
11
|
"url": "git+https://github.com/wemap/wemap-modules-js.git",
|
|
11
12
|
"directory": "packages/camera"
|
|
12
13
|
},
|
|
13
14
|
"name": "@wemap/camera",
|
|
14
|
-
"version": "8.0.1",
|
|
15
|
+
"version": "8.1.0-alpha.1",
|
|
15
16
|
"bugs": {
|
|
16
17
|
"url": "https://github.com/wemap/wemap-modules-js/issues"
|
|
17
18
|
},
|
|
@@ -28,5 +29,5 @@
|
|
|
28
29
|
"events": "^3.3.0"
|
|
29
30
|
},
|
|
30
31
|
"type": "module",
|
|
31
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "8a3bf5d4765173c410228b9aa3e69a24fe0aec66"
|
|
32
33
|
}
|