00001 #ifndef Impala_Core_VideoSet_Walker_h
00002 #define Impala_Core_VideoSet_Walker_h
00003
00004 #include <vector>
00005 #include "Persistency/QuidTableRepository.h"
00006 #include "Persistency/SegmentationRepository.h"
00007 #include "Persistency/KeyframesRepository.h"
00008 #include "Persistency/AnnotationTableRepository.h"
00009 #include "Basis/ConfigBase.h"
00010 #include "Core/Table/AnnotationTable.h"
00011 #include "Core/VideoSet/VideoSet.h"
00012 #include "Core/VideoSet/Segmentation.h"
00013 #include "Core/VideoSet/RgbDataSrcKeyframes.h"
00014 #include "Core/VideoSet/Listener.h"
00015 #include "Core/Geometry/DatabaseReadVxRectangle.h"
00016 #include "Util/DatabaseReadString.h"
00017 #include "Util/Database.h"
00018 #include "Util/IOBuffer.h"
00019
00020 namespace Impala
00021 {
00022 namespace Core
00023 {
00024 namespace VideoSet
00025 {
00026
00027 class WalkerConfig : public ConfigBase
00028 {
00029 public:
00030 WalkerConfig()
00031 {
00032 iFrames = false;
00033 keyframeSrc = false;
00034 partialWalk = false;
00035 virtualWalk = false;
00036 maxKeyframeMask = -1;
00037 numberFrames = -1;
00038 numberKeyframes = -1;
00039 numberQuids = -1;
00040 startKeyframe = 0;
00041 startQuid = 0;
00042 stepSize = 1;
00043 }
00044
00045 void InitOptions(CmdOptions& co)
00046 {
00047 co.AddOption(0, "iFrames", "", "false");
00048 co.AddOption(0, "keyframeSrc", "", "false");
00049 co.AddOption(0, "virtualWalk", "", "false");
00050 co.AddOption(0, "partialWalk", "", "false");
00051
00052 co.AddOption(0, "numberFrames", "nr", "-1");
00053 co.AddOption(0, "numberKeyframes", "nr", "-1");
00054 co.AddOption(0, "numberQuids", "nr", "-1");
00055 co.AddOption(0, "startKeyframe", "idx", "0");
00056 co.AddOption(0, "startQuid", "idx", "0");
00057 co.AddOption(0, "stepSize", "nr", "1");
00058 }
00059
00060 void RetrieveOptions(CmdOptions& co)
00061 {
00062 iFrames = co.GetBool("iFrames", iFrames);
00063 keyframeSrc = co.GetBool("keyframeSrc", keyframeSrc);
00064 partialWalk = co.GetBool("partialWalk", partialWalk);
00065 virtualWalk = co.GetBool("virtualWalk", virtualWalk);
00066 maxKeyframeMask = co.GetInt("maxKeyframeMask", maxKeyframeMask);
00067 numberFrames = co.GetInt("numberFrames", numberFrames);
00068 numberKeyframes = co.GetInt("numberKeyframes", numberKeyframes);
00069 numberQuids = co.GetInt("numberQuids", numberQuids);
00070 startKeyframe = co.GetInt("startKeyframe", startKeyframe);
00071 startQuid = co.GetInt("startQuid", startQuid);
00072 stepSize = co.GetInt("stepSize", stepSize);
00073 }
00074
00075 private:
00076 bool iFrames;
00077 bool keyframeSrc;
00078 bool partialWalk;
00079 bool virtualWalk;
00080 int maxKeyframeMask;
00081 int numberFrames;
00082 int numberKeyframes;
00083 int numberQuids;
00084 int startKeyframe;
00085 int startQuid;
00086 int stepSize;
00087
00088 friend class Walker;
00089 };
00090
00091
00092
00093 class Walker
00094 {
00095 public:
00096
00097 Walker(VideoSet* videoSet, WalkerConfig config) : mConfig(config)
00098 {
00099 mVideoSet = videoSet;
00100 mSegmentation = 0;
00101 mKeyframes = 0;
00102 mKeyframeMask = 0;
00103 mQuids = new Table::QuidTable(0);
00104 }
00105
00106 virtual
00107 ~Walker()
00108 {
00109 for(int i = 0; i < mListeners.size(); i++)
00110 {
00111 delete mListeners[i];
00112 }
00113 mListeners.clear();
00114 }
00115
00116 void
00117 AddListener(Listener* listener)
00118 {
00119 mListeners.push_back(listener);
00120 }
00121
00122 int
00123 NrListeners() const
00124 {
00125 return mListeners.size();
00126 }
00127
00128 void
00129 LoadSegmentation(String name)
00130 {
00131 if (mSegmentation)
00132 delete mSegmentation;
00133 #ifndef REPOSITORY_USED // Here comes the deprecated stuff
00134 mSegmentation = new Segmentation(mVideoSet, name);
00135 #else // REPOSITORY_USED
00136 Persistency::SegmentationLocator loc(mVideoSet->GetLocator(), name);
00137 mSegmentation = Persistency::SegmentationRepository().Get(loc,
00138 mVideoSet);
00139 #endif // REPOSITORY_USED
00140 }
00141
00142 Segmentation*
00143 GetSegmentation()
00144 {
00145 return mSegmentation;
00146 }
00147
00148 void
00149 LoadKeyframes(String name)
00150 {
00151 if (mKeyframes)
00152 delete mKeyframes;
00153 #ifndef REPOSITORY_USED // Here comes the deprecated stuff
00154 mKeyframes = new Keyframes(mVideoSet, name);
00155 #else // REPOSITORY_USED
00156 Persistency::KeyframesLocator loc(mVideoSet->GetLocator(), name);
00157 mKeyframes = Persistency::KeyframesRepository().Get(loc, mVideoSet);
00158 #endif // REPOSITORY_USED
00159 }
00160
00161 void
00162 SetKeyframeMask(bool* mask)
00163 {
00164 mKeyframeMask = mask;
00165 }
00166
00167 void
00168 AddRkfMask()
00169 {
00170 if (!InitKeyframeMask())
00171 return;
00172 int nrKey = mKeyframes->GetNrKeyframes();
00173 for (int i=0 ; i<nrKey ; i++)
00174 mKeyframeMask[i] &= mKeyframes->IsRKF(i);
00175 }
00176
00177 #ifndef REPOSITORY_USED // Here comes the deprecated stuff
00178 void
00179 AddKeyframeMaskFile(String fileName)
00180 {
00181 if (!InitKeyframeMask())
00182 return;
00183 std::vector< String > maskNames;
00184 Util::DatabaseReadString(std::back_inserter(maskNames), fileName,
00185 mVideoSet->GetDatabase(), true);
00186 if (maskNames.size() > mConfig.maxKeyframeMask)
00187 maskNames.erase(maskNames.begin() + mConfig.maxKeyframeMask,
00188 maskNames.end());
00189
00190 int nrKey = mKeyframes->GetNrKeyframes();
00191 for (int i=0 ; i<nrKey ; i++)
00192 {
00193 String keyName = mKeyframes->GetName(i);
00194 bool present = false;
00195 for (int j=0 ; j<maskNames.size() ; j++)
00196 {
00197 String s = maskNames[j];
00198 int pos = keyName.find(s);
00199 if (pos < keyName.size())
00200 {
00201 if (keyName[pos + s.size()] == '_' ||
00202 keyName[pos + s.size()] == '.')
00203 {
00204 present = true;
00205 break;
00206 }
00207 }
00208 }
00209 mKeyframeMask[i] &= present;
00210 }
00211 }
00212 #endif // REPOSITORY_USED
00213
00214 void
00215 AddKeyframeMaskAnnoFile(String fileName)
00216 {
00217 if (!InitKeyframeMask())
00218 return;
00219 #ifndef REPOSITORY_USED // Here comes the deprecated stuff
00220 Table::AnnotationTable annoTable;
00221 Table::Read(&annoTable, fileName, mVideoSet->GetDatabase());
00222 int nrKey = mKeyframes->GetNrKeyframes();
00223 for (int i=0 ; i<nrKey ; i++)
00224 {
00225 Quid quid = mKeyframes->GetQuidFrame(i);
00226 bool present = annoTable.IsPositive(quid);
00227 mKeyframeMask[i] &= present;
00228 }
00229 #else // REPOSITORY_USED
00230 StringList sList(fileName, '/');
00231 if (sList.size() != 4)
00232 ILOG_ERROR("AddKeyframeMaskAnnoFile: expected 4 elements in path");
00233 StringListCI it = sList.begin();
00234 it++;
00235 String quidStr = *it++;
00236 String conceptSet = *it++;
00237 String keyword = FileNameBase(*it);
00238 Persistency::AnnotationTableLocator loc(mVideoSet->GetLocator(),
00239 StringToQuidClass(quidStr),
00240 conceptSet, keyword);
00241 Table::AnnotationTable* annoTable =
00242 Persistency::AnnotationTableRepository().Get(loc);
00243 int nrKey = mKeyframes->GetNrKeyframes();
00244 for (int i=0 ; i<nrKey ; i++)
00245 {
00246 Quid quid = mKeyframes->GetQuidFrame(i);
00247 bool present = annoTable->IsPositive(quid);
00248 mKeyframeMask[i] &= present;
00249 }
00250 delete annoTable;
00251 #endif // REPOSITORY_USED
00252 }
00253
00254 bool*
00255 GetKeyframeMask()
00256 {
00257 return mKeyframeMask;
00258 }
00259
00260 void
00261 LoadQuids(String fileName)
00262 {
00263 #ifndef REPOSITORY_USED // Here comes the deprecated stuff
00264 Table::Read(mQuids, fileName, mVideoSet->GetDatabase());
00265 #else // REPOSITORY_USED
00266 Persistency::QuidTableLocator loc(mVideoSet->GetLocator(),
00267 FileNamePath(fileName),
00268 FileNameTail(fileName));
00269 mQuids = Persistency::QuidTableRepository().Get(loc);
00270 #endif // REPOSITORY_USED
00271 mQuidWalkName = FileNameBase(fileName);
00272 mQuids->UpdateGroups();
00273 }
00274
00275 Core::Table::QuidTable*
00276 GetQuids()
00277 {
00278 return mQuids;
00279 }
00280
00281 void
00282 LoadBookmarks(String fileName)
00283 {
00284 mVrList.clear();
00285 #ifndef REPOSITORY_USED // Here comes the deprecated stuff
00286 Geometry::DatabaseReadVxRectangle(std::back_inserter(mVrList), fileName,
00287 mVideoSet->GetDatabase());
00288 #else // REPOSITORY_USED
00289 Persistency::FileLocator loc(mVideoSet->GetLocator(), fileName);
00290 Geometry::DatabaseReadVxRectangle(std::back_inserter(mVrList), loc);
00291 #endif // REPOSITORY_USED
00292 }
00293
00294 int
00295 TotalNrFramesInBookmarks()
00296 {
00297 int nr = 0;
00298 for (size_t i=0 ; i<mVrList.size() ; i++)
00299 {
00300 Geometry::VxRectangle vr = mVrList[i];
00301 nr += vr.mEndFrame - vr.mStartFrame + 1;
00302 }
00303 return nr;
00304 }
00305
00306
00307
00308 int
00309 DoWalk()
00310 {
00311 return DoWalk(0, mVideoSet->NrFiles(), 0);
00312 }
00313
00314 int
00315 DoWalk(int startFile, int numberFiles, int startFrame)
00316 {
00317 if (startFile >= mVideoSet->NrFiles())
00318 {
00319 ILOG_ERROR("DoWalk: startFile out of range");
00320 return -1;
00321 }
00322 if (numberFiles == -1)
00323 numberFiles = mVideoSet->NrFiles() - startFile;
00324 if (startFile + numberFiles >= mVideoSet->NrFiles())
00325 numberFiles = mVideoSet->NrFiles() - startFile;
00326
00327 for (size_t l=0 ; l<mListeners.size() ; l++)
00328 {
00329 mListeners[l]->HandleNewWalk(mVideoSet);
00330 mListeners[l]->HandleNewWalk(mVideoSet, "Frames");
00331 if (mSegmentation)
00332 mListeners[l]->HandleNewWalk(mVideoSet, mSegmentation);
00333
00334 if (mConfig.partialWalk)
00335 mListeners[l]->HandleNewWalkPartial(mVideoSet, startFrame,
00336 mConfig.stepSize,
00337 mConfig.numberFrames);
00338 }
00339
00340 for (int fileId=startFile ; fileId<startFile+numberFiles ; fileId++)
00341 {
00342 if (mConfig.virtualWalk)
00343 {
00344 for (size_t l=0 ; l<mListeners.size() ; l++)
00345 mListeners[l]->HandleNewFile(mVideoSet, fileId, 0);
00346 for (size_t l=0 ; l<mListeners.size() ; l++)
00347 mListeners[l]->HandleDoneFile(mVideoSet, fileId, 0);
00348 continue;
00349 }
00350
00351 Stream::RgbDataSrc* src = mVideoSet->GetVideo(fileId);
00352 if (src == 0)
00353 {
00354
00355
00356
00357 ILOG_ERROR("DoWalk: Failed on file: " +
00358 mVideoSet->GetAsPath(fileId));
00359 return -3;
00360 }
00361
00362 for (size_t l=0 ; l<mListeners.size() ; l++)
00363 mListeners[l]->HandleNewFile(mVideoSet, fileId, src);
00364
00365 if (!src->GotoFrame(startFrame))
00366 {
00367 ILOG_ERROR("DoWalk: Failed on src->GotoFrame() for file: " +
00368 mVideoSet->GetAsPath(fileId));
00369 delete src;
00370 return -5;
00371 }
00372
00373 if (src->FrameNr() != startFrame)
00374 continue;
00375
00376 if (mConfig.iFrames)
00377 {
00378 while (!src->CurIsIFrame() && !src->TheEnd())
00379 {
00380 if (!src->NextFrame(mConfig.stepSize))
00381 {
00382 ILOG_ERROR("DoWalk: Failed on src->NextFrame() for file: " +
00383 mVideoSet->GetAsPath(fileId));
00384 delete src;
00385 return -6;
00386 }
00387 }
00388 }
00389
00390 if (src->TheEnd())
00391 {
00392 ILOG_ERROR("DoWalk: no IFrames found");
00393 continue;
00394 }
00395
00396 int lastShot = -1;
00397 int numberFrames = mConfig.numberFrames;
00398 bool done = false;
00399 do
00400 {
00401 if (mSegmentation)
00402 {
00403 int frame = src->FrameNr();
00404 int shot = mSegmentation->GetShotId(fileId, frame);
00405 if (shot != lastShot)
00406 {
00407 if (lastShot != -1)
00408 for (size_t l=0 ; l<mListeners.size() ; l++)
00409 mListeners[l]->HandleDoneShot(mVideoSet, fileId,
00410 src, lastShot);
00411 for (size_t l=0 ; l<mListeners.size() ; l++)
00412 mListeners[l]->HandleNewShot(mVideoSet, fileId,
00413 src, shot);
00414 lastShot = shot;
00415 }
00416 }
00417
00418 for (size_t l=0 ; l<mListeners.size() ; l++)
00419 mListeners[l]->HandleNewFrame(mVideoSet, fileId, src);
00420
00421 if (mConfig.stepSize == 10000000)
00422 {
00423 done = true;
00424 }
00425 else
00426 {
00427
00428
00429 try
00430 {
00431 src->NextFrame(mConfig.stepSize);
00432 if (mConfig.iFrames)
00433 {
00434 while (!src->CurIsIFrame() && !src->TheEnd())
00435 src->NextFrame(mConfig.stepSize);
00436 }
00437 }
00438 catch (std::exception& e)
00439 {
00440 String eMsg(e.what());
00441
00442
00443
00444 ILOG_ERROR("DoWalk: Failed on src->NextFrame() for file: "
00445 + mVideoSet->GetAsPath(fileId) + ": " + eMsg);
00446 delete src;
00447 return -4;
00448 }
00449 }
00450
00451 if (src->TheEnd())
00452 done = true;
00453
00454 if (numberFrames > 0)
00455 {
00456 numberFrames--;
00457 if (numberFrames <= 0)
00458 done = true;
00459 }
00460 } while (!done);
00461
00462 if (mSegmentation && (lastShot != -1))
00463 for (size_t l=0 ; l<mListeners.size() ; l++)
00464 mListeners[l]->HandleDoneShot(mVideoSet, fileId, src,
00465 lastShot);
00466 for (size_t l=0 ; l<mListeners.size() ; l++)
00467 mListeners[l]->HandleDoneFile(mVideoSet, fileId, src);
00468
00469 delete src;
00470 }
00471
00472 for (size_t l=0 ; l<mListeners.size() ; l++)
00473 mListeners[l]->HandleDoneWalk(mVideoSet);
00474
00475 return 0;
00476 }
00477
00478 void
00479 DoWalkKeyframes(int startFile, int numberFiles)
00480 {
00481 if (mKeyframes == 0)
00482 {
00483 ILOG_ERROR("DoWalkKeyframes: no keyframes loaded");
00484 return;
00485 }
00486 if (startFile >= mVideoSet->NrFiles())
00487 {
00488 ILOG_ERROR("DoWalkKeyframes: startFile out of range");
00489 return;
00490 }
00491 if (numberFiles == -1)
00492 numberFiles = mVideoSet->NrFiles();
00493 if (startFile + numberFiles >= mVideoSet->NrFiles())
00494 numberFiles = mVideoSet->NrFiles() - startFile;
00495
00496 for (size_t l=0 ; l<mListeners.size() ; l++)
00497 {
00498 mListeners[l]->HandleNewWalk(mVideoSet);
00499 mListeners[l]->HandleNewWalk(mVideoSet, "Keyframes");
00500 mListeners[l]->HandleNewWalk(mVideoSet, mKeyframes, mKeyframeMask);
00501 if (mSegmentation)
00502 mListeners[l]->HandleNewWalk(mVideoSet, mSegmentation);
00503 }
00504 ILOG_DEBUG("fileId range = " << startFile << " - "
00505 << startFile+numberFiles);
00506 for (int fileId=startFile ; fileId<startFile+numberFiles ; fileId++)
00507 {
00508 ILOG_DEBUG("fileId = " << fileId);
00509 ILOG_NDC_PUSH("video " << fileId);
00510 Stream::RgbDataSrc* src = 0;
00511 if (mConfig.keyframeSrc)
00512 src = new RgbDataSrcKeyframes(mVideoSet, mKeyframes, fileId);
00513 else if (!mConfig.virtualWalk)
00514 src = mVideoSet->GetVideo(fileId);
00515 for (size_t l=0 ; l<mListeners.size() ; l++)
00516 mListeners[l]->HandleNewFile(mVideoSet, fileId, src);
00517 int numberKeyframes = mConfig.numberKeyframes;
00518 int startK = mKeyframes->GetFirstKeyframeVideo(fileId);
00519 int numberK = mKeyframes->GetNrKeyframesVideo(fileId);
00520 int lastK = startK + numberK;
00521 ILOG_INFO("keyframes are " << startK << " - " << lastK << " (nr = "
00522 << numberK << ")");
00523 if (mConfig.startKeyframe < numberK)
00524 startK += mConfig.startKeyframe;
00525 if (numberKeyframes == -1)
00526 numberKeyframes = numberK;
00527
00528
00529
00530 bool done = false;
00531 int k = startK;
00532 ILOG_DEBUG("processing " << startK << " - " << lastK << " (max "
00533 << numberKeyframes << ")");
00534 while (!done)
00535 {
00536 if ((!mKeyframeMask) || mKeyframeMask[k])
00537 {
00538 ILOG_DEBUG("keyframe " << k);
00539 if (src)
00540 {
00541 ILOG_DEBUG("GotoFrame " << mKeyframes->GetFrameNr(k));
00542 src->GotoFrame(mKeyframes->GetFrameNr(k));
00543 ILOG_DEBUG("src at " << src->FrameNr());
00544 }
00545 for (size_t l=0 ; l<mListeners.size() ; l++)
00546 mListeners[l]->HandleNewFrame(mVideoSet, fileId, src);
00547 if (--numberKeyframes <= 0)
00548 done = true;
00549 }
00550 if (++k >= lastK)
00551 done = true;
00552 }
00553 for (size_t l=0 ; l<mListeners.size() ; l++)
00554 mListeners[l]->HandleDoneFile(mVideoSet, fileId, src);
00555 if (src)
00556 delete src;
00557 ILOG_NDC_POP;
00558 }
00559
00560 for (size_t l=0 ; l<mListeners.size() ; l++)
00561 mListeners[l]->HandleDoneWalk(mVideoSet);
00562 }
00563
00564 void
00565 DoWalkQuids(int startFile, int numberFiles)
00566 {
00567 if ((mQuids == 0) || (mQuids->Size() == 0))
00568 {
00569 ILOG_ERROR("DoWalkQuids: no quids loaded");
00570 return;
00571 }
00572 if (startFile >= mVideoSet->NrFiles())
00573 {
00574 ILOG_ERROR("DoWalkQuids: startFile out of range");
00575 return;
00576 }
00577 if (numberFiles == -1)
00578 numberFiles = mVideoSet->NrFiles();
00579 if (startFile + numberFiles >= mVideoSet->NrFiles())
00580 numberFiles = mVideoSet->NrFiles() - startFile;
00581
00582 for (size_t l=0 ; l<mListeners.size() ; l++)
00583 {
00584 mListeners[l]->HandleNewWalk(mVideoSet);
00585 mListeners[l]->HandleNewWalk(mVideoSet, mQuidWalkName);
00586 if (mSegmentation)
00587 mListeners[l]->HandleNewWalk(mVideoSet, mSegmentation);
00588 }
00589 ILOG_DEBUG("fileId range = " << startFile << " - "
00590 << startFile+numberFiles);
00591 for (int fileId=startFile ; fileId<startFile+numberFiles ; fileId++)
00592 {
00593 ILOG_DEBUG("fileId = " << fileId);
00594 ILOG_NDC_PUSH("video " << fileId);
00595 int numberQuids = mConfig.numberQuids;
00596 int startQ = mQuids->GetFirstQuidObject(fileId);
00597 int numberQ = mQuids->GetNrQuidsObject(fileId);
00598 if (numberQ == 0)
00599 continue;
00600
00601 int lastQ = startQ + numberQ;
00602 ILOG_INFO("quids are " << startQ << " - " << lastQ << " (nr = "
00603 << numberQ << ")");
00604 if (mConfig.startQuid < numberQ)
00605 startQ += mConfig.startQuid;
00606 if (numberQuids == -1)
00607 numberQuids = numberQ;
00608 bool done = false;
00609 int qIdx = startQ;
00610 ILOG_DEBUG("processing " << startQ << " - " << lastQ << " (max "
00611 << numberQuids << ")");
00612 Stream::RgbDataSrc* src = 0;
00613 if (!mConfig.virtualWalk)
00614 src = mVideoSet->GetVideo(fileId);
00615 for (size_t l=0 ; l<mListeners.size() ; l++)
00616 mListeners[l]->HandleNewFile(mVideoSet, fileId, src);
00617 while (!done)
00618 {
00619 ILOG_DEBUG("quidIdx " << qIdx);
00620 Quid quid = mQuids->Get1(qIdx);
00621 if (src)
00622 {
00623 int frameNr = QuidId(quid);
00624 ILOG_DEBUG("GotoFrame " << frameNr);
00625 src->GotoFrame(frameNr);
00626 ILOG_DEBUG("src at " << src->FrameNr());
00627 }
00628 for (size_t l=0 ; l<mListeners.size() ; l++)
00629 mListeners[l]->HandleNewFrame(mVideoSet, fileId, src);
00630 if (--numberQuids <= 0)
00631 done = true;
00632 if (++qIdx >= lastQ)
00633 done = true;
00634 }
00635 for (size_t l=0 ; l<mListeners.size() ; l++)
00636 mListeners[l]->HandleDoneFile(mVideoSet, fileId, src);
00637 if (src)
00638 delete src;
00639 ILOG_NDC_POP;
00640 }
00641
00642 for (size_t l=0 ; l<mListeners.size() ; l++)
00643 mListeners[l]->HandleDoneWalk(mVideoSet);
00644 }
00645
00646 void
00647 DoWalkBookmarks()
00648 {
00649 for (size_t l=0 ; l<mListeners.size() ; l++)
00650 {
00651 mListeners[l]->HandleNewWalk(mVideoSet, mVrList.size());
00652 mListeners[l]->HandleNewWalk(mVideoSet, "Bookmarks");
00653 }
00654 for (size_t v=0 ; v<mVrList.size() ; v++)
00655 {
00656 ILOG_INFO("Bookmark " << v << " of " << mVrList.size());
00657 Geometry::VxRectangle vr = mVrList[v];
00658 int fileId = mVideoSet->GetFileId(vr.mVideoName);
00659
00660
00661
00662
00663 Stream::RgbDataSrc* src = mVideoSet->GetVideo(fileId);
00664 for (size_t l=0 ; l<mListeners.size() ; l++)
00665 mListeners[l]->HandleNewFile(mVideoSet, fileId, src, v, vr);
00666
00667 Geometry::Rectangle r = vr.mRect;
00668 String s = vr.mAnno;
00669 src->GotoFrame(vr.mStartFrame);
00670 for (size_t l=0 ; l<mListeners.size() ; l++)
00671 mListeners[l]->HandleNewFrame(mVideoSet, fileId, src, r, s);
00672 while (src->FrameNr() < vr.mEndFrame)
00673 {
00674 src->NextFrame();
00675 for (size_t l=0 ; l<mListeners.size() ; l++)
00676 mListeners[l]->HandleNewFrame(mVideoSet, fileId, src, r, s);
00677 }
00678
00679 for (size_t l=0 ; l<mListeners.size() ; l++)
00680 mListeners[l]->HandleDoneFile(mVideoSet, fileId, src, v, vr);
00681 delete src;
00682 }
00683 for (size_t l=0 ; l<mListeners.size() ; l++)
00684 mListeners[l]->HandleDoneWalk(mVideoSet, mVrList.size());
00685 }
00686
00687 protected:
00688
00689 bool
00690 InitKeyframeMask()
00691 {
00692 if (mKeyframes == 0)
00693 {
00694 ILOG_ERROR("InitKeyframeMask: no keyframes loaded");
00695 return false;
00696 }
00697 if (mKeyframeMask)
00698 return true;
00699 int nrKey = mKeyframes->GetNrKeyframes();
00700 mKeyframeMask = new bool[nrKey];
00701 for (int i=0 ; i<nrKey ; i++)
00702 mKeyframeMask[i] = true;
00703 return true;
00704 }
00705
00706 VideoSet* mVideoSet;
00707 Segmentation* mSegmentation;
00708 Keyframes* mKeyframes;
00709 Core::Table::QuidTable* mQuids;
00710 String mQuidWalkName;
00711 std::vector<Geometry::VxRectangle> mVrList;
00712 std::vector<Listener*> mListeners;
00713 bool* mKeyframeMask;
00714 WalkerConfig mConfig;
00715
00716 ILOG_VAR_DEC;
00717 };
00718
00719 ILOG_VAR_INIT(Walker, Impala.Core.VideoSet);
00720
00721 }
00722 }
00723 }
00724
00725 #endif