00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00024
00025 #include <QVKLTFeatureTracking>
00026
00027 void QVTrackingManager::updateTrackings(QHash<int, QVKLTTrackerFeature> *tracks) {
00028
00029
00030 if (removeLostTrackings) {
00031 QList<int> lost = QList<int> ();
00032 QHash<int, QVKLTFeatureTracking>::iterator j;
00033
00034 for (j = trackings.begin(); j != trackings.end(); j++) {
00035 if (!tracks->contains(j.key()))
00036 lost << j.key();
00037 }
00038 for (int i=0; i < lost.size(); i++){
00039 trackings.remove(lost[i]);
00040 }
00041 }
00042
00043
00044 QHash<int, QVKLTTrackerFeature>::iterator i;
00045 for (i = tracks->begin(); i != tracks->end(); ++i) {
00046 if (trackings.contains(i.key())) {
00047
00048 trackings[i.key()].addFeature(i.value());
00049 } else {
00050
00051 trackings.insert(i.key(), QVKLTFeatureTracking(i.value(), this->actualFrame));
00052 }
00053 }
00054
00055 this->actualFrame++;
00056 }
00057
00058 QList<int> QVTrackingManager::getTrackingsAtLastFrame() {
00059 if (removeLostTrackings) {
00060 return trackings.keys();
00061 } else{
00062 return getTrackingsAtFrame(this->actualFrame);
00063 }
00064 }
00065
00066 QList<int> QVTrackingManager::getTrackingsAtFrame(int frame) {
00067 QList<int> ids = QList<int> ();
00068 QHash<int, QVKLTFeatureTracking>::iterator j;
00069 for(j = trackings.begin(); j != trackings.end(); j++) {
00070 QVKLTFeatureTracking ft = j.value();
00071
00072 if( (ft.getFirstFrame() <= frame) and (frame <= ft.getLastFrame()) )
00073 ids << j.key();
00074 }
00075 return ids;
00076 }