Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

void Impala::Application::SDash::CameraMovementReader::Read ( const std::string &  basePath,
std::vector< Visualization::Video > &  videos,
std::map< int, std::vector< CameraEvent > > &  camEventSchedule 
) [inline]

Definition at line 27 of file CameraMovementReader.h.

References Impala::FileExists(), Impala::Application::SDash::CameraEvent::FrameNr(), Impala::Util::StringParser::GetInt(), Impala::MakeString(), and Impala::Application::SDash::CameraEvent::SetComments().

Referenced by Impala::Application::SDash::SurveillanceApp::ReadCameraMovements().

00031     {
00032 
00033         int totalEventsFound = 0;
00034         int totalFramesFound = 0;
00035         std::vector<Visualization::Video>::iterator videoIter = videos.begin();
00036         while (videoIter != videos.end())
00037         {
00038             int videoId = videoIter->mId;
00039             int eventsFound = 0;
00040             int framesFound = 0;
00041             std::string filePath = basePath + "cam_moving_" + MakeString(videoId) + ".csv";
00042             if (FileExists(filePath))
00043             {
00044                 // open the file
00045                 Util::IOBufferFile file(filePath, true, true);
00046 
00047                 int prevFrameNr = -2;
00048                 int frameNr = -1;
00049                 CameraEvent camEvent;
00050                 do
00051                 {
00052                     // read a line, parse into frame nr
00053                     std::string line = file.ReadLine();
00054                     if (line.empty())
00055                     {
00056                         if (prevFrameNr >= 0)
00057                         {
00058                             // end last sequence
00059                             int firstFrameOfSeq = camEvent.FrameNr();
00060                             int eventTimeSec = firstFrameOfSeq * videoIter->GetTimePerFrame();
00061                             camEvent.SetComments(MakeString(2 + prevFrameNr - firstFrameOfSeq) + " frames");
00062                             camEventSchedule[eventTimeSec].push_back(camEvent);
00063                         }
00064 
00065                         break;
00066                     }
00067 
00068                     Util::StringParser parser(line);
00069                     frameNr = parser.GetInt(';');
00070                     if (frameNr > prevFrameNr + 1)
00071                     {
00072                         if (prevFrameNr >= 0)
00073                         {
00074                             // end previous sequence
00075                             int firstFrameOfSeq = camEvent.FrameNr();
00076                             int eventTimeSec = firstFrameOfSeq * videoIter->GetTimePerFrame();
00077                             camEvent.SetComments(MakeString(2 + prevFrameNr - firstFrameOfSeq) + " frames");
00078                             camEventSchedule[eventTimeSec].push_back(camEvent);
00079                         }
00080 
00081                         // start of a movement sequence
00082                         int camNr = videoId + 1;
00083                         camEvent = CameraEvent(camNr, 3, frameNr);
00084                         eventsFound++;
00085                         videoIter->AddMovementFrame(frameNr); // first frame of seq.
00086                         framesFound++;
00087                     }
00088                     //lastCamEventP->SetComments(MakeString(frameNr - lastCamEventP->FrameNr()) + " frames");
00089                     videoIter->AddMovementFrame(frameNr + 1); // movement ends at earliest at this frame
00090                     framesFound++;
00091                     prevFrameNr = frameNr;
00092                 } while (true);
00093             }
00094 
00095             std::cout << eventsFound << " camera movements found for video #" << videoId << std::endl;
00096             std::cout << framesFound << " camera movement frames found for video #" << videoId << std::endl;
00097             totalEventsFound += eventsFound;
00098             totalFramesFound += framesFound;
00099             videoIter++;
00100         }
00101 
00102         std::cout << totalEventsFound << " camera movements found in total" << std::endl;
00103         std::cout << totalFramesFound << " camera movement frames found in total" << std::endl;
00104         //return 0;
00105     }

Here is the call graph for this function:


Generated on Fri Mar 19 10:49:04 2010 for ImpalaSrc by  doxygen 1.5.1