question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Illegal constructor.

See original GitHub issue

Hi, I get the following error:

TypeError: Illegal constructor.

when I do the following: const detection = await faceapi.detectSingleFace(video);

video is basically an HTML element (document.getElementById(“video-stream”)) I also tried passing an id to the faceapi.detectSingleFace, same error.

I am using node v10.15.0, webpack, babel and React.

I had an error about tensorflow saying that fs module could not be resolved, but I guess this is not related. Just in case…

Here is the full code:

async function detectFaces(video, canvas, width, height) {
	window.logger.log("detectFaces");
	const detection = await faceapi.detectSingleFace(video);
	console.log(detection);
}

function loadVideo(video, canvas, width, height) {
	window.logger.log("loadVideo");
	navigator.mediaDevices.getUserMedia({
		video: {
			width : width,
			height: height
		}
	}).then(function(stream) {
		video.srcObject = stream;
		video.play();
		video.onloadedmetadata = function() {
			detectFaces(video, canvas, width, height);
		}
	}).catch(function(error) {
		console.log(error);
	});
}

Thank you.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

17reactions
ciobanudan97commented, Mar 11, 2019

Yes , I put this in my code and it works: faceapi.env.monkeyPatch({ Canvas: HTMLCanvasElement, Image: HTMLImageElement, ImageData: ImageData, Video: HTMLVideoElement, createCanvasElement: () => document.createElement(‘canvas’), createImageElement: () => document.createElement(‘img’) })

0reactions
Alireza17224commented, Dec 6, 2021

You must set options for that like tinyModel or Yolyo

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to solve "Uncaught TypeError: Illegal constructor"
The Illegal constructor error is thrown when a class extends HTMLElement, but is instantiated like a regular class. Using classes that inherits from ......
Read more >
Illegal constructor with EcmaScript 6 - javascript - Stack Overflow
So, new UserAvatar will fail with Illegal constructor. To fix it, define it first: customElements.define('tom-user-avatar', UserAvatar);.
Read more >
Uncaught TypeError: Illegal constructor in Chrome when a ...
I'm running into a frustrating problem with some custom elements I'm defining and am hoping for some bread crumbs from someone with a...
Read more >
1186698 - PeerConnection.js: TypeError: Illegal constructor
The answer is that an error is reported to the web console (and to the page's onerror handler), just without useful location information....
Read more >
HTML : Only on Chrome I got this error: Uncaught TypeError
HTML : Only on Chrome I got this error: Uncaught TypeError : Illegal constructor [ Beautify Your Computer ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found