Definition at line 41 of file mainTrack.cpp. References Impala::CmdOptions::GetArg(), Impala::Util::Database::GetIOBuffer(), Impala::CmdOptions::GetString(), ILOG_DEBUG, ILOG_ERROR, ILOG_INFO, ILOG_VAR, main(), Impala::Util::MakeString(), Impala::Util::IOBuffer::Puts(), SetUpOptions(), and Impala::Core::Array::WritePng(). 00042 { 00043 CmdOptions& options = SetUpOptions(argc, argv); 00044 ILOG_VAR(main); 00045 std::string vidname = options.GetArg(0); 00046 std::string input = options.GetArg(1); 00047 std::string output = options.GetArg(2); 00048 ILOG_INFO(vidname); 00049 String imageDumpFilename = options.GetString("tracker-dump-im"); 00050 bool doDump = false; 00051 if(imageDumpFilename != "") 00052 doDump = true; 00053 00054 RgbDataSrcFactory& factory = RgbDataSrcFactory::Instance(); 00055 RgbDataSrc* src = factory.Construct(RgbDataSrcFactory::SRC_LAVC, vidname); 00056 if (! src->Valid()) 00057 { 00058 ILOG_ERROR("RgbDataSrc failed"); 00059 return 0; 00060 } 00061 ILOG_INFO("opened movie: << " << src->LastFrame()+1 << " frames of " << src->FrameWidth() << " x " << src->FrameHeight()); 00062 00063 // read frame regions from file. 00064 FrameRegionTable* regions = new FrameRegionTable; 00065 std::ifstream ifs(input.c_str()); 00066 if(ifs.is_open()) 00067 { 00068 regions->ReadFrom(ifs); 00069 ifs.close(); 00070 } 00071 00072 Array::Array2dVec3UInt8* image=0; 00073 00074 for(int i=0 ; i<regions->Size() ; i++) 00075 { 00076 FrameRegion region = regions->GetRegion(i); 00077 ILOG_INFO("starting tracker for region " << i); 00078 int startFrame = region.GetFrameNumber(); 00079 src->GotoFrame(startFrame); 00080 00081 //setup tracker 00082 FrameRegionTable* track = new FrameRegionTable; 00083 Tracker* tracker = TrackerFactory::CreateTracker(options); 00084 image = Array::MakeFromData<Array::Array2dVec3UInt8>(src->DataPtr(), src->FrameWidth(), src->FrameHeight()); 00085 tracker->Initialize(image, ®ion, track); 00086 00087 //loop tracker until end 00088 while(!src->TheEnd() && tracker->ObjectVisible()) 00089 { 00090 ILOG_DEBUG("."); 00091 delete image; 00092 image = Array::MakeFromData<Array::Array2dVec3UInt8>(src->DataPtr(), src->FrameWidth(), src->FrameHeight()); 00093 tracker->Process(image); 00094 if(doDump) 00095 { 00096 static int frame = 0; 00097 WritePng(image, imageDumpFilename + MakeString(frame) + ".png", 00098 &Util::Database::GetInstance()); 00099 frame++; 00100 } 00101 src->NextFrame(); 00102 } 00103 00104 delete tracker; 00105 delete image; 00106 ILOG_INFO("done tracking, saving data..."); 00107 00108 //save the track 00109 std::ostringstream oss; 00110 track->WriteTo(oss); 00111 Util::Database& db = Util::Database::GetInstance(); 00112 Util::IOBuffer* buf = db.GetIOBuffer(output + MakeString(i) + ".txt", false, false, "tmp"); 00113 buf->Puts(oss.str()); 00114 delete buf; 00115 00116 track->WriteTo(std::cout); 00117 delete track; 00118 } 00119 ILOG_INFO("all frame regions tracked succesfully"); 00120 return 0; 00121 }
Here is the call graph for this function:
|