I have a data-set acquired with an RGB-D camera and a text file where for each image of the data-set, the timestamps and the filenames are stored. What I do is to parse this file and fill up two std::map, one for rgb images and the other for depth images. Now, since the timestamps don't intersect, I have to write a routine that finds matching images based on the timestamps. This is what I wrote so far:
typedef map<double,string> StampImageMap;
...
vector<string> &vstrImageFilenamesRGB;
vector<string> &vstrImageFilenamesD;
vector<double> &vTimestampsRGB;
vector<double> &vTimestampsDPT;
double tolerance = 0.02;
for(StampImageMap::iterator it=rgb_images.begin(); it != rgb_images.end(); it++) {
bool found = false;
StampImageMap::iterator jt=depth_images.begin();
while(found == false && jt!=depth_images.end()) {
if(fabs(it->first - jt->first) < tolerance) {
found = true;
vstrImageFilenamesRGB.push_back(it->second);
vstrImageFilenamesD.push_back(jt->second);
vTimestampsRGB.push_back(it->first);
vTimestampsDPT.push_back(jt->first);
}
jt++;
}
}
and I'm wondering if there's a more efficient way to perform this task!