-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWebsiteSystem.js
More file actions
103 lines (75 loc) · 2.72 KB
/
Copy pathWebsiteSystem.js
File metadata and controls
103 lines (75 loc) · 2.72 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
Canvas = null;
AllTrialData = [];
// TrialDataTemplate = {
// 'trialID' : 1,
// 'trialType' : 'default',
// 'trialData' : TRIALDATA,
// }
function CreateTrialData(trialType) {
var trialData = {};
trialData['trialID'] = AllTrialData.length + 1;
trialData['trialType'] = trialType;
return trialData;
}
function PushTrialData(trialData) {
AllTrialData.push(trialData);
}
function GetCanvas() {
if (Canvas == null) {
Canvas = this.document.querySelector('.ExperimentCanvas');
}
return Canvas;
}
function ClearCanvas() {
if (Canvas == null) {
Canvas = this.document.querySelector('.ExperimentCanvas');
}
Canvas.innerHTML = '';
/*
while (element.firstChild) {
element.removeChild(element.firstChild);
}
*/
}
async function ResumeWebgazer(caller = 'function') {
//await webgazer.resume();
console.log(`Webgazer resumed. Called by "${caller}"`);
}
async function PauseWebgazer(caller = 'function') {
//await webgazer.pause();
console.log(`Webgazer paused. Called by "${caller}"`);
}
/* ----------------------------------------------------------------------------------------------- */
WelcomePageInstruction =
`Position your head so that the webcam has a good view of your eyes.<br/>
Center your face in the box and look directly towards the camera.<br/>
It is important that you try and keep your head reasonably still throughout the experiment, so please take a moment to adjust your setup to be comfortable.<br/>
When your face is centered in the box and the box is green, you can click to continue.<br/>
`
function ShowWelcomePage() {
ShowInstruction(WelcomePageInstruction, AfterWelcomPage, 'Continue', true);
}
async function AfterWelcomPage() {
await ReadTheConfigs(); //Get prepared for the experiment.
// var videoContainer = document.querySelector('#webgazerVideoContainer');
// videoContainer.style.display = 'none';
await PauseWebgazer('AfterWelcomPage');
StartCalibration();
}
window.onload = async function () {
await webgazer.setTracker("TFFacemesh");// ‘clmtrackr’ ‘js_objectdetect’ ‘trackingjs’
await webgazer.setRegression("ridge"); //‘ridge’ ‘weightedRidge' 'threadedRidge'
webgazer.applyKalmanFilter(true);
webgazer.clearData(); //need clear all data collected
GetCanvas();
ShowWelcomePage();
await webgazer.setGazeListener(function(data, elapsedTime){
}).saveDataAcrossSessions(true).begin();
webgazer.showVideo(true); // id = "webgazerVideoFeed". webgazerVideoContainer
webgazer.showPredictionPoints(true);
SetInstructionButtonDisable(false);
}
window.onbeforeunload = function () {
webgazer.clearData();
webgazer.end();
}