本文整理汇总了C++中Filter::getFileData方法的典型用法代码示例。如果您正苦于以下问题:C++ Filter::getFileData方法的具体用法?C++ Filter::getFileData怎么用?C++ Filter::getFileData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Filter
的用法示例。
在下文中一共展示了Filter::getFileData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[]) {
signal(SIGINT, interrupted);
signal(SIGTERM, interrupted);
// Evalutate/check command line arguments
Options opts(argc, argv);
if (opts.isOk() != true) {
return 1;
}
Filter filter;
filter.setRedEnabled(opts.isRedEnabled());
filter.setYellowEnabled(opts.isYellowEnabled());
// If processing a single file (-f FILE)
if (opts.isFileMode()) {
Mat orig = imread(opts.getImageFile());
// Create base name for output files
string baseName(opts.getImageFile());
int pos = baseName.rfind('.');
if (pos != string::npos) {
baseName.erase(pos);
}
avc::Timer timer;
Found found = filter.filter(orig);
filter.printFrameRate(cout, timer.secsElapsed());
// Write out individual image files
filter.writeImages(baseName, orig, false);
// Return 0 to parent process if we found image (for scripting)
return (found == Found::None ? 1 : 0);
}
// Video processing
VideoCapture videoFeed(0);
{
int attempts = 0;
while (!videoFeed.isOpened()) {
float waitSecs = 3;
attempts++;
cerr << "Failed to open camera on attempt " << attempts
<< ", trying again in "
<< waitSecs << " seconds.\n";
avc::Timer::sleep(waitSecs);
if (isInterrupted) {
return 1;
}
videoFeed.release();
videoFeed.open(0);
}
}
videoFeed.set(CV_CAP_PROP_FRAME_WIDTH, 320);
videoFeed.set(CV_CAP_PROP_FRAME_HEIGHT, 240);
Mat origFrame;
// Where to write out information about what we see
ofstream stanchionsFile(opts.getStanchionsFile());
// Get initial frame and toss (incase first one is bad)
videoFeed >> origFrame;
avc::Timer timer;
int foundLast = -1;
while (!isInterrupted) {
videoFeed >> origFrame;
int found = filter.filter(origFrame);
if ((found != foundLast) || opts.verbose()) {
opts.writeToChangeDir(origFrame, filter.getFileData().frameCount);
filter.printFrameRate(cout, timer.secsElapsed());
foundLast = found;
} else {
// No change in detection state, however, go write out image
// if user enabled the periodic feature (-p PERIODIC) and we've
// reached the periodic count
opts.writePeriodic(origFrame, filter.getFileData().frameCount);
}
stanchionsFile.seekp(0);
stanchionsFile.write((const char*) &filter.getFileData(), sizeof(FileData));
stanchionsFile.flush();
}
if (filter.getFileData().frameCount > 0) {
filter.printFrameRate(cout, timer.secsElapsed());
filter.writeImages(opts.getOutputDir() + "/avc-vision", origFrame, true);
} else {
cout << "***ERROR*** Failed to read/process any video frames from camera\n";
}
return 0;
//.........这里部分代码省略.........