mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 11:10:54 +00:00
improve timing in webgazer and utilize in jspsych
This commit is contained in:
parent
346726ec44
commit
3ce8aea220
@ -87839,7 +87839,6 @@ var defaults = {
|
|||||||
'settings': {}
|
'settings': {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//PRIVATE FUNCTIONS
|
//PRIVATE FUNCTIONS
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -87994,6 +87993,7 @@ async function getPrediction(regModelIndex) {
|
|||||||
if(paused){
|
if(paused){
|
||||||
paintCurrentFrame(videoElementCanvas, videoElementCanvas.width, videoElementCanvas.height);
|
paintCurrentFrame(videoElementCanvas, videoElementCanvas.width, videoElementCanvas.height);
|
||||||
}
|
}
|
||||||
|
var time = performance.now();
|
||||||
|
|
||||||
var predictions = [];
|
var predictions = [];
|
||||||
// [20200617 xk] TODO: this call should be made async somehow. will take some work.
|
// [20200617 xk] TODO: this call should be made async somehow. will take some work.
|
||||||
@ -88010,14 +88010,16 @@ async function getPrediction(regModelIndex) {
|
|||||||
return predictions[regModelIndex] === null ? null : {
|
return predictions[regModelIndex] === null ? null : {
|
||||||
'x' : predictions[regModelIndex].x,
|
'x' : predictions[regModelIndex].x,
|
||||||
'y' : predictions[regModelIndex].y,
|
'y' : predictions[regModelIndex].y,
|
||||||
'eyeFeatures': latestEyeFeatures
|
'eyeFeatures': latestEyeFeatures,
|
||||||
|
't' : time
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
return predictions.length === 0 || predictions[0] === null ? null : {
|
return predictions.length === 0 || predictions[0] === null ? null : {
|
||||||
'x' : predictions[0].x,
|
'x' : predictions[0].x,
|
||||||
'y' : predictions[0].y,
|
'y' : predictions[0].y,
|
||||||
'eyeFeatures': latestEyeFeatures,
|
'eyeFeatures': latestEyeFeatures,
|
||||||
'all' : predictions
|
'all' : predictions,
|
||||||
|
't' : time
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -226,10 +226,12 @@ jsPsych.extensions['webgazer'] = (function () {
|
|||||||
if (gazeData !== null){
|
if (gazeData !== null){
|
||||||
var d = {
|
var d = {
|
||||||
x: state.round_predictions ? Math.round(gazeData.x) : gazeData.x,
|
x: state.round_predictions ? Math.round(gazeData.x) : gazeData.x,
|
||||||
y: state.round_predictions ? Math.round(gazeData.y) : gazeData.y
|
y: state.round_predictions ? Math.round(gazeData.y) : gazeData.y,
|
||||||
|
t: gazeData.t
|
||||||
}
|
}
|
||||||
if(state.activeTrial) {
|
if(state.activeTrial) {
|
||||||
d.t = Math.round(performance.now() - state.currentTrialStart)
|
console.log(`handleUpdate: t = ${Math.round(gazeData.t)}, now = ${Math.round(performance.now())}`);
|
||||||
|
d.t = Math.round(gazeData.t - state.currentTrialStart)
|
||||||
state.currentTrialData.push(d); // add data to current trial's data
|
state.currentTrialData.push(d); // add data to current trial's data
|
||||||
}
|
}
|
||||||
state.currentGaze = d;
|
state.currentGaze = d;
|
||||||
|
@ -110,7 +110,7 @@
|
|||||||
|
|
||||||
var cancelGazeUpdate = jsPsych.extensions['webgazer'].onGazeUpdate(function(prediction){
|
var cancelGazeUpdate = jsPsych.extensions['webgazer'].onGazeUpdate(function(prediction){
|
||||||
if(performance.now() > pt_start_val){
|
if(performance.now() > pt_start_val){
|
||||||
pt_data.push({x: prediction.x, y: prediction.y, dx: prediction.x - x, dy: prediction.y - y, t: Math.round(performance.now()-start)});
|
pt_data.push({x: prediction.x, y: prediction.y, dx: prediction.x - x, dy: prediction.y - y, t: Math.round(prediction.t-start)});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user