remote-calibrator 0.5.0-beta.2 → 0.5.0-beta.3
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +1 -0
- package/homepage/example.js +1 -1
- package/lib/RemoteCalibrator.min.js +1 -1
- package/lib/RemoteCalibrator.min.js.LICENSE.txt +1 -1
- package/lib/RemoteCalibrator.min.js.map +1 -1
- package/package.json +7 -7
- package/src/const.js +3 -0
- package/src/css/panel.scss +6 -0
- package/src/distance/distance.js +1 -1
- package/src/distance/distanceTrack.js +20 -28
- package/src/distance/interPupillaryDistance.js +3 -1
- package/src/i18n.js +1 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "remote-calibrator",
|
3
|
-
"version": "0.5.0-beta.
|
3
|
+
"version": "0.5.0-beta.3",
|
4
4
|
"description": "Useful calibration tools for remote psychophysics experiments.",
|
5
5
|
"main": "lib/RemoteCalibrator.min.js",
|
6
6
|
"directories": {
|
@@ -33,25 +33,25 @@
|
|
33
33
|
"autoprefixer": "^10.3.7",
|
34
34
|
"babel-loader": "^8.2.3",
|
35
35
|
"clean-webpack-plugin": "^4.0.0",
|
36
|
-
"css-loader": "^6.
|
36
|
+
"css-loader": "^6.5.0",
|
37
37
|
"css-minimizer-webpack-plugin": "^3.1.1",
|
38
38
|
"cssnano": "^5.0.8",
|
39
|
-
"eslint": "^
|
40
|
-
"eslint-webpack-plugin": "^3.0
|
39
|
+
"eslint": "^8.1.0",
|
40
|
+
"eslint-webpack-plugin": "^3.1.0",
|
41
41
|
"express": "^4.17.1",
|
42
42
|
"googleapis": "^89.0.0",
|
43
43
|
"husky": "^7.0.4",
|
44
|
-
"lint-staged": "^11.2.
|
44
|
+
"lint-staged": "^11.2.6",
|
45
45
|
"nodemon": "^2.0.14",
|
46
46
|
"postcss-loader": "^6.2.0",
|
47
47
|
"prettier": "^2.4.1",
|
48
|
-
"sass": "^1.43.
|
48
|
+
"sass": "^1.43.4",
|
49
49
|
"sass-loader": "^12.2.0",
|
50
50
|
"style-loader": "^3.3.1",
|
51
51
|
"svg-inline-loader": "^0.8.2",
|
52
52
|
"terser-webpack-plugin": "^5.2.4",
|
53
53
|
"url-loader": "^4.1.1",
|
54
|
-
"webpack": "^5.
|
54
|
+
"webpack": "^5.60.0",
|
55
55
|
"webpack-cli": "^4.9.1",
|
56
56
|
"webpack-modules": "^1.0.0",
|
57
57
|
"xlsx": "^0.17.3"
|
package/src/const.js
CHANGED
@@ -12,6 +12,8 @@ RemoteCalibrator.prototype._CONST = Object.freeze({
|
|
12
12
|
MARGIN: 10,
|
13
13
|
BORDER: 8,
|
14
14
|
},
|
15
|
+
PPI_DONT_USE: 127.7,
|
16
|
+
PD_DONT_USE: 6.4,
|
15
17
|
},
|
16
18
|
S: {
|
17
19
|
AUTO: 'AUTO',
|
@@ -31,4 +33,5 @@ RemoteCalibrator.prototype._CONST = Object.freeze({
|
|
31
33
|
B: 'BlindSpot',
|
32
34
|
F: 'FaceMesh',
|
33
35
|
},
|
36
|
+
IN_TO_CM: 2.54,
|
34
37
|
})
|
package/src/css/panel.scss
CHANGED
@@ -29,6 +29,7 @@
|
|
29
29
|
user-select: none;
|
30
30
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
|
31
31
|
Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
|
32
|
+
scrollbar-width: none;
|
32
33
|
}
|
33
34
|
|
34
35
|
.rc-panel-title {
|
@@ -211,4 +212,9 @@
|
|
211
212
|
cursor: pointer;
|
212
213
|
}
|
213
214
|
}
|
215
|
+
|
216
|
+
::-webkit-scrollbar {
|
217
|
+
width: 0;
|
218
|
+
display: none;
|
219
|
+
}
|
214
220
|
}
|
package/src/distance/distance.js
CHANGED
@@ -24,7 +24,7 @@ const blindSpotHTML = `<canvas id="blind-spot-canvas"></canvas>`
|
|
24
24
|
/* -------------------------------------------------------------------------- */
|
25
25
|
|
26
26
|
export function blindSpotTest(RC, options, toTrackDistance = false, callback) {
|
27
|
-
let ppi =
|
27
|
+
let ppi = RC._CONST.N.PPI_DONT_USE // Dangerous! Arbitrary value
|
28
28
|
if (RC.screenPpi) ppi = RC.screenPpi.value
|
29
29
|
else
|
30
30
|
console.error(
|
@@ -155,17 +155,14 @@ const startTrackingPupils = async (RC, beforeCallbackTrack, callbackTrack) => {
|
|
155
155
|
}
|
156
156
|
|
157
157
|
const eyeDist = (a, b) => {
|
158
|
-
return Math.
|
159
|
-
Math.pow(a[0] - b[0], 2) +
|
160
|
-
Math.pow(a[1] - b[1], 2) +
|
161
|
-
Math.pow(a[2] - b[2], 2)
|
162
|
-
)
|
158
|
+
return Math.hypot(a[0] - b[0], a[1] - b[1], a[2] - b[2])
|
163
159
|
}
|
164
160
|
|
165
161
|
const cyclopean = (video, a, b) => {
|
166
|
-
|
167
|
-
|
168
|
-
|
162
|
+
return [
|
163
|
+
(-a[0] - b[0] + video.videoWidth) / 2,
|
164
|
+
(-a[1] - b[1] + video.videoHeight) / 2,
|
165
|
+
]
|
169
166
|
}
|
170
167
|
|
171
168
|
/* -------------------------------------------------------------------------- */
|
@@ -207,7 +204,7 @@ const _tracking = async (RC, trackingOptions, callbackTrack) => {
|
|
207
204
|
model = await RC.gazeTracker.webgazer.getTracker().model
|
208
205
|
|
209
206
|
// Near point
|
210
|
-
let ppi = RC.screenPpi ? RC.screenPpi.value :
|
207
|
+
let ppi = RC.screenPpi ? RC.screenPpi.value : RC._CONST.N.PPI_DONT_USE
|
211
208
|
if (!RC.screenPpi && trackingOptions.nearPoint)
|
212
209
|
console.error(
|
213
210
|
'Screen size measurement is required to get accurate near point tracking.'
|
@@ -352,25 +349,19 @@ const _getNearPoint = (
|
|
352
349
|
ppi,
|
353
350
|
latency
|
354
351
|
) => {
|
355
|
-
let
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
const videoFactor = video.videoHeight / video.clientHeight
|
362
|
-
offsetToVideoMid.forEach((e, i) => {
|
363
|
-
// Average interpupillary distance - 6.4cm
|
364
|
-
offsetToVideoMid[i] =
|
365
|
-
((RC.PDCm ? RC.PDCm.value : 6.4) * e) /
|
366
|
-
(averageDist * (videoFactor / 2)) /* Should this be videoFactor? */
|
352
|
+
let offsetToVideoCenter = cyclopean(video, mesh[133], mesh[362])
|
353
|
+
offsetToVideoCenter.forEach((offset, i) => {
|
354
|
+
// Average inter-pupillary distance - 6.4cm
|
355
|
+
offsetToVideoCenter[i] =
|
356
|
+
((RC.PDCm ? RC.PDCm.value : RC._CONST.N.PD_DONT_USE) * offset) /
|
357
|
+
averageDist
|
367
358
|
})
|
368
359
|
|
369
360
|
let nPData = (RC.newNearPointData = {
|
370
361
|
value: {
|
371
|
-
x: toFixedNumber(
|
362
|
+
x: toFixedNumber(offsetToVideoCenter[0], trackingOptions.decimalPlace),
|
372
363
|
y: toFixedNumber(
|
373
|
-
|
364
|
+
offsetToVideoCenter[1] + ((screen.height / 2) * 2.54) / ppi, // Commonly the webcam is 0.5cm above the screen
|
374
365
|
trackingOptions.decimalPlace
|
375
366
|
),
|
376
367
|
latencyMs: latency,
|
@@ -379,17 +370,18 @@ const _getNearPoint = (
|
|
379
370
|
})
|
380
371
|
|
381
372
|
// SHOW
|
373
|
+
const dotR = 5
|
382
374
|
if (trackingOptions.showNearPoint) {
|
383
375
|
let offsetX = (nPData.value.x * ppi) / 2.54
|
384
376
|
let offsetY = (nPData.value.y * ppi) / 2.54
|
385
377
|
Object.assign(nearPointDot.style, {
|
386
|
-
left: `${screen.width / 2 - window.screenLeft
|
378
|
+
left: `${screen.width / 2 - window.screenLeft + offsetX - dotR}px`,
|
387
379
|
top: `${
|
388
380
|
screen.height / 2 -
|
389
381
|
window.screenTop -
|
390
|
-
|
391
|
-
|
392
|
-
|
382
|
+
(window.outerHeight - window.innerHeight) -
|
383
|
+
offsetY -
|
384
|
+
dotR
|
393
385
|
}px`,
|
394
386
|
})
|
395
387
|
}
|
@@ -498,7 +490,7 @@ RemoteCalibrator.prototype.getDistanceNow = async function (callback = null) {
|
|
498
490
|
mesh,
|
499
491
|
dist,
|
500
492
|
timestamp,
|
501
|
-
this.screenPpi ? this.screenPpi.value :
|
493
|
+
this.screenPpi ? this.screenPpi.value : this._CONST.N.PPI_DONT_USE,
|
502
494
|
latency
|
503
495
|
)
|
504
496
|
}
|
@@ -53,7 +53,9 @@ RemoteCalibrator.prototype._measurePD = function (options = {}, callback) {
|
|
53
53
|
this._replaceBackground(
|
54
54
|
constructInstructions(options.headline, options.shortDescription, true)
|
55
55
|
)
|
56
|
-
const screenPpi = this.screenPpi
|
56
|
+
const screenPpi = this.screenPpi
|
57
|
+
? this.screenPpi.value
|
58
|
+
: this._CONST.N.PPI_DONT_USE
|
57
59
|
|
58
60
|
let [videoWidth, videoHeight] = setupVideo(this)
|
59
61
|
let [ruler, rulerListener] = setupRuler(
|