当前位置: 首页>>代码示例>>C++>>正文


C++ Filter::getFileData方法代码示例

本文整理汇总了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;
//.........这里部分代码省略.........
开发者ID:SparkysRunawayCircuitCrew,项目名称:VisionCode,代码行数:101,代码来源:filter.cpp


注:本文中的Filter::getFileData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。