uninitialized Ptr<CascadeClassifierImpl> ccimpl in bool CascadeClassifier::read(const FileNode &root) (Bugfix #3530)


Added by be rak about 11 years ago. Updated about 11 years ago.


Status:Done Start date:2014-02-08
Priority:Normal Due date:
Assignee:- % Done:

0%

Category:objdetect
Target version:3.0
Affected version:branch 'master' (3.0-dev) Operating System:Any
Difficulty:Easy HW Platform:Any
Pull request:https://github.com/Itseez/opencv/pull/2322

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&lt;CascadeClassifierImpl&gt; ccimpl = makePtr&lt;CascadeClassifierImpl&gt;();
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

Revision 9c2ef369
Added by Vadim Pisarevsky about 10 years ago

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

Also available in: Atom PDF