fixed crash from #79

This commit is contained in:
matlabbe
2016-05-05 11:53:09 -04:00
parent 74d0bfa1bb
commit 7c8583f025
2 changed files with 10 additions and 7 deletions

View File

@@ -2508,10 +2508,10 @@ void Memory::removeVirtualLinks(int signatureId)
void Memory::dumpMemory(std::string directory) const
{
UINFO("Dumping memory to directory \"%s\"", directory.c_str());
this->dumpDictionary((directory+"DumpMemoryWordRef.txt").c_str(), (directory+"DumpMemoryWordDesc.txt").c_str());
this->dumpSignatures((directory + "DumpMemorySign.txt").c_str(), false);
this->dumpSignatures((directory + "DumpMemorySign3.txt").c_str(), true);
this->dumpMemoryTree((directory + "DumpMemoryTree.txt").c_str());
this->dumpDictionary((directory+"/DumpMemoryWordRef.txt").c_str(), (directory+"/DumpMemoryWordDesc.txt").c_str());
this->dumpSignatures((directory + "/DumpMemorySign.txt").c_str(), false);
this->dumpSignatures((directory + "/DumpMemorySign3.txt").c_str(), true);
this->dumpMemoryTree((directory + "/DumpMemoryTree.txt").c_str());
}
void Memory::dumpDictionary(const char * fileNameRef, const char * fileNameDesc) const
@@ -2524,6 +2524,7 @@ void Memory::dumpDictionary(const char * fileNameRef, const char * fileNameDesc)
void Memory::dumpSignatures(const char * fileNameSign, bool words3D) const
{
UDEBUG("");
FILE* foutSign = 0;
#ifdef _MSC_VER
fopen_s(&foutSign, fileNameSign, "w");
@@ -2571,6 +2572,7 @@ void Memory::dumpSignatures(const char * fileNameSign, bool words3D) const
void Memory::dumpMemoryTree(const char * fileNameTree) const
{
UDEBUG("");
FILE* foutTree = 0;
#ifdef _MSC_VER
fopen_s(&foutTree, fileNameTree, "w");

View File

@@ -1546,18 +1546,17 @@ void VWDictionary::deleteUnusedWords()
void VWDictionary::exportDictionary(const char * fileNameReferences, const char * fileNameDescriptors) const
{
UDEBUG("");
if(_visualWords.empty())
{
UWARN("Dictionary is empty, cannot export it!");
return;
}
if(_visualWords.at(0)->getDescriptor().type() != CV_32FC1)
if(_visualWords.begin()->second->getDescriptor().type() != CV_32FC1)
{
UERROR("Exporting binary descriptors is not implemented!");
return;
}
FILE* foutRef = 0;
FILE* foutDesc = 0;
#ifdef _MSC_VER
@@ -1580,10 +1579,12 @@ void VWDictionary::exportDictionary(const char * fileNameReferences, const char
}
else
{
UDEBUG("");
fprintf(foutDesc, "WordID Descriptors...%d\n", (*_visualWords.begin()).second->getDescriptor().cols);
}
}
UDEBUG("Export %d words...", _visualWords.size());
for(std::map<int, VisualWord *>::const_iterator iter=_visualWords.begin(); iter!=_visualWords.end(); ++iter)
{
// References