void LSDWrapper::run()
{
	std::cout << "Waiting for Video" << std::endl;

	// wait for firsst image
	while(!newImageAvailable)
		usleep(100000);	// sleep 100ms
	newImageAvailable = false;
	while(!newImageAvailable)
		usleep(100000);	// sleep 100ms

	// read image height and width**temporarily*** 
	frameWidth = 640;
	frameHeight = 480;

	ResetInternal();


	snprintf(charBuf,200,"Video resolution: %d x %d",frameWidth,frameHeight);
	ROS_INFO(charBuf);
	node->publishCommand(std::string("u l ")+charBuf);

	// create window
	Util::displayImage("LSD SLAM Drone Camera Feed", image.data);

	// Framewidth size removed
	changeSizeNextRender = true;

	boost::unique_lock<boost::mutex> lock(new_frame_signal_mutex);

	while(keepRunning)
	{
		if(newImageAvailable)
		{
			newImageAvailable = false;

			mimFrameBW_workingCopy.copy_from(mimFrameBW);

			// release lock and do the work-intensive stuff.....
			lock.unlock();

			HandleFrame();


			if(changeSizeNextRender)
			{
				myGLWindow->set_size(desiredWindowSize);
				changeSizeNextRender = false;
			}

			// get lock again
			lock.lock();
		}
		else
			new_frame_signal.wait(lock);
	}

	lock.unlock();
	delete myGLWindow;
}
void PTAMWrapper::run()
{
	std::cout << "Waiting for Video" << std::endl;

	// wait for firsst image
	while(!newImageAvailable)
		usleep(100000);	// sleep 100ms
	newImageAvailable = false;
	while(!newImageAvailable)
		usleep(100000);	// sleep 100ms

	// read image height and width
	frameWidth = mimFrameBW.size().x;
	frameHeight = mimFrameBW.size().y;

	ResetInternal();


	snprintf(charBuf,200,"Video resolution: %d x %d",frameWidth,frameHeight);
	ROS_INFO(charBuf);
	node->publishCommand(std::string("u l ")+charBuf);

	// create window
    myGLWindow = new GLWindow2(CVD::ImageRef(frameWidth,frameHeight), "PTAM Drone Camera Feed", this);
	myGLWindow->set_title("PTAM Drone Camera Feed");

	changeSizeNextRender = true;
	if(frameWidth < 640)
		desiredWindowSize = CVD::ImageRef(frameWidth*2,frameHeight*2);
	else
		desiredWindowSize = CVD::ImageRef(frameWidth,frameHeight);

	while(keepRunning)
	{
		if(newImageAvailable)
		{
			HandleFrame();

			if(changeSizeNextRender)
			{
				myGLWindow->set_size(desiredWindowSize);
				changeSizeNextRender = false;
			}
		}
		else
			usleep(2000);	// TODO: really, really, REALLY dirty hack: busy-wait. replace by some proper signal.
	}

	delete myGLWindow;
}
Example #3
0
void Game::Execute()
{
	// Begin activity
	isActive = true;

	gameWindow.create(sf::VideoMode(500, 500), "myExtraCreditProg");
	gameWindow.setFramerateLimit(60);

	actors[0] = &hunter;
	actors[1] = &dodo;
	actors[2] = &fox;

	h_SpeedX = 1;
	h_SpeedY = 1;

	d_SpeedX = -1;
	d_SpeedY = 1;

	f_SpeedX = 1;
	f_SpeedY = -1;

	for(int i=0; i<3; i++)
		renderable[i] = true;
	

	for(int i=0; i<3; i++)
		actors[i]->Load();

	// Continuous loop until the simulation has been told to terminate
	while ( isActive )
	{
		EventHandling();
		HandleFrame();
		Render();
	}
	gameWindow.close();
}
Example #4
0
void PTAMWrapper::run()
{
	std::cout << "Waiting for Video" << std::endl;

	// wait for firsst image
	while(!newImageAvailable)
		usleep(100000);	// sleep 100ms
	newImageAvailable = false;
	while(!newImageAvailable)
		usleep(100000);	// sleep 100ms

	// read image height and width
	frameWidth = mimFrameBW.size().x;
	frameHeight = mimFrameBW.size().y;

	ResetInternal();


	snprintf(charBuf,200,"Video resolution: %d x %d",frameWidth,frameHeight);
	ROS_INFO(charBuf);
	node->publishCommand(std::string("u l ")+charBuf);

	// create window
//    myGLWindow = new GLWindow2(CVD::ImageRef(frameWidth,frameHeight), "PTAM Drone Camera Feed", this);
//	myGLWindow->set_title("PTAM Drone Camera Feed");

    std::cout << "hein 0" << std::endl;
	changeSizeNextRender = true;
	if(frameWidth < 640)
		desiredWindowSize = CVD::ImageRef(frameWidth*2,frameHeight*2);
	else
		desiredWindowSize = CVD::ImageRef(frameWidth,frameHeight);


	boost::unique_lock<boost::mutex> lock(new_frame_signal_mutex);

	std::cout << "hein 1" << std::endl;

	while(keepRunning)
	{
        std::cout << "hein 2" << std::endl;
		if(newImageAvailable)
		{
			newImageAvailable = false;

			// copy to working copy
			mimFrameBW_workingCopy.copy_from(mimFrameBW);
			mimFrameTime_workingCopy = mimFrameTime;
			mimFrameSEQ_workingCopy = mimFrameSEQ;
			mimFrameTimeRos_workingCopy = mimFrameTimeRos;

			std::cout << "hein 3" << std::endl;
			// release lock and do the work-intensive stuff.....
			lock.unlock();

			HandleFrame();


			if(changeSizeNextRender)
			{
				//myGLWindow->set_size(desiredWindowSize);
				changeSizeNextRender = false;
			}
            std::cout << "hein 4" << std::endl;
			// get lock again
			lock.lock();
		}
		else
			new_frame_signal.wait(lock);
	}

	lock.unlock();
	//delete myGLWindow;
}