@wemap/providers 14.3.1 → 14.5.0
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/index.js +132 -81
- package/dist/src/providers/vision/vps/ImageRelocalization.d.ts +3 -3
- package/dist/src/providers/vision/vps/ImageRelocalization.d.ts.map +1 -1
- package/dist/src/providers/vision/vps/VpsBackgroundScanner.d.ts +3 -0
- package/dist/src/providers/vision/vps/VpsBackgroundScanner.d.ts.map +1 -1
- package/dist/src/providers/vision/vps/VpsProvider.d.ts +18 -2
- package/dist/src/providers/vision/vps/VpsProvider.d.ts.map +1 -1
- package/dist/src/providers/vision/vps/VpsRequest.d.ts +9 -1
- package/dist/src/providers/vision/vps/VpsRequest.d.ts.map +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -3052,7 +3052,7 @@ var field = function(e, C, w) {
|
|
|
3052
3052
|
}
|
|
3053
3053
|
}(), package_default = {
|
|
3054
3054
|
name: "@wemap/providers",
|
|
3055
|
-
version: "14.
|
|
3055
|
+
version: "14.4.0",
|
|
3056
3056
|
type: "module",
|
|
3057
3057
|
publishConfig: { access: "public" },
|
|
3058
3058
|
main: "./dist/index.js",
|
|
@@ -3063,12 +3063,12 @@ var field = function(e, C, w) {
|
|
|
3063
3063
|
} },
|
|
3064
3064
|
files: ["dist"],
|
|
3065
3065
|
dependencies: {
|
|
3066
|
-
"@wemap/camera": "14.
|
|
3067
|
-
"@wemap/core": "14.
|
|
3068
|
-
"@wemap/geo": "14.
|
|
3069
|
-
"@wemap/osm": "14.
|
|
3070
|
-
"@wemap/routers": "14.
|
|
3071
|
-
"@wemap/utils": "14.
|
|
3066
|
+
"@wemap/camera": "14.4.0",
|
|
3067
|
+
"@wemap/core": "14.4.0",
|
|
3068
|
+
"@wemap/geo": "14.4.0",
|
|
3069
|
+
"@wemap/osm": "14.4.0",
|
|
3070
|
+
"@wemap/routers": "14.4.0",
|
|
3071
|
+
"@wemap/utils": "14.4.0"
|
|
3072
3072
|
},
|
|
3073
3073
|
devDependencies: {
|
|
3074
3074
|
"@wemap/logger-legacy": "^13.3.0",
|
|
@@ -3169,18 +3169,29 @@ var field = function(e, C, w) {
|
|
|
3169
3169
|
}, VpsRequest_default = class e {
|
|
3170
3170
|
metadata;
|
|
3171
3171
|
image;
|
|
3172
|
-
|
|
3173
|
-
|
|
3172
|
+
imageQuality;
|
|
3173
|
+
localPose;
|
|
3174
|
+
constructor(e, C, w = .8, T = null) {
|
|
3175
|
+
this.metadata = e, this.image = C, this.imageQuality = w, this.localPose = T;
|
|
3174
3176
|
}
|
|
3175
3177
|
toJson() {
|
|
3176
3178
|
return {
|
|
3177
|
-
image: canvasToBase64(this.image, "image/jpeg"),
|
|
3179
|
+
image: canvasToBase64(this.image, "image/jpeg", this.imageQuality),
|
|
3180
|
+
...this.localPose && { local_pose: this.localPose },
|
|
3178
3181
|
...this.metadata.toJson()
|
|
3179
3182
|
};
|
|
3180
3183
|
}
|
|
3181
3184
|
static fromJson(C) {
|
|
3182
3185
|
return new e(VpsMetadata_default.fromJson(C), base64ToCanvas(C.image));
|
|
3183
3186
|
}
|
|
3187
|
+
toFormData() {
|
|
3188
|
+
let e = this.image.toDataURL("image/jpeg", this.imageQuality).split(",")[1] || "", C = atob(e), w = new Uint8Array(C.length);
|
|
3189
|
+
for (let e = 0; e < C.length; e++) w[e] = C.charCodeAt(e);
|
|
3190
|
+
let T = new FormData();
|
|
3191
|
+
T.append("image", new Blob([w], { type: "image/jpeg" }), "image.jpg");
|
|
3192
|
+
let E = this.metadata.toJson();
|
|
3193
|
+
return E.calibration && T.append("calibration", JSON.stringify(E.calibration)), E.coarse && T.append("coarse", JSON.stringify(E.coarse)), E.device && T.append("device", JSON.stringify(E.device)), this.localPose && T.append("local_pose", JSON.stringify(this.localPose)), T;
|
|
3194
|
+
}
|
|
3184
3195
|
}, VpsResponse_default = class e {
|
|
3185
3196
|
success;
|
|
3186
3197
|
attitude;
|
|
@@ -3202,31 +3213,28 @@ var field = function(e, C, w) {
|
|
|
3202
3213
|
return w.position && (D = UserPosition.fromJson(w.position), D.time = T), new e(w.success, E, D);
|
|
3203
3214
|
}
|
|
3204
3215
|
}, ImageRelocalization_default = class {
|
|
3205
|
-
static _prepareRequest(e, C = null, w = null, T = null) {
|
|
3206
|
-
let
|
|
3207
|
-
return T && (
|
|
3208
|
-
width:
|
|
3209
|
-
height:
|
|
3210
|
-
}, C, w,
|
|
3211
|
-
}
|
|
3212
|
-
static async relocalize(e, C, w = null, T = null, E = null, D = null) {
|
|
3213
|
-
let
|
|
3216
|
+
static _prepareRequest(e, C = null, w = null, T = null, E = null) {
|
|
3217
|
+
let D = reduceImageSize(e, 720, 720), O = UserAgentUtils.getDeviceFromUserAgent() || {};
|
|
3218
|
+
return T && (O.session_id = T.session_id, O.installation_id = T.installation_id, O.attempt_id = T.attempt_id, O.caller = T.caller), new VpsRequest_default(new VpsMetadata_default({
|
|
3219
|
+
width: D.width,
|
|
3220
|
+
height: D.height
|
|
3221
|
+
}, C, w, O), D, .8, E);
|
|
3222
|
+
}
|
|
3223
|
+
static async relocalize(e, C, w = null, T = null, E = null, D = null, O = null) {
|
|
3224
|
+
let k = TimeUtils.preciseTime() / 1e3, A = this._prepareRequest(C, w, T, E, D), j;
|
|
3214
3225
|
try {
|
|
3215
|
-
let C =
|
|
3216
|
-
|
|
3226
|
+
let C = A.toFormData();
|
|
3227
|
+
j = await fetch(e, {
|
|
3217
3228
|
method: "POST",
|
|
3218
3229
|
body: C,
|
|
3219
|
-
headers: Object.assign({
|
|
3220
|
-
"Content-Type": "application/json",
|
|
3221
|
-
Accept: "application/vnd.geopose+json; version=1"
|
|
3222
|
-
}, D || {})
|
|
3230
|
+
headers: Object.assign({ Accept: "application/vnd.geopose+json; version=1" }, O || {})
|
|
3223
3231
|
});
|
|
3224
3232
|
} catch {
|
|
3225
3233
|
return Logger.debug("[VPS] Server respond error"), null;
|
|
3226
3234
|
}
|
|
3227
|
-
if (
|
|
3228
|
-
let
|
|
3229
|
-
return Logger.debug(`[VPS] Server respond ${
|
|
3235
|
+
if (j.status !== 200) return Logger.debug("[VPS] Server respond error"), null;
|
|
3236
|
+
let M = await j.json(), F = VpsResponse_default.fromJson(M, k);
|
|
3237
|
+
return Logger.debug(`[VPS] Server respond ${F.success ? "success" : "not found"}`), F;
|
|
3230
3238
|
}
|
|
3231
3239
|
static getHeadingFromQuaternion(e) {
|
|
3232
3240
|
let [C, w, T, E] = e, D = Math.sqrt(2) / 2, O = [
|
|
@@ -3237,7 +3245,35 @@ var field = function(e, C, w) {
|
|
|
3237
3245
|
];
|
|
3238
3246
|
return -Math.atan2(2 * O[3] * O[0] - 2 * O[2] * O[1], 1 - 2 * O[1] ** 2 - 2 * O[3] ** 2);
|
|
3239
3247
|
}
|
|
3240
|
-
},
|
|
3248
|
+
}, RelativeAttitudeProvider_default = new class extends Provider_default {
|
|
3249
|
+
arCoreMonitoringId;
|
|
3250
|
+
arCoreProviderId;
|
|
3251
|
+
inertialProviderId;
|
|
3252
|
+
getName = () => "RelativeAttitude";
|
|
3253
|
+
availability = () => RelativeAttitudeFromInertialProvider_default.getAvailability();
|
|
3254
|
+
start() {
|
|
3255
|
+
this.arCoreMonitoringId = ArCoreProvider_default.addMonitoringListener(() => {
|
|
3256
|
+
this.listenArCore(), this.unlistenInertial();
|
|
3257
|
+
}, () => {
|
|
3258
|
+
this.unlistenArCore(), this.listenInertial();
|
|
3259
|
+
}), ArCoreProvider_default.state === "started" ? this.listenArCore() : this.listenInertial();
|
|
3260
|
+
}
|
|
3261
|
+
stop() {
|
|
3262
|
+
ArCoreProvider_default.removeMonitoringListener(this.arCoreMonitoringId), this.unlistenArCore(), this.unlistenInertial();
|
|
3263
|
+
}
|
|
3264
|
+
listenInertial = () => {
|
|
3265
|
+
this.inertialProviderId = RelativeAttitudeFromInertialProvider_default.addEventListener(this.notify, this.notifyError);
|
|
3266
|
+
};
|
|
3267
|
+
unlistenInertial = () => {
|
|
3268
|
+
RelativeAttitudeFromInertialProvider_default.removeEventListener(this.inertialProviderId);
|
|
3269
|
+
};
|
|
3270
|
+
listenArCore = () => {
|
|
3271
|
+
this.arCoreProviderId = ArCoreProvider_default.addEventListener((e) => this.notify(e.relativeAttitude), null, !1);
|
|
3272
|
+
};
|
|
3273
|
+
unlistenArCore = () => {
|
|
3274
|
+
ArCoreProvider_default.removeEventListener(this.arCoreProviderId);
|
|
3275
|
+
};
|
|
3276
|
+
}(), RelativeRotationCalc = class {
|
|
3241
3277
|
_providerId;
|
|
3242
3278
|
_isRunning = !1;
|
|
3243
3279
|
_dataOnStart = null;
|
|
@@ -3310,6 +3346,12 @@ var field = function(e, C, w) {
|
|
|
3310
3346
|
0,
|
|
3311
3347
|
0
|
|
3312
3348
|
], Math.PI);
|
|
3349
|
+
static ENU_TO_ARCORE_ROT = Quaternion.fromAxisAngle([
|
|
3350
|
+
1,
|
|
3351
|
+
0,
|
|
3352
|
+
0
|
|
3353
|
+
], -Math.PI / 2);
|
|
3354
|
+
static _scanFailureCallbackUniqueId = 0;
|
|
3313
3355
|
_relativeRotationCalc;
|
|
3314
3356
|
_serverError = !1;
|
|
3315
3357
|
_cameraError = !1;
|
|
@@ -3320,8 +3362,13 @@ var field = function(e, C, w) {
|
|
|
3320
3362
|
_waitTimeMinInclinationForRequest = e.DEFAULT_WAIT_TIME_MIN_INCLINATION_FOR_REQUEST;
|
|
3321
3363
|
_useCoarsePose = e.DEFAULT_USE_COARSE_POSE;
|
|
3322
3364
|
_requestCaller = e.DEFAULT_REQUEST_CALLER;
|
|
3323
|
-
|
|
3324
|
-
|
|
3365
|
+
_sessionId;
|
|
3366
|
+
_attemptIdCounter = 0;
|
|
3367
|
+
_currentAttemptId = null;
|
|
3368
|
+
_scanFailureCallbacks = [];
|
|
3369
|
+
constructor() {
|
|
3370
|
+
super(), this._sessionId = this._generateUuid();
|
|
3371
|
+
}
|
|
3325
3372
|
getName = () => "Vps";
|
|
3326
3373
|
availability = () => Camera.checkAvailability();
|
|
3327
3374
|
start() {
|
|
@@ -3363,29 +3410,43 @@ var field = function(e, C, w) {
|
|
|
3363
3410
|
this._useCoarsePose && (k || AbsoluteAttitudeProvider_default.lastEvent) && (O = {
|
|
3364
3411
|
...k && { position: k },
|
|
3365
3412
|
...AbsoluteAttitudeProvider_default.lastEvent && { attitude: AbsoluteAttitudeProvider_default.lastEvent }
|
|
3366
|
-
}), this.
|
|
3367
|
-
let A =
|
|
3368
|
-
|
|
3413
|
+
}), this._currentAttemptId === null && (this._attemptIdCounter += 1, this._currentAttemptId = this._attemptIdCounter);
|
|
3414
|
+
let A = RelativeAttitudeProvider_default.lastEvent, j = GeoRelativePositionProvider_default.lastEvent, M = A && j ? {
|
|
3415
|
+
position: Quaternion.rotate(e.ENU_TO_ARCORE_ROT, [
|
|
3416
|
+
j.x,
|
|
3417
|
+
j.y,
|
|
3418
|
+
j.z
|
|
3419
|
+
]),
|
|
3420
|
+
orientation: Quaternion.multiply(e.ENU_TO_ARCORE_ROT, A.quaternion)
|
|
3421
|
+
} : null, F = await ImageRelocalization_default.relocalize(this._endpoint, D, null, O, {
|
|
3422
|
+
session_id: this._sessionId,
|
|
3369
3423
|
installation_id: null,
|
|
3370
|
-
attempt_id: this.
|
|
3424
|
+
...this._currentAttemptId !== null && { attempt_id: this._currentAttemptId },
|
|
3371
3425
|
caller: this._requestCaller
|
|
3372
|
-
});
|
|
3373
|
-
if (!
|
|
3374
|
-
|
|
3375
|
-
|
|
3426
|
+
}, M);
|
|
3427
|
+
if (!F || !F.success) {
|
|
3428
|
+
this._scanFailureCallbacks.forEach(({ id: e, callback: C }) => C({
|
|
3429
|
+
listenerId: e,
|
|
3430
|
+
sessionId: this._sessionId,
|
|
3431
|
+
attemptId: this._currentAttemptId
|
|
3432
|
+
}));
|
|
3433
|
+
continue;
|
|
3434
|
+
}
|
|
3435
|
+
this._currentAttemptId = null;
|
|
3436
|
+
let I = F.attitude.quaternion, L = Quaternion.multiply(I, e.CAMERA_TO_SMARTPHONE_ROT), R = Quaternion.multiply(Quaternion.fromAxisAngle([
|
|
3376
3437
|
0,
|
|
3377
3438
|
0,
|
|
3378
3439
|
1
|
|
3379
|
-
], deg2rad(window.orientation || 0)),
|
|
3440
|
+
], deg2rad(window.orientation || 0)), L), z = this._relativeRotationCalc?.tickEnd() || new Attitude([
|
|
3380
3441
|
1,
|
|
3381
3442
|
0,
|
|
3382
3443
|
0,
|
|
3383
3444
|
0
|
|
3384
|
-
]),
|
|
3385
|
-
if (
|
|
3445
|
+
]), B = new AbsoluteAttitude(Quaternion.multiply(R, z.quaternion), F.attitude.time, F.attitude.accuracy), V = F.position.clone();
|
|
3446
|
+
if (V.accuracy === null && (V.accuracy = 5), T()) break;
|
|
3386
3447
|
this.notify({
|
|
3387
|
-
absoluteAttitude:
|
|
3388
|
-
absolutePosition:
|
|
3448
|
+
absoluteAttitude: B,
|
|
3449
|
+
absolutePosition: V
|
|
3389
3450
|
});
|
|
3390
3451
|
}
|
|
3391
3452
|
};
|
|
@@ -3396,6 +3457,19 @@ var field = function(e, C, w) {
|
|
|
3396
3457
|
return (e === "x" ? C : C & 3 | 8).toString(16);
|
|
3397
3458
|
});
|
|
3398
3459
|
}
|
|
3460
|
+
addScanFailureListener(C) {
|
|
3461
|
+
let w = ++e._scanFailureCallbackUniqueId;
|
|
3462
|
+
return this._scanFailureCallbacks.push({
|
|
3463
|
+
id: w,
|
|
3464
|
+
callback: C
|
|
3465
|
+
}), w;
|
|
3466
|
+
}
|
|
3467
|
+
removeScanFailureListener(e) {
|
|
3468
|
+
this._scanFailureCallbacks = this._scanFailureCallbacks.filter(({ id: C }) => C !== e);
|
|
3469
|
+
}
|
|
3470
|
+
resetCurrentAttempt() {
|
|
3471
|
+
this._currentAttemptId = null;
|
|
3472
|
+
}
|
|
3399
3473
|
get endpoint() {
|
|
3400
3474
|
return this._endpoint;
|
|
3401
3475
|
}
|
|
@@ -3606,34 +3680,6 @@ var field = function(e, C, w) {
|
|
|
3606
3680
|
let T = deg2rad(e), E = deg2rad(C), D = deg2rad(w), O = Math.cos(T / 2), k = Math.cos(E / 2), A = Math.cos(D / 2), j = Math.sin(T / 2), M = Math.sin(E / 2), N = Math.sin(D / 2), F = O * k * A - j * M * N, I = j * k * A + O * M * N;
|
|
3607
3681
|
return rad2deg(-2 * Math.atan(I / F));
|
|
3608
3682
|
}
|
|
3609
|
-
}(), RelativeAttitudeProvider_default = new class extends Provider_default {
|
|
3610
|
-
arCoreMonitoringId;
|
|
3611
|
-
arCoreProviderId;
|
|
3612
|
-
inertialProviderId;
|
|
3613
|
-
getName = () => "RelativeAttitude";
|
|
3614
|
-
availability = () => RelativeAttitudeFromInertialProvider_default.getAvailability();
|
|
3615
|
-
start() {
|
|
3616
|
-
this.arCoreMonitoringId = ArCoreProvider_default.addMonitoringListener(() => {
|
|
3617
|
-
this.listenArCore(), this.unlistenInertial();
|
|
3618
|
-
}, () => {
|
|
3619
|
-
this.unlistenArCore(), this.listenInertial();
|
|
3620
|
-
}), ArCoreProvider_default.state === "started" ? this.listenArCore() : this.listenInertial();
|
|
3621
|
-
}
|
|
3622
|
-
stop() {
|
|
3623
|
-
ArCoreProvider_default.removeMonitoringListener(this.arCoreMonitoringId), this.unlistenArCore(), this.unlistenInertial();
|
|
3624
|
-
}
|
|
3625
|
-
listenInertial = () => {
|
|
3626
|
-
this.inertialProviderId = RelativeAttitudeFromInertialProvider_default.addEventListener(this.notify, this.notifyError);
|
|
3627
|
-
};
|
|
3628
|
-
unlistenInertial = () => {
|
|
3629
|
-
RelativeAttitudeFromInertialProvider_default.removeEventListener(this.inertialProviderId);
|
|
3630
|
-
};
|
|
3631
|
-
listenArCore = () => {
|
|
3632
|
-
this.arCoreProviderId = ArCoreProvider_default.addEventListener((e) => this.notify(e.relativeAttitude), null, !1);
|
|
3633
|
-
};
|
|
3634
|
-
unlistenArCore = () => {
|
|
3635
|
-
ArCoreProvider_default.removeEventListener(this.arCoreProviderId);
|
|
3636
|
-
};
|
|
3637
3683
|
}(), AbsoluteAttitudeProvider_default = new class w extends Provider_default {
|
|
3638
3684
|
static REL_ABS_DIVERGENCE_ANGLE_THRESHOLD = deg2rad(25);
|
|
3639
3685
|
static REL_ABS_DIVERGENCE_TIME_THRESHOLD = 2.5;
|
|
@@ -4108,12 +4154,15 @@ var field = function(e, C, w) {
|
|
|
4108
4154
|
this.notify(T);
|
|
4109
4155
|
}
|
|
4110
4156
|
stop() {}
|
|
4111
|
-
}(), VpsBackgroundScanner = class {
|
|
4157
|
+
}(), VpsBackgroundScanner = class e {
|
|
4158
|
+
static MAX_CONSECUTIVE_FAILURES = 10;
|
|
4112
4159
|
intervalMs;
|
|
4113
4160
|
enabled;
|
|
4114
4161
|
timeoutId = null;
|
|
4115
4162
|
listenerId = null;
|
|
4163
|
+
scanFailureListenerId = null;
|
|
4116
4164
|
isBackgroundScanRunning = !1;
|
|
4165
|
+
consecutiveFailures = 0;
|
|
4117
4166
|
_status;
|
|
4118
4167
|
statusCallbacks = /* @__PURE__ */ new Set();
|
|
4119
4168
|
onResult;
|
|
@@ -4141,10 +4190,10 @@ var field = function(e, C, w) {
|
|
|
4141
4190
|
}, this.intervalMs), this.setStatus("scheduled"));
|
|
4142
4191
|
}
|
|
4143
4192
|
async cancelRunningScan() {
|
|
4144
|
-
this.isBackgroundScanRunning && (this.listenerId !== null && (VpsProvider_default.removeEventListener(this.listenerId), this.listenerId = null, VpsProvider_default.stop()), this.isBackgroundScanRunning = !1, this.setStatus(this.enabled ? "idle" : "disabled"));
|
|
4193
|
+
this.isBackgroundScanRunning && (this.listenerId !== null && (VpsProvider_default.removeEventListener(this.listenerId), this.listenerId = null, VpsProvider_default.stop()), this.scanFailureListenerId !== null && (VpsProvider_default.removeScanFailureListener(this.scanFailureListenerId), this.scanFailureListenerId = null), this.isBackgroundScanRunning = !1, this.setStatus(this.enabled ? "idle" : "disabled"));
|
|
4145
4194
|
}
|
|
4146
4195
|
clear() {
|
|
4147
|
-
this.clearTimeoutOnly(), this.listenerId !== null && (VpsProvider_default.removeEventListener(this.listenerId), this.listenerId = null), this.isBackgroundScanRunning = !1, this.setStatus(this.enabled ? "idle" : "disabled");
|
|
4196
|
+
this.clearTimeoutOnly(), this.listenerId !== null && (VpsProvider_default.removeEventListener(this.listenerId), this.listenerId = null), this.scanFailureListenerId !== null && (VpsProvider_default.removeScanFailureListener(this.scanFailureListenerId), this.scanFailureListenerId = null), this.isBackgroundScanRunning = !1, this.setStatus(this.enabled ? "idle" : "disabled");
|
|
4148
4197
|
}
|
|
4149
4198
|
runNow() {
|
|
4150
4199
|
this.enabled && (this.clearTimeoutOnly(), this.startBackgroundScan());
|
|
@@ -4154,19 +4203,21 @@ var field = function(e, C, w) {
|
|
|
4154
4203
|
}
|
|
4155
4204
|
async startBackgroundScan() {
|
|
4156
4205
|
if (!this.enabled || this.isBackgroundScanRunning || this.listenerId !== null) return;
|
|
4157
|
-
let
|
|
4158
|
-
if (
|
|
4159
|
-
this.onError(
|
|
4206
|
+
let C = await VpsProvider_default.getAvailability();
|
|
4207
|
+
if (C instanceof Error) {
|
|
4208
|
+
this.onError(C), this.setStatus("idle");
|
|
4160
4209
|
return;
|
|
4161
4210
|
}
|
|
4162
|
-
this.isBackgroundScanRunning = !0, this.setStatus("scanning"), this.
|
|
4163
|
-
this.
|
|
4211
|
+
this.isBackgroundScanRunning = !0, this.setStatus("scanning"), this.scanFailureListenerId = VpsProvider_default.addScanFailureListener((C) => {
|
|
4212
|
+
!this.isBackgroundScanRunning || this.scanFailureListenerId === null || C.listenerId !== this.scanFailureListenerId || (this.consecutiveFailures += 1, this.consecutiveFailures >= e.MAX_CONSECUTIVE_FAILURES && (this.consecutiveFailures = 0, VpsProvider_default.resetCurrentAttempt(), this.cleanupListener(), this.schedule()));
|
|
4213
|
+
}), this.listenerId = VpsProvider_default.addEventListener((e) => {
|
|
4214
|
+
this.consecutiveFailures = 0, this.cleanupListener(), this.onResult(e), this.schedule();
|
|
4164
4215
|
}, (e) => {
|
|
4165
4216
|
this.cleanupListener(), this.onError(e), this.schedule();
|
|
4166
4217
|
});
|
|
4167
4218
|
}
|
|
4168
4219
|
cleanupListener() {
|
|
4169
|
-
this.listenerId !== null && (VpsProvider_default.removeEventListener(this.listenerId), this.listenerId = null), VpsProvider_default.stop(), this.isBackgroundScanRunning = !1, this.enabled ? this.setStatus("idle") : this.setStatus("disabled");
|
|
4220
|
+
this.listenerId !== null && (VpsProvider_default.removeEventListener(this.listenerId), this.listenerId = null), this.scanFailureListenerId !== null && (VpsProvider_default.removeScanFailureListener(this.scanFailureListenerId), this.scanFailureListenerId = null), VpsProvider_default.stop(), this.isBackgroundScanRunning = !1, this.enabled ? this.setStatus("idle") : this.setStatus("disabled");
|
|
4170
4221
|
}
|
|
4171
4222
|
setStatus(e) {
|
|
4172
4223
|
this._status !== e && (this._status = e, this.statusCallbacks.forEach((C) => {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Calibration } from '../../../../../camera';
|
|
2
2
|
import { Quaternion_t } from '@wemap/maths-legacy';
|
|
3
3
|
import { CoarsePose, VpsDeviceMetadata } from './VpsMetadata';
|
|
4
|
-
import { default as VpsRequest } from './VpsRequest';
|
|
4
|
+
import { default as VpsRequest, LocalPose } from './VpsRequest';
|
|
5
5
|
import { default as VpsResponse } from './VpsResponse';
|
|
6
6
|
declare class ImageRelocalization {
|
|
7
|
-
static _prepareRequest(imageCanvas: HTMLCanvasElement, calibration?: Calibration | null, coarsePose?: CoarsePose | null, deviceMetadata?: Pick<VpsDeviceMetadata, 'session_id' | 'installation_id' | 'attempt_id' | 'caller'> | null): VpsRequest;
|
|
8
|
-
static relocalize(endpointUrl: string, imageCanvas: HTMLCanvasElement, calibration?: Calibration | null, coarsePose?: CoarsePose | null, deviceMetadata?: Pick<VpsDeviceMetadata, 'session_id' | 'installation_id' | 'attempt_id' | 'caller'> | null, customHeaders?: Record<string, string> | null): Promise<VpsResponse | null>;
|
|
7
|
+
static _prepareRequest(imageCanvas: HTMLCanvasElement, calibration?: Calibration | null, coarsePose?: CoarsePose | null, deviceMetadata?: Pick<VpsDeviceMetadata, 'session_id' | 'installation_id' | 'attempt_id' | 'caller'> | null, localPose?: LocalPose | null): VpsRequest;
|
|
8
|
+
static relocalize(endpointUrl: string, imageCanvas: HTMLCanvasElement, calibration?: Calibration | null, coarsePose?: CoarsePose | null, deviceMetadata?: Pick<VpsDeviceMetadata, 'session_id' | 'installation_id' | 'attempt_id' | 'caller'> | null, localPose?: LocalPose | null, customHeaders?: Record<string, string> | null): Promise<VpsResponse | null>;
|
|
9
9
|
static getHeadingFromQuaternion(quaternion: Quaternion_t): number;
|
|
10
10
|
}
|
|
11
11
|
export default ImageRelocalization;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageRelocalization.d.ts","sourceRoot":"","sources":["../../../../../src/providers/vision/vps/ImageRelocalization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAmB,MAAM,eAAe,CAAC;AAElE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAoB,EAAE,KAAK,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAErF,OAAO,UAAU,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"ImageRelocalization.d.ts","sourceRoot":"","sources":["../../../../../src/providers/vision/vps/ImageRelocalization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAmB,MAAM,eAAe,CAAC;AAElE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAoB,EAAE,KAAK,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAErF,OAAO,UAAU,EAAE,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,WAAW,MAAM,eAAe,CAAC;AAExC,cAAM,mBAAmB;IAErB,MAAM,CAAC,eAAe,CAClB,WAAW,EAAE,iBAAiB,EAC9B,WAAW,GAAE,WAAW,GAAG,IAAW,EACtC,UAAU,GAAE,UAAU,GAAG,IAAW,EACpC,cAAc,GAAE,IAAI,CAAC,iBAAiB,EAAE,YAAY,GAAG,iBAAiB,GAAG,YAAY,GAAG,QAAQ,CAAC,GAAG,IAAW,EACjH,SAAS,GAAE,SAAS,GAAG,IAAW;WAuBzB,UAAU,CACnB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,iBAAiB,EAC9B,WAAW,GAAE,WAAW,GAAG,IAAW,EACtC,UAAU,GAAE,UAAU,GAAG,IAAW,EACpC,cAAc,GAAE,IAAI,CAAC,iBAAiB,EAAE,YAAY,GAAG,iBAAiB,GAAG,YAAY,GAAG,QAAQ,CAAC,GAAG,IAAW,EACjH,SAAS,GAAE,SAAS,GAAG,IAAW,EAClC,aAAa,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAW;IA6CvD,MAAM,CAAC,wBAAwB,CAAC,UAAU,EAAE,YAAY;CAmB3D;AAED,eAAe,mBAAmB,CAAC"}
|
|
@@ -37,11 +37,14 @@ export interface VpsBackgroundScanOptions {
|
|
|
37
37
|
* the same provider, use {@link cancelRunningScan} first to avoid conflicts.
|
|
38
38
|
*/
|
|
39
39
|
export declare class VpsBackgroundScanner {
|
|
40
|
+
private static readonly MAX_CONSECUTIVE_FAILURES;
|
|
40
41
|
private readonly intervalMs;
|
|
41
42
|
private enabled;
|
|
42
43
|
private timeoutId;
|
|
43
44
|
private listenerId;
|
|
45
|
+
private scanFailureListenerId;
|
|
44
46
|
private isBackgroundScanRunning;
|
|
47
|
+
private consecutiveFailures;
|
|
45
48
|
private _status;
|
|
46
49
|
private statusCallbacks;
|
|
47
50
|
private readonly onResult;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VpsBackgroundScanner.d.ts","sourceRoot":"","sources":["../../../../../src/providers/vision/vps/VpsBackgroundScanner.ts"],"names":[],"mappings":"AAAA,OAAoB,EAAE,KAAK,QA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MAAM,EAAE,uBAAuB,KAAK,IAAI,GAAG,MAAM,IAAI;IAO/E;;OAEG;IACH,eAAe,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,uBAAuB,KAAK,IAAI,GAAG,IAAI;IAI1E;;;OAGG;IACH,QAAQ,IAAI,IAAI;IAYhB;;;;;OAKG;IACG,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAmBxC;;OAEG;IACH,KAAK,IAAI,IAAI;IAcb;;;;;OAKG;IACH,MAAM,IAAI,IAAI;IAQd,OAAO,CAAC,gBAAgB;YAUV,mBAAmB;IA8CjC,OAAO,CAAC,eAAe;IAkBvB,OAAO,CAAC,SAAS;CAclB"}
|
|
@@ -6,6 +6,11 @@ export type VpsEvent = {
|
|
|
6
6
|
absoluteAttitude: AbsoluteAttitude;
|
|
7
7
|
absolutePosition: AbsolutePosition;
|
|
8
8
|
};
|
|
9
|
+
export type VpsScanFailureEvent = {
|
|
10
|
+
listenerId: number;
|
|
11
|
+
sessionId: string;
|
|
12
|
+
attemptId: number | null;
|
|
13
|
+
};
|
|
9
14
|
declare class VpsProvider extends Provider<VpsEvent> {
|
|
10
15
|
static MIN_TIME_BETWEEN_TWO_REQUESTS: number;
|
|
11
16
|
static DEFAULT_MIN_INCLINATION_FOR_REQUEST: number;
|
|
@@ -13,6 +18,8 @@ declare class VpsProvider extends Provider<VpsEvent> {
|
|
|
13
18
|
static DEFAULT_USE_COARSE_POSE: boolean;
|
|
14
19
|
static DEFAULT_REQUEST_CALLER: string;
|
|
15
20
|
static CAMERA_TO_SMARTPHONE_ROT: import('@wemap/maths-legacy').Quaternion_t;
|
|
21
|
+
static ENU_TO_ARCORE_ROT: import('@wemap/maths-legacy').Quaternion_t;
|
|
22
|
+
static _scanFailureCallbackUniqueId: number;
|
|
16
23
|
_relativeRotationCalc?: RelativeRotationCalc;
|
|
17
24
|
_serverError: boolean;
|
|
18
25
|
_cameraError: boolean;
|
|
@@ -23,8 +30,14 @@ declare class VpsProvider extends Provider<VpsEvent> {
|
|
|
23
30
|
_waitTimeMinInclinationForRequest: number;
|
|
24
31
|
_useCoarsePose: boolean;
|
|
25
32
|
_requestCaller: string;
|
|
26
|
-
|
|
27
|
-
|
|
33
|
+
_sessionId: string;
|
|
34
|
+
_attemptIdCounter: number;
|
|
35
|
+
_currentAttemptId: number | null;
|
|
36
|
+
_scanFailureCallbacks: {
|
|
37
|
+
id: number;
|
|
38
|
+
callback: (event: VpsScanFailureEvent) => void;
|
|
39
|
+
}[];
|
|
40
|
+
constructor();
|
|
28
41
|
getName: () => string;
|
|
29
42
|
availability: () => Promise<void>;
|
|
30
43
|
start(): void;
|
|
@@ -37,6 +50,9 @@ declare class VpsProvider extends Provider<VpsEvent> {
|
|
|
37
50
|
_internalStart: () => Promise<void>;
|
|
38
51
|
_internalStop: () => void;
|
|
39
52
|
_generateUuid(): string;
|
|
53
|
+
addScanFailureListener(callback: (event: VpsScanFailureEvent) => void): number;
|
|
54
|
+
removeScanFailureListener(listenerId: number): void;
|
|
55
|
+
resetCurrentAttempt(): void;
|
|
40
56
|
get endpoint(): string | null;
|
|
41
57
|
set endpoint(endpoint: string | null);
|
|
42
58
|
get minInclinationForRequest(): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VpsProvider.d.ts","sourceRoot":"","sources":["../../../../../src/providers/vision/vps/VpsProvider.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,MAAM,EAAE,MAAM,eAAe,CAAC;AAOtD,OAAO,QAAQ,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"VpsProvider.d.ts","sourceRoot":"","sources":["../../../../../src/providers/vision/vps/VpsProvider.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,MAAM,EAAE,MAAM,eAAe,CAAC;AAOtD,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAKtC,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAI1D,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EA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AE,MAAM,EAAE,MAAM,CAAA;KAAE,UAMlD;IAED,gBAAgB,aAQf;IAED,UAAU,CAAC,MAAM,EAAE,MAAM;IAYzB,cAAc,sBA8Ib;IAED,aAAa,aAEZ;IAED,aAAa;IAab,sBAAsB,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI;IAMrE,yBAAyB,CAAC,UAAU,EAAE,MAAM;IAI5C,mBAAmB;IAInB,IAAI,QAAQ,kBAEX;IAED,IAAI,QAAQ,CAAC,QAAQ,eAAA,EAEpB;IAED,IAAI,wBAAwB,WAE3B;IAED,IAAI,wBAAwB,CAAC,wBAAwB,QAAA,EAEpD;IAED,IAAI,gCAAgC,WAEnC;IAED,IAAI,gCAAgC,CAAC,gCAAgC,QAAA,EAEpE;IAED,IAAI,aAAa,YAEhB;IAED,IAAI,aAAa,CAAC,aAAa,SAAA,EAE9B;IAED,IAAI,aAAa,WAEhB;IAED,IAAI,aAAa,CAAC,aAAa,QAAA,EAE9B;CACJ;;AAED,wBAAiC"}
|
|
@@ -2,18 +2,26 @@ import { default as VpsMetadata, VpsMetadataJson } from './VpsMetadata';
|
|
|
2
2
|
export type VpsRequestJson = VpsMetadataJson & {
|
|
3
3
|
image: string;
|
|
4
4
|
};
|
|
5
|
+
export type LocalPose = {
|
|
6
|
+
position: [number, number, number];
|
|
7
|
+
orientation: [number, number, number, number];
|
|
8
|
+
};
|
|
5
9
|
declare class VpsRequest {
|
|
6
10
|
metadata: VpsMetadata;
|
|
7
11
|
image: HTMLCanvasElement;
|
|
8
|
-
|
|
12
|
+
imageQuality: number;
|
|
13
|
+
localPose: LocalPose | null;
|
|
14
|
+
constructor(metadata: VpsMetadata, image: HTMLCanvasElement, imageQuality?: number, localPose?: LocalPose | null);
|
|
9
15
|
toJson(): {
|
|
10
16
|
size: [number, number];
|
|
11
17
|
calibration?: import('../../../../../camera').Calibration;
|
|
12
18
|
coarse?: import('./VpsMetadata').CoarsePoseJson;
|
|
13
19
|
device?: import('./VpsMetadata').VpsDeviceMetadata;
|
|
20
|
+
local_pose?: LocalPose | undefined;
|
|
14
21
|
image: string;
|
|
15
22
|
};
|
|
16
23
|
static fromJson(json: VpsRequestJson): VpsRequest;
|
|
24
|
+
toFormData(): FormData;
|
|
17
25
|
}
|
|
18
26
|
export default VpsRequest;
|
|
19
27
|
//# sourceMappingURL=VpsRequest.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VpsRequest.d.ts","sourceRoot":"","sources":["../../../../../src/providers/vision/vps/VpsRequest.ts"],"names":[],"mappings":"AAEA,OAAO,WAAW,EAAE,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAElE,MAAM,MAAM,cAAc,GAAG,eAAe,GAAG;IAC3C,KAAK,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,cAAM,UAAU;IACZ,QAAQ,EAAE,WAAW,CAAC;IACtB,KAAK,EAAE,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"VpsRequest.d.ts","sourceRoot":"","sources":["../../../../../src/providers/vision/vps/VpsRequest.ts"],"names":[],"mappings":"AAEA,OAAO,WAAW,EAAE,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAElE,MAAM,MAAM,cAAc,GAAG,eAAe,GAAG;IAC3C,KAAK,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,SAAS,GAAG;IACpB,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,WAAW,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;CAChD,CAAA;AAED,cAAM,UAAU;IACZ,QAAQ,EAAE,WAAW,CAAC;IACtB,KAAK,EAAE,iBAAiB,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC;gBAGxB,QAAQ,EAAE,WAAW,EACrB,KAAK,EAAE,iBAAiB,EACxB,YAAY,GAAE,MAAY,EAC1B,SAAS,GAAE,SAAS,GAAG,IAAW;IAQtC,MAAM;;;;;;;;IASN,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,cAAc;IAOpC,UAAU;CA0Bb;AAED,eAAe,UAAU,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wemap/providers",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
"dist"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@wemap/camera": "14.
|
|
21
|
-
"@wemap/core": "14.
|
|
22
|
-
"@wemap/geo": "14.
|
|
23
|
-
"@wemap/osm": "14.
|
|
24
|
-
"@wemap/routers": "14.
|
|
25
|
-
"@wemap/utils": "14.
|
|
20
|
+
"@wemap/camera": "14.5.0",
|
|
21
|
+
"@wemap/core": "14.5.0",
|
|
22
|
+
"@wemap/geo": "14.5.0",
|
|
23
|
+
"@wemap/osm": "14.5.0",
|
|
24
|
+
"@wemap/routers": "14.5.0",
|
|
25
|
+
"@wemap/utils": "14.5.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@wemap/logger-legacy": "^13.3.0",
|