Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught ReferenceError: webgazer is not defined #296

Open
dabingch opened this issue Mar 22, 2023 · 3 comments
Open

Uncaught ReferenceError: webgazer is not defined #296

dabingch opened this issue Mar 22, 2023 · 3 comments

Comments

@dabingch
Copy link

dabingch commented Mar 22, 2023

I got an error while I was integrating webgazer in my Vue 2 project.

Uncaught ReferenceError: webgazer is not defined

And it was caused at line 42 in util.mjs

I got this error every time in console after I started the webgazer

Is there any hint to fix it?

image

WebGazer/src/util.mjs

Lines 28 to 51 in 9cc7b97

/**
* Compute eyes size as gray histogram
* @param {Object} eyes - The eyes where looking for gray histogram
* @returns {Array.<T>} The eyes gray level histogram
*/
util.getEyeFeats = function(eyes) {
let process = (eye) => {
let resized = this.resizeEye(eye, resizeWidth, resizeHeight);
let gray = this.grayscale(resized.data, resized.width, resized.height);
let hist = [];
this.equalizeHistogram(gray, 5, hist);
return hist;
};
if (webgazer.params.trackEye == 'left') {
return process(eyes.left);
}
else if (webgazer.params.trackEye == 'right') {
return process(eyes.right);
}
else {
return [].concat(process(eyes.left), process(eyes.right));
}
}

@anurag-wecp
Copy link

Hey @dabingch were you able to fix this?

@jeffhuang
Copy link
Contributor

sorry this breaks the way we use webpack right now. npm run build fails

reverting the commit for now

@jeffhuang jeffhuang reopened this Sep 17, 2023
@Grapelllar
Copy link

I found a solution to this issue. The problem occurs because WebGazer internally relies on a global webgazer object, but when using ES modules, this global reference isn't created automatically.

The simplest fix is to manually assign the webgazer instance to the window object:

import webgazer from 'webgazer';
window.webgazer = webgazer; // add this line

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants