//============================================================================== void Linkage::Criteria::expandDownstream( BodyNode* _start, std::vector<BodyNode*>& _bns, bool _includeStart) const { std::vector<Recording> recorder; recorder.reserve(_start->getSkeleton()->getNumBodyNodes()); if(_includeStart) _bns.push_back(_start); recorder.push_back(Recording(_start, 0)); while(recorder.size() > 0) { Recording& r = recorder.back(); if(r.mCount < static_cast<int>(r.mNode->getNumChildBodyNodes())) { stepToNextChild(recorder, _bns, r, mMapOfTerminals, 0); } else { recorder.pop_back(); if(recorder.size() > 0) ++recorder.back().mCount; } } }
bool cCutter::Start(const char *FileName) { if (!cuttingThread) { error = false; ended = false; cRecording Recording(FileName); cMarks FromMarks; FromMarks.Load(FileName); cMark *First=FromMarks.First(); if (First) Recording.SetStartTime(Recording.start+((First->position/FRAMESPERSEC+30)/60)*60); const char *evn = Recording.PrefixFileName('%'); if (evn && RemoveVideoFile(evn) && MakeDirs(evn, true)) { // XXX this can be removed once RenameVideoFile() follows symlinks (see videodir.c) // remove a possible deleted recording with the same name to avoid symlink mixups: char *s = strdup(evn); char *e = strrchr(s, '.'); if (e) { if (strcmp(e, ".rec") == 0) { strcpy(e, ".del"); RemoveVideoFile(s); } } free(s); // XXX editedVersionName = strdup(evn); Recording.WriteInfo(); Recordings.AddByName(editedVersionName, false); cuttingThread = new cCuttingThread(FileName, editedVersionName); return true; } } return false; }
void CMomReplayManager::StopRecording() { if (!Recording()) return; Log("Stopped recording a replay.\n"); m_bRecording = false; delete m_pRecordingReplay; m_pRecordingReplay = nullptr; }
CMomReplayBase* CMomReplayManager::StartRecording() { if (Recording()) return m_pRecordingReplay; Log("Started recording a replay...\n"); m_bRecording = true; m_pRecordingReplay = m_mapCreators.Element(m_mapCreators.Find(m_ucCurrentVersion))->CreateReplay(); return m_pRecordingReplay; }
void RecordManager::start() { if (m_running) { return; } QDateTime start = QDateTime::currentDateTime(); QString filename = start.toString("yyyyMMdd-hhmmss") + ".rec.mov"; m_con->sendCommand("ADD 1-1 FILE " + filename + " -f mov -vcodec h264 -preset veryfast -tune film -acodec aac -r 25 -b 3500000 -ac 2"); m_current = Recording(); m_current.filename = filename; m_current.start = start; m_running = true; }
//============================================================================== void stepToParent(std::vector<Recording>& _recorder, std::vector<BodyNode*>& _bns, Recording& _r, const std::unordered_map<BodyNode*, bool>& _terminalMap) { BodyNode* bn = _r.mNode->getParentBodyNode(); std::unordered_map<BodyNode*, bool>::const_iterator it = _terminalMap.find(bn); if(it != _terminalMap.end()) { bool inclusive = it->second; if(inclusive) _bns.push_back(bn); ++_r.mCount; return; } _recorder.push_back(Recording(bn, -1)); _bns.push_back(bn); }
cDvbPlayer::cDvbPlayer(const char *FileName, bool PauseLive) :cThread("dvbplayer") { nonBlockingFileReader = NULL; ringBuffer = NULL; index = NULL; cRecording Recording(FileName); framesPerSecond = Recording.FramesPerSecond(); isPesRecording = Recording.IsPesRecording(); pauseLive = PauseLive; eof = false; firstPacket = true; playMode = pmPlay; playDir = pdForward; trickSpeed = NORMAL_SPEED; readIndex = -1; readIndependent = false; readFrame = NULL; playFrame = NULL; dropFrame = NULL; isyslog("replay %s", FileName); fileName = new cFileName(FileName, false, false, isPesRecording); replayFile = fileName->Open(); if (!replayFile) return; ringBuffer = new cRingBufferFrame(PLAYERBUFSIZE); // Create the index file: index = new cIndexFile(FileName, false, isPesRecording, pauseLive); if (!index) esyslog("ERROR: can't allocate index"); else if (!index->Ok()) { delete index; index = NULL; } else if (PauseLive) framesPerSecond = cRecording(FileName).FramesPerSecond(); // the fps rate might have changed from the default }
//============================================================================== void Linkage::Criteria::expandUpstream( BodyNode* _start, std::vector<BodyNode*>& _bns, bool _includeStart) const { std::vector<Recording> recorder; recorder.reserve(_start->getSkeleton()->getNumBodyNodes()); if(_includeStart) _bns.push_back(_start); recorder.push_back(Recording(_start, -1)); while(recorder.size() > 0) { Recording& r = recorder.back(); if(r.mCount == -1) { // -1 means we need to take a step upstream if(r.mNode->getParentBodyNode() == nullptr) { // If the parent is a nullptr, we have reached the root ++r.mCount; } else if(recorder.size() == 1 || r.mNode->getParentBodyNode() != recorder[recorder.size()-2].mNode) { // Go toward this node if we did not originally come from this node // or if we're at the first iteration stepToParent(recorder, _bns, r, mMapOfTerminals); } else { // If we originally came from this node, then just continue to the next ++r.mCount; } } else if(r.mCount < static_cast<int>(r.mNode->getNumChildBodyNodes())) { // Greater than -1 means we need to add the children if(recorder.size()==1) { // If we've arrived back at the bottom of the queue, we're finished, // because we don't want to go downstream of the starting BodyNode break; } else if( r.mNode->getChildBodyNode(r.mCount) != recorder[recorder.size()-2].mNode) { // Go toward this node if we did not originally come from this node stepToNextChild(recorder, _bns, r, mMapOfTerminals, -1); } else { // If we originally came from this node, then just continue to the next ++r.mCount; } } else { // If we've iterated through all the children of this node, pop it recorder.pop_back(); // Move on to the next child if(recorder.size() > 0) ++recorder.back().mCount; } } }
int main(int argc, char **argv) { srand (time(NULL)); std::string xmlDocFile = "/home/elli/Documents/colorferet/dvd1/data/ground_truths/xml/recordings.xml"; std::string basePath = "/home/elli/Documents/colorferet/"; std::ofstream* outputTrainingFilestream = GetOutputFile(true); std::ofstream* outputTestFilestream = GetOutputFile(false); pugi::xml_document doc; if (!doc.load_file(xmlDocFile.c_str())) { std::cerr << "Failed to load XML doc \'" << xmlDocFile << "\'" << std::endl; exit(-1); } std::list<Recording> recordingList; pugi::xml_node recordingsNode = doc.child("Recordings"); pugi::xml_object_range<pugi::xml_named_node_iterator> recordingsIterator = doc.child("Recordings").children("Recording"); for (pugi::xml_named_node_iterator it = recordingsIterator.begin(); it != recordingsIterator.end(); it++) { std::string fileRoot = (*it).child("URL").attribute("root").value(); std::string filePathWithExtension = (*it).child("URL").attribute("relative").value(); std::string filePath = filePathWithExtension.substr(0, filePathWithExtension.length()-4); std::string subject = (*it).child("Subject").attribute("id").value(); Recording newRecording = Recording(subject, basePath, fileRoot, filePath); if (newRecording.GetSubjectId() < 5) { // to keep this small only going to kee the forst 45 ppl recordingList.push_back(newRecording); } } int width = 32; int height = 48; std::cout << recordingList.size() << std::endl; cv::Size desiredImageSize (width, height); int counter = 0; int trainingCount = 0; int testingCount = 0; int totalCounts = recordingList.size()*recordingList.size(); int proposedTrainingCount = (double) totalCounts * 0.7; std::cout << proposedTrainingCount <<std::endl; int proposedTestingCount = totalCounts-proposedTrainingCount; (*outputTestFilestream) << proposedTestingCount << " " << width*height*2 << " " << 1 << std::endl; (*outputTrainingFilestream) << proposedTrainingCount << " " << width*height*2 << " " << 1 << std::endl; (*outputTestFilestream).setf(std::ios::fixed); (*outputTestFilestream) << std::setprecision(3); (*outputTrainingFilestream).setf(std::ios::fixed); (*outputTrainingFilestream) << std::setprecision(3); for (std::list<Recording>::iterator itOuter = recordingList.begin(); itOuter != recordingList.end(); itOuter++) { counter++; if(counter%10 == 0) { std::cout << counter << std::endl; } cv::Mat currentImage = cv::imread(itOuter->GetFilePath(), cv::IMREAD_GRAYSCALE); cv::Mat resizedCurrentImage; cv::resize(currentImage, resizedCurrentImage, desiredImageSize, 0, 0, CV_INTER_AREA); //std::cout << "Current Size: " << resizedCurrentImage.size() << std::endl; for (std::list<Recording>::iterator itInner = recordingList.begin(); itInner != recordingList.end(); itInner++) { cv::Mat currentInnerImage = cv::imread(itInner->GetFilePath(), cv::IMREAD_GRAYSCALE); cv::Mat resizedInnerImage; cv::resize(currentInnerImage, resizedInnerImage, desiredImageSize, 0, 0, CV_INTER_AREA); std::ofstream* outputFilestream; double myRand = ((double) rand() / (RAND_MAX)); if ((myRand < 0.7 && trainingCount < proposedTrainingCount)|| testingCount >=proposedTestingCount) { outputFilestream = outputTrainingFilestream; trainingCount++; } else { outputFilestream = outputTestFilestream; testingCount++; } for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { cv::Scalar intensity = resizedCurrentImage.at<uchar>(x,y); (*outputFilestream) << (double) intensity[0]/255 << " "; } } for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { cv::Scalar intensity = resizedInnerImage.at<uchar>(x,y); (*outputFilestream) << (double) intensity[0]/255 << " "; } } if (itOuter->GetSubjectId() == itInner->GetSubjectId()) { (*outputFilestream) << 1; } else { (*outputFilestream) << 0; } (*outputFilestream) << std::endl; } } std::cout << trainingCount << " " << testingCount << std::endl; outputTestFilestream->close(); outputTrainingFilestream->close(); }