Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OpenCV.js unable to load haar cascades

Hi everyone,
I was tring to implement the face detection example with opencv.js.
The problem is that there's no way of importing the necessary haar cascade.
My project structure is as follows:

  • index.html
  • js
    • myjs.js
    • opencv.js
    • utils.js
  • haar
    • haarcascade_frontalface_default.xml


In "myjs.js" I try to load the cascade as shown in the example using my path to the cascade:

let classifier = new cv.CascadeClassifier();
classifier.load('../haar/haarcascade_frontalface_default.xml');

The function returns always false indicating the loading failure, independently if using the relative or the absolute path. Because of this I can't use the "detectMultiScale" function...

Can anyone help me please?