void ID3v2_Tag::setTextFrame(const wxString &id, const wxString &value) { if(value.IsEmpty()) { removeFrames(id); return; } //if(!d->frameListMap[id].isEmpty()) // d->frameListMap[id].front()->setText(value); ID3v2_FrameList* it = frameList(id); if( it ) { ID3v2_FrameList::Node* l = it->GetFirst(); if( l ) { l->GetData()->setText(value); } } else { const SjStringType encoding = m_factory->defaultTextEncoding(); SjByteVector idBv; idBv.appendString(id, SJ_LATIN1); ID3v2_TextIdentificationFrame *f = new ID3v2_TextIdentificationFrame(idBv, encoding); addFrame(f); f->setText(value); } }
ID3v2_CommentsFrame* ID3v2_Tag::findCommentFrame() const { ID3v2_FrameList* list = frameList(wxT("COMM")); ID3v2_CommentsFrame* frame; if( list ) { // prefer comments without description, start searching with the last (mostly the newest) ID3v2_FrameList::Node* node = list->GetLast(); while( node ) { frame = (ID3v2_CommentsFrame*)node->GetData(); if( frame->description().IsEmpty() && !frame->text().IsEmpty() ) { return frame; } node = node->GetPrevious(); } // try to return empty frames without description list->GetLast(); while( node ) { frame = (ID3v2_CommentsFrame*)node->GetData(); if( frame->description().IsEmpty() ) { return frame; } node = node->GetPrevious(); } /* if( !forWrite ) // do not overwrite eg. MusicMatch comments { // okay, no comment so far, check all comment frames and return the first non-empty comment node = list->GetFirst(); while( node ) { frame = (ID3v2_CommentsFrame*)node->GetData(); if( !frame->text().IsEmpty() ) { return frame; } node = node->GetNext(); } // just use the first frame node = list->GetFirst(); if( node ) { return (ID3v2_CommentsFrame*)node->GetData(); } }*/ } return NULL; }
void ID3v2_Tag::addFrame(ID3v2_Frame *frame) { m_frameList.Append(frame); ID3v2_FrameList* l = frameList(frame->frameID().toString(SJ_LATIN1)); if( l == NULL ) { l = new ID3v2_FrameList; m_frameListMap.Insert(frame->frameID().toString(SJ_LATIN1), l); } l->Append(frame); }
wxString ID3v2_Tag::simpleFrame(const wxString& frameId) const { ID3v2_FrameList* list = frameList(frameId); if( list ) { ID3v2_FrameList::Node* node = list->GetFirst(); if( node ) { return node->GetData()->toString(); } } return wxEmptyString; }
void ID3v2_Tag::removeFrames(const wxString &id) { /*FrameList l = d->frameListMap[id]; for(FrameList::Iterator it = l.begin(); it != l.end(); ++it) removeFrame(*it, true);*/ ID3v2_FrameList* l = frameList(id); if( l ) { ID3v2_FrameList::Node* first; while( (first=l->GetFirst()) != NULL ) { removeFrame(first->GetData(), true); } } }
void ID3v2_Tag::removeFrame(ID3v2_Frame *frame, bool del) { // remove the frame from the frame list /*FrameList::Iterator it = d->frameList.find(frame); d->frameList.erase(it);*/ m_frameList.DeleteObject(frame); // this does not delete the object itself! // ...and from the frame list map /*it = d->frameListMap[frame->frameID()].find(frame); d->frameListMap[frame->frameID()].erase(it);*/ ID3v2_FrameList* it = frameList(frame->frameID().toString(SJ_LATIN1)); if( it ) { it->DeleteObject(frame); } // ...and delete as desired if(del) delete frame; }
int main() { PROFILER_INIT(); FrameList frameList(10); // Keep a history of up to 100 frames (might be used by some modules) // Modules //BackgroundModelling_simple::BackgroundModel backgroundModel; BackgroundModelling::BackgroundModel backgroundModel; ForegroundProcessing::ForegroundProcessor foregroundProcessor; Identification::Identifier identifier; Prediction::Kalman kalmanFilter; Evaluation evaluate(&frameList, 20); // Init foregroundProcessor.setAlgortihm(ForegroundProcessing::SLOW); //Use slow, toggle shadows in the init command foregroundProcessor.init(3, 2, 125, 4, false); foregroundProcessor.initShadow(0.5, 0.5, 0.3, 0.99); identifier.init(Identification::Ultimate); evaluate.readXML2FrameList("clip1.xml"); //evaluate.readXML2FrameList("CAVIAR1/fosne2gt.xml"); int waitForBGConvergence = 60; // Load frame source //frameList.open("CAVIAR1/OneStopNoEnter2front.mpg"); //frameList.open("clip1.mpeg"); frameList.open("camera1.mov"); //frameList.open("Renova_20080420_083025_Cam10_0000.mpeg"); //Record video VideoWriter demo("trackingDemo.mpeg", CV_FOURCC('P','I','M','1'), 20, frameList.movieSize*2); // Create windows namedWindow("Info",CV_WINDOW_AUTOSIZE); namedWindow("Background",CV_WINDOW_AUTOSIZE); namedWindow("Foreground",CV_WINDOW_AUTOSIZE); namedWindow("Tracking",CV_WINDOW_AUTOSIZE); namedWindow("Raw image", CV_WINDOW_AUTOSIZE); //namedWindow("BackgroundModel",CV_WINDOW_AUTOSIZE); namedWindow("Evaluation", CV_WINDOW_AUTOSIZE); while (frameList.queryNextFrame()) { PROFILER_RESET(); sampleDown(frameList.getLatestFrame().image, frameList.getLatestFrame().image, 1); // Speed up by sampling down the image // Do the nessecary processing backgroundModel.update(frameList.getFrames()); PROFILE("BackgroundModel"); if (frameList.getCurrentFrameNumber() > waitForBGConvergence) //Wait for convergence foregroundProcessor.segmentForeground(frameList.getLatestFrame()); PROFILE("ForegroundSeg."); identifier.identify(frameList.getFrames()); PROFILE("Identification"); kalmanFilter.predict(frameList.getLatestFrame()); PROFILE("Kalman Prediction"); evaluate.currentFrame(); PROFILE("Evaluation"); // Display result frameList.display("Tracking"); frameList.displayBackground("Background"); if (frameList.getCurrentFrameNumber() > waitForBGConvergence) //Wait for convergence frameList.displayForeground("Foreground"); evaluate.displayInfo("Evaluation"); // Give the GUI time to render waitKey(1); PROFILE("Display"); // Write current frame (and info) to file demo << frameList.getLatestFrame().demoImage; // Optional pause between each frame //stepWiseFromFrame(frameList, 55); PROFILE("QueryNextFrame"); PROFILE_TOTALTIME(); PROFILE("FPS"); PROFILE_FPS(); // Evaluate accuracy and precision evaluate.MOTA(); evaluate.MOTP(); // Display info frameList.displayInfo("Info"); } evaluate.displaySequenceInfo("Evaluation"); waitKey(0); return 0; }
wxString ID3v2_Tag::genre() const { // TODO: In the next major version (Tagger 2.0) a list of multiple genres // should be separated by " / " instead of " ". For the moment to keep // the behavior the same as released versions it is being left with " ". /*if(!d->frameListMap["TCON"].isEmpty() && dynamic_cast<TextIdentificationFrame *>(d->frameListMap["TCON"].front())) begin Frame *frame = d->frameListMap["TCON"].front();*/ ID3v2_FrameList* it = frameList(wxT("TCON")); if( it && it->GetFirst() ) { ID3v2_Frame* frame = it->GetFirst()->GetData(); // ID3v2.4 lists genres as the fields in its frames field list. If the field // is simply a number it can be assumed that it is an ID3v1 genre number. // Here was assume that if an ID3v1 string is present that it should be // appended to the genre string. Multiple fields will be appended as the // string is built. if(m_header.majorVersion() == 4) { ID3v2_TextIdentificationFrame *f = (ID3v2_TextIdentificationFrame *)(frame); wxArrayString fields = f->fieldList(); wxString genreString; bool hasNumber = false; //for(StringList::ConstIterator it = fields.begin(); it != fields.end(); ++it) int i, iCount = fields.GetCount(); for( i = 0; i < iCount; i++ ) { wxString itStr = fields.Item(i); int j, jCount = itStr.Len(); if( jCount > 0 ) // skip empty strings as they're converted to "Blues" otherwise { bool isNumber = true; /*for(String::ConstIterator charIt = (*it).begin(); isNumber && charIt != (*it).end(); ++charIt) { isNumber = *charIt >= '0' && *charIt <= '9'; }*/ for( j = 0; j < jCount; j++ ) { char charIt = itStr.GetChar(j); if( charIt < '0' || charIt > '9' ) { isNumber = false; break; } } if(!genreString.IsEmpty()) genreString.Append(' '); if(isNumber) { //int number = (*itStr).toInt(); long number; itStr.ToLong(&number); if(number >= 0 && number <= 255) { hasNumber = true; genreString.Append(ID3v1_Tag::lookupGenreName(number)); } } else { genreString.append(itStr); } } } // for if(hasNumber) return genreString; } wxString s = frame->toString(); // ID3v2.3 "content type" can contain a ID3v1 genre number in parenthesis at // the beginning of the field. If this is all that the field contains, do a // translation from that number to the name and return that. If there is a // string folloing the ID3v1 genre number, that is considered to be // authoritative and we return that instead. Or finally, the field may // simply be free text, in which case we just return the value. int closing = s.find(wxT(")")); if(s.substr(0, 1) == wxT("(") && closing > 0) { if(closing == int(s.size() - 1)) { long lng; wxString temp = s.substr(1, s.size() - 2); temp.ToLong(&lng); return ID3v1_Tag::lookupGenreName(lng); } else return s.substr(closing + 1); } return s; } return wxT(""); }