Exemplo n.º 1
0
//  Display next frame
bool next()
{
	static bool first = true;
	if(_decoder.getNextFrame(&_frame)) {
		++_currentFrame;

		if(first) {
			_fh = _frame.height();
			_fw = _frame.width();
			createMask();
			getBestFrames((folder+"/BgCandidates/_GraphcutInfo.txt").toStdString());
			first = false;

			_width = 2000;
			_height = 1500;
			screen = new unsigned char[_width*_height*4];
		}
	 
		bool important = false;
		for(int i = 0; i < _bestFrames.size(); ++i) {
			if(_bestFrames[i].id == _currentFrame)
				important = true;
		}

		if(!important)
			return true;
		
		_framePos1 = _homographies[_currentFrame] * vec3(-_fw/2, _fh/2, 1);
 		_framePos2 = _homographies[_currentFrame] * vec3(-_fw/2, -_fh/2, 1);
		_framePos3 = _homographies[_currentFrame] * vec3(_fw/2, -_fh/2, 1);
		_framePos4 = _homographies[_currentFrame] * vec3(_fw/2, _fh/2, 1);

		
		memset(screen, 0, _width*_height*3);
		flipV(screen, _width, _height, 3);
		SoftwareRenderer::render(RX::vec3(255, 0, 255), _framePos1, _framePos2, _framePos3, _framePos4, screen, _width, _height, 3);
		SoftwareRenderer::renderNoColorAB(_frame, RX::vec3(255, 0, 255), RX::vec3(0, 255, 0), _framePos1, _framePos2, _framePos3, _framePos4, screen, _width, _height, 4, 3);

		for(int i = 0; i < _width*_height; ++i) {
			char swap = screen[i*3];
			screen[i*3] = screen[i*3+2];
			screen[i*3+2] = swap;
		}
		
		char buf[50];
		sprintf(buf, "/BgCandidates/mask%d.png", _currentFrame);
		QImage maskImg(screen, _width, _height, QImage::Format_RGB888);
		maskImg.save(folder+buf);

		return true;
	}
	else
		return false;
}