uninitialized Ptr<CascadeClassifierImpl> ccimpl in bool CascadeClassifier::read(const FileNode &root) (Bugfix #3530)
Description
sometimes it's nessecary to read a cascade file from memory.
the following code worked nicely in 2.4.2:
// simulate 'in memory' situation
const char * path = "E:/code/opencv/data/haarcascades /haarcascade_eye.xml";
FILE * f = fopen(path,"rb");
char buf[0x8ffff];
int r = fread(buf,1,0x8ffff,f);
buf[r]=0;
// load it into CascadeClassifier:
CascadeClassifier cf;
FileStorage fs(buf, FileStorage::READ | FileStorage::MEMORY);
FileNode fn = fs.getFirstTopLevelNode();
bool ok = cf.read(fn);
same code crashes with 3.0, due to uninitialized Ptr<CascadeClassifierImpl> ccimpl in bool CascadeClassifier::read(const FileNode &root)
changing the code to this:
bool CascadeClassifier::read(const FileNode &root)
{
Ptr<CascadeClassifierImpl> ccimpl = makePtr<CascadeClassifierImpl>();
bool ok = ccimpl->read_(root);
...
made it work for me ( but not sure, if that's the right fix, all a bit over my head, i have to say .. )
Associated revisions
Merge pull request #3530 from jet47:win-install-testdata
History
Updated by Kirill Kornyakov about 11 years ago
- Status changed from New to Done
- Tracker changed from Bug to Bugfix
- Pull request set to https://github.com/Itseez/opencv/pull/2322