Open alexsosa2000 opened 11 months ago
Please try the following code:
using var fs = new FileStorage(yaml_string, FileStorage.Modes.Read | FileStorage.Modes.Memory);
using var node = fs.GetFirstTopLevelNode();
using var cascade = new CascadeClassifier();
bool ret = cascade.Read(node); // should return true
Thank you @shimat. It turned out I needed to use v4.6 to get the Read() method.
Unfortunately cascade.Read() is returning false. I'm using this haarcascade_frontalface_default.xml as the string.
Any idea how to get it working with this model?
Also, in your expert opinion, would it be better to use DNN in Blazor WebAssembly? If so, is that able to read from an in-memory file and model?
Summary of your issue
I'm trying to do face detection in Blazor WebAssembly by using CascadeClassifier. The problem is it seems to only be able to initialize from a file (which can't be done in the browser). Therefore, I'm trying to figure out how to initialize CascadeClassifier from a string in memory (hardcoded XML).
I've seen other examples of people doing this like (C++ example):
Ref: https://answers.opencv.org/question/27970/cascadeclassifierload-from-memory/
The problem is there's no CascadeClassifer.Read() method that allows me to pass in FileStorage.GetFirstTopLevelNode().
Any idea on how to be able to initialize the CascadeClassifier from a string in memory?