Proper way to unload a loaded classifier? [closed]
How do I unload a loaded classifier? I thought by name there may be something like "unload" since I call "load" to begin with, and I do see CascadeClassifier::empty();, but that just checks whether something was loaded (?).
Thanks.
what do you mean with "stop" ?
For instance, if I'm running a classifier on live video and I want to stop the classifier from performing detectMultiScale by taking the xml document I called "load" on, and somehow unload it. I could create a conditional inside processImage to ignore detectMultiScale for whenever I choose, but I'm not comfortable with that solution. If I were to load another classifier, I'm not sure what would happen to the old one, and so I don't want to set myself up for uncertainty.
Thank you for your consideration, berak.
better use some programming logic, like a flag, to decide, whether to call detectMultiScale or not.
well, you can't make it 'forget' the old one, without making the whole thing invalid. (that's what you wanted?)
if you need another cascade, use a new CascadeClassifier instance.
Thanks for the quick replies - glad I didn't reply too soon before the edit. Yeah, I'd like to make it forget the old one, so I edited my question to better reflect that.
you can call release() on it, but then you're not allowed to call detectMultiScale (it will crash) unless you load another cascade file.
again, if you want to switch the detection on/off, this is not the way to do it.
I would use a combination of @berak his suggestions. Call the release on the object when you want to unload it, and at the same time set a boolean flag. Before adding detectmultiscale operator, check that flag, if it is set then NOT use it, if it is unset, then go ahead with processing.
Hmm. My last question was about -nonsym being removed. Now I want the deprecated cvReleaseHaarClassifierCascade(&cascade). Maybe in a few years I'll catch up.
Well that is actually not what you were looking for. C depended on manual cleaning. However C++ has a garbage collector that destroys objects the moment they run out of scope. That is why the cvRelease functions were removed. Only time you actually should call release on an object is when you explicitly made one with the new operator.