Improved DatabaseViewer memory usage (by not keeping uncompressed data in cache)

This commit is contained in:
matlabbe
2015-10-14 11:02:36 -04:00
parent a8d83c895c
commit 9bd649009c
5 changed files with 37 additions and 20 deletions
+1 -1
View File
@@ -61,7 +61,7 @@ public:
static void getConnectedGraph(
int fromId,
const std::map<int, Transform> & posesIn,
const std::multimap<int, Link> & linksIn,
const std::multimap<int, Link> & linksIn, // only one link between two poses
std::map<int, Transform> & posesOut,
std::multimap<int, Link> & linksOut,
int depth = 0);
+1 -1
View File
@@ -141,7 +141,7 @@ public:
double & stamp,
bool lookInDatabase = false) const;
cv::Mat getImageCompressed(int signatureId) const;
SensorData getNodeData(int nodeId, bool uncompressedData = false);
SensorData getNodeData(int nodeId, bool uncompressedData = false, bool keepLoadedDataInMemory = true);
void getNodeWords(int nodeId,
std::multimap<int, cv::KeyPoint> & words,
std::multimap<int, pcl::PointXYZ> & words3);
+2 -1
View File
@@ -239,6 +239,7 @@ void Optimizer::getConnectedGraph(
std::multimap<int, int> biLinks;
for(std::multimap<int, Link>::const_iterator iter=linksIn.begin(); iter!=linksIn.end(); ++iter)
{
UASSERT_MSG(findLink(biLinks, iter->second.from(), iter->second.to()) == biLinks.end(), "Input links should be unique between two poses.");
biLinks.insert(std::make_pair(iter->second.from(), iter->second.to()));
biLinks.insert(std::make_pair(iter->second.to(), iter->second.from()));
}
@@ -262,7 +263,7 @@ void Optimizer::getConnectedGraph(
{
nextDepth.insert(nextId);
std::map<int, Link>::const_iterator kter = graph::findLink(linksIn, *jter, nextId);
std::multimap<int, Link>::const_iterator kter = graph::findLink(linksIn, *jter, nextId);
if(depth == 0 || d < depth-1)
{
linksOut.insert(*kter);
+7 -3
View File
@@ -3392,23 +3392,27 @@ cv::Mat Memory::getImageCompressed(int signatureId) const
return image;
}
SensorData Memory::getNodeData(int nodeId, bool uncompressedData)
SensorData Memory::getNodeData(int nodeId, bool uncompressedData, bool keepLoadedDataInMemory)
{
UDEBUG("nodeId=%d", nodeId);
SensorData r;
Signature * s = this->_getSignature(nodeId);
if(s && !s->sensorData().imageCompressed().empty())
{
if(uncompressedData)
if(keepLoadedDataInMemory && uncompressedData)
{
s->sensorData().uncompressData();
}
r = s->sensorData();
if(!keepLoadedDataInMemory && uncompressedData)
{
r.uncompressData();
}
}
else if(_dbDriver)
{
// load from database
if(s)
if(s && keepLoadedDataInMemory)
{
std::list<Signature*> signatures;
signatures.push_back(s);