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


C++ EventPtr::addFrame方法代码示例

本文整理汇总了C++中EventPtr::addFrame方法的典型用法代码示例。如果您正苦于以下问题:C++ EventPtr::addFrame方法的具体用法?C++ EventPtr::addFrame怎么用?C++ EventPtr::addFrame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EventPtr的用法示例。


在下文中一共展示了EventPtr::addFrame方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: convertToEvent

/**
 * @brief Video::convertToEvent
 * @param path
 * @return
 */
EventPtr Video::convertToEvent(std::string path){
	cv::Mat shot;
	FramePtr frame;
	EventPtr event;

	unsigned int j=0;
	int framecount=0;

	double tmpPos = getFramePos();
	setFramePos(0);

	emit startProgress(0, (uint) getLengthFrames());

	while(getNextFrame(shot)){
		emit progressChanged(j);

		if (event.isNull()){
			event = EventPtr(new Event(this));
		}
		// create new frame
		frame = FramePtr(new Frame(this, shot, path));
		// add frame to event
		event->addFrame(frame);
		framecount ++;
		j++;
	}

	setFramePos(tmpPos);

	return event;
}
开发者ID:BioFoV,项目名称:BioFoV,代码行数:36,代码来源:Video.cpp

示例2: startProgress

/**
 * @brief Automatically splits the video into several events provided the
 * given parameters.
 * @param threshold
 * @param maxcount
 * @param mincount
 * @param history
 * @param varThreshold
 * @param bShadowDetection
 * @param path
 * @return
 */
std::deque<EventPtr> Video::autoDetectEvents(double threshold,
										   double maxcount,
										   double mincount,
										   int history,
										   int varThreshold,
										   bool bShadowDetection,
										   std::string path){
	cv::Mat shot;
	FramePtr frame;
	SnapshotPtr snap;
	EventPtr event;
	std::deque<EventPtr> events;

	unsigned int j=0;
	int emptycount=0;
	int framecount=0;
	int value;
	int absoluteThreshold = threshold/100*resolution.width*resolution.height;
	int i;


	// Initialization of background subtraction
	bgSubInit(history, varThreshold, bShadowDetection);

	setFramePos(0);

	emit startProgress(0, (uint) getLengthFrames());

	while(getNextFrame(shot)){
		QCoreApplication::processEvents();
		if (toCancel){
			events.clear();
			canceled();
			return events;
		}
		bg->NewFrame(shot);
		bg->Denoise();
		emit progressChanged(j);
		value = cv::countNonZero(bg->Foreground());

		// Detected change
		if ( value > absoluteThreshold ){
			if (event.isNull()){
				event = EventPtr(new Event(this));
			}
			// create new frame
			frame = FramePtr(new Frame(this, shot, path));
			snap = SnapshotPtr(new Snapshot(frame, bg->Foreground(), path));
			// add frame to event
			event->addFrame(frame);
			event->addSnapshot(snap);
			framecount ++;
			emptycount = 0;
		}
		// Did not detect change
		else if (!event.isNull()){
			emptycount ++;
			// create new frame
			frame = FramePtr(new Frame(this, shot, path));
			snap = SnapshotPtr(new Snapshot(frame, bg->Foreground(), path));
			// add frame to event
			event->addFrame(frame);
			event->addSnapshot(snap);
			framecount ++;
			if(emptycount > maxcount){
				if (framecount - emptycount > mincount){
					// remove extra frames with no movement
					for (i = 0; i < maxcount; i++){
						event->remLastFrame();
						event->remLastSnapshot();
					}
					events.push_back(event);
				}
				event.clear();
				emptycount = 0;
				framecount = 0;
			}
		}
		j++;
	}
	// Check if Video ended in the middle of an Event.
	if (!event.isNull()){
		if (framecount > mincount){
			events.push_back(event);
		} else {
			event.clear();
		}
	}
//.........这里部分代码省略.........
开发者ID:BioFoV,项目名称:BioFoV,代码行数:101,代码来源:Video.cpp


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