js cascadeclassifier load always empty
I am trying to load the pretrained models. I am using Vue and the XML is in the public directory
public/models/haarcascades/*
I can load it using axios.get() I then can create a new File() using the data from the get
But no matter what I do, I can not get the classifier not be empty. What is the search path used by classifier? is it local file access or network? If local file then I could use my new File()
let classifier = new cv2.CascadeClassifier();
// load pre-trained classifiers
let b = classifier.load('/models/haarcascades/haarcascade_frontalface_default.xml');
console.log('NNLOAD', b, classifier.empty())
let faces = new cv2.RectVector();
//console.log(faces)
//InterpolationFlags
try {
classifier.detectMultiScale(gray, faces, 1.1, 3, 0)
console.log('FACE',faces, faces.size(), faces.get(0))
}
catch(err) {
console.log('FERR',err);
}
``` To test each path I did the following. I know that I need the correct path. That is my question., is there a default path? Where does opencv js look for the files?
let b = classifier.load('/public/models/haarcascades/haarcascade_frontalface_default.xml')
console.log('CLASS', process.env.BASE_URL, b, classifier.empty())
b = classifier.load('/models/haarcascades/haarcascade_frontalface_default.xml')
console.log('CLASS', process.env.BASE_URL, b, classifier.empty())
b = classifier.load('models/haarcascades/haarcascade_frontalface_default.xml')
console.log('CLASS', process.env.BASE_URL, b, classifier.empty())
b = classifier.load('../../public/models/haarcascades/haarcascade_frontalface_default.xml')
console.log('CLASS', process.env.BASE_URL, b, classifier.empty())
b = classifier.load('public/models/haarcascades/haarcascade_frontalface_default.xml')
console.log('CLASS', process.env.BASE_URL, b, classifier.empty())
b = classifier.load('haarcascade_frontalface_default.xml')
console.log('CLASS', process.env.BASE_URL, b, classifier.empty())
They all returned false and .empty() true.
public/models/haarcascades/
vs/models/haarcascades/
-- do you see the mismatch ?and where exactly is the
public
folder ?that's unfortunately useless, problem here is: you need a correct filename
did you check, if your cascade file is valid ?
I cloned the opencv repo and used those xml files. I assume that it is a valid file.
try to put html and xml into the same folder, load your html from there, and use 'haarcascade_frontalface_default.xml'
apart from that, only the 1st and last of all the paths (and maybe the one with ../.. in it, idk) are correct, think of it ..
I copied the xml file into every directory, /public, /src/assets, /src, src/components, still nothing. I am going to try to "import it and see what that does. I even cloned v4.0.0 and built a new opencv.js and now I am trying that.version. More later