void SpecificWorker::compute()
{
	try
	{
		vector<string> names;
		names.push_back("default");
		RoboCompRGBDBus::ImageMap imgs;
		rgbdbus_proxy->getImages(names, imgs);
		Mat frame(imgs["default"].camera.colorHeight, imgs["default"].camera.colorWidth, CV_8UC3,  &(imgs["default"].colorImage)[0]);
		drawQtImage((const uchar *)(&(imgs["default"].colorImage)[0]), imgs["default"].camera.colorWidth, imgs["default"].camera.colorHeight, QImage::Format_RGB888, label);
		
		/// Apply Laplace function
		Mat gray, dst, abs_dst;
		cvtColor( frame, gray, CV_RGB2GRAY );
		Laplacian( gray, dst, CV_16S, 3, 1, 0, BORDER_DEFAULT );
		convertScaleAbs( dst, abs_dst );
		drawQtImage( (const uchar *)(abs_dst.data), imgs["default"].camera.colorWidth, imgs["default"].camera.colorHeight, QImage::Format_Indexed8, label_edges);
		
		printFPS();
		//imshow("img", frame);
	}
	catch(const Ice::Exception &e)
	{
		std::cout << "Error reading from Camera" << e << std::endl;
	}
}
示例#2
0
void doFPS(unsigned long int curtime, unsigned int interval)
{
	countFrame();
	if (curtime >= framelasttime + interval)
	{
		makeFPS(curtime);
		printFPS();
	}
}
/**
* \brief Thread method
*/
void Worker::run()
{
	init();
	while (!_finished)
	{
		if( uvcGrab() == false)
			qFatal ( "Wroker:run() -> Fatal error: uvcgrab() returned error" );
		printFPS();
	}
}
示例#4
0
void Engine::run()
{
    QTimer simulationTimer;
    connect(&simulationTimer, SIGNAL(timeout()), this, SLOT(simulationStep()));
    simulationTimer.start(1000 / FPS);

    QTimer fpsTimer;
    connect(&fpsTimer, SIGNAL(timeout()), this, SLOT(printFPS()));
    fpsTimer.start(1000);

    exec();
}
/**
 * Run method for thread
 */
void ieee1394capture::run( )
{
	while ( !_finished )
	{
// 		if(!sleeped)
		{
			if ( grab() == false )
				qFatal ( "ieee1394capture::run() -> Fatal error: grab() returned error" );
			printFPS();

		}
	}
}
// Distributes task for the "key" kind of events 
// For example : cout when b key is pressed
// down is true when the key is pressed, false when released
void Application::handleKeyEvent(const SDL_keysym& keysym, bool down) {
    if (down) {
        switch (keysym.sym) {
            case SDLK_ESCAPE:
                m_bRunning = false;
                break;
            case SDLK_f:
                printFPS();
                break;
            default:
                break;
        }
    }
}
示例#7
0
/*
WizardEntity* createWizardEntity(string name, GLfloat* vertices, float radius, float x, float y, float z) { 
	return new WizardEntity(new Vector(x, y, z), createTexture(name), vertices, radius); 
}

// Each texture being created goes through the same method calls and is named with a number, referenced by index.
GLuint* createTexture(string name) {
	GLuint* texture = new GLuint;
	SDL_Surface* textureSurface = SDL_LoadBMP( ("resources\\" + name + ".bmp").c_str() );
	if(textureSurface == NULL) cout << "SDL_LoadBMP: " << SDL_GetError() << endl;

	glGenTextures(1, texture);
	glBindTexture(GL_TEXTURE_2D, *texture);
	glTexImage2D(	GL_TEXTURE_2D, 0, 3,
					textureSurface->w, textureSurface->h, 0,
					GL_BGR, GL_UNSIGNED_BYTE, textureSurface->pixels );
	glTexParameteri( GL_TEXTURE_2D,
						GL_TEXTURE_MIN_FILTER,
						GL_LINEAR );
	glTexParameteri( GL_TEXTURE_2D,
						GL_TEXTURE_MAG_FILTER,
						GL_LINEAR );

	SDL_FreeSurface( textureSurface );

	return texture;
}
*/
void pollEventsAndDraw() {
    static GLint initialTime = 0;
    static GLint frames = 0;
	SDL_Event event;
	bool running = true;
	bool keys[282] = { false };
	
	// ========== START TEST ========== //
#ifdef cubeVertNotes
	GLfloat cube[72] = { // Front face
-1.0, -1.0,  1.0,
 1.0, -1.0,  1.0,
 1.0,  1.0,  1.0,
-1.0,  1.0,  1.0,
// Back face
-1.0, -1.0, -1.0,
-1.0,  1.0, -1.0,
 1.0,  1.0, -1.0,
 1.0, -1.0, -1.0,
// Top face
-1.0,  1.0, -1.0,
-1.0,  1.0,  1.0,
 1.0,  1.0,  1.0,
 1.0,  1.0, -1.0,
// Bottom face
-1.0, -1.0, -1.0,
 1.0, -1.0, -1.0,
 1.0, -1.0,  1.0,
-1.0, -1.0,  1.0,
// Right face
 1.0, -1.0, -1.0,
 1.0,  1.0, -1.0,
 1.0,  1.0,  1.0,
 1.0, -1.0,  1.0,
// Left face
-1.0, -1.0, -1.0,
-1.0, -1.0,  1.0,
-1.0,  1.0,  1.0,
-1.0,  1.0, -1.0}; // default cube
#endif
	/*bool collision[5] = {false};
	LinkedList* entities = new LinkedList();
	*/
	PlayerEntity* player = createPlayerEntity(0, 1.0f, 0, NULL);
	Level* level = new Level("TEST.txt",player);

	/*GLfloat modelVert[12] = {
		-1.0, -1.0,  0,
		 1.0, -1.0,  0,
		 1.0,  1.0,  0,
		-1.0,  1.0,  0};
	Entity* tmpModel = createEntity("1", NULL, &modelVert[0], 0, 1.0f, -10.0f, NULL);
	tmpModel->incrementYOf(ROTATION, 20.0f);

	GLfloat floorVert[12] = { 
		-6.0, 0.0,  40.0,
		 6.0, 0.0,  40.0,
		 6.0, 0.0, -40.0,
		-6.0, 0.0, -40.0};
	PlaneEntity* tmpFloor = createPlaneEntity("2", NULL, HORIZONTAL, &floorVert[0], 0, 0, 0);

	GLuint* wallTex = createTexture("3");
	GLfloat wallVert[12] = { 
		0.0, 0.0,  30.0,
		0.0, 10.0,  30.0,
		0.0, 10.0, -40.0,
		0.0, 0.0, -40.0};
	PlaneEntity* tmpWall1 = createPlaneEntity("", wallTex, VERTICAL_Z, &wallVert[0], -6.0f, 0, 0);
	PlaneEntity* tmpWall2 = createPlaneEntity("", wallTex, VERTICAL_Z, &wallVert[0], 6.0f, 0, 0);
	
	GLuint* stepTex = createTexture("4");
	GLfloat floorVert2[12] = { 
		-1.0, 0.0,  3.0,
		 1.0, 0.0,  3.0,
		 1.0, 0.0, -3.0,
		-1.0, 0.0, -3.0};
	PlaneEntity* tmpFloor2 = createPlaneEntity("", stepTex, HORIZONTAL, floorVert2, 0, 2.0f, -7.0f);
	GLfloat floorVert3[12] = { 
		-1.0, 2.0,  0.0,
		 1.0, 2.0,  0.0,
		 1.0, -2.0, 0.0,
		-1.0, -2.0, 0.0};
	PlaneEntity* tmpFloor3 = createPlaneEntity("", stepTex, VERTICAL_X, floorVert3, 0, 0.0f, -4.0f);

	BlockEntity* tmpBlock = createBlockEntity("", stepTex, 0.0f, 0.25f, 7.0f, 4.0f, 0.5f, 5.0f);

	//entities->add(tmpModel);
	entities->add(tmpWall1);
	entities->add(tmpWall2);
	entities->add(tmpFloor);
	entities->add(tmpFloor2);
	entities->add(tmpFloor3);
	entities->add(tmpBlock);*/
	// ========== END TEST ========== //

	while( running ) {
		if( SDL_PollEvent(&event) ) {
			if(event.key.keysym.sym == SDLK_ESCAPE || event.type == SDL_QUIT) {
				running = false;
			} else if(event.type == SDL_KEYDOWN) {
				if(event.key.keysym.sym == SDLK_SPACE) player->jump();
				else if(event.key.keysym.sym == SDLK_x) player->turn180();
				keys[event.key.keysym.scancode] = true;
			} else if(event.type == SDL_KEYUP) {
				keys[event.key.keysym.scancode] = false;
			}
		}
		movePlayer(keys, player);

		// ========== START TEST ========== //
		player->incrementYOf(VELOCITY, -0.2f); // gravity hack
		/*
			// Must be  in level superclass: ******
		glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
		glLoadIdentity();

		glColor3f(1, 1, 1);

		GLfloat matrix[16];
		glGetFloatv(GL_MODELVIEW_MATRIX, matrix);

#ifndef COLLIDED_CONSOLE_HERE
		if(player->hasCollided(tmpModel)) {
			if(!collision[0]) {
				cout << "Collision: Model" << endl;
				collision[0] = true;
			}
		} else if(collision[0] == true) collision[0] = false;
		
		if(player->hasCollided(tmpWall1)) {
			if(!collision[1]) {
				cout << "Collision: Wall1" << endl;
				collision[1] = true;
			}
		} else if(collision[1] == true) collision[1] = false;
		
		if(player->hasCollided(tmpWall2)) {
			if(!collision[2]) {
				cout << "Collision: Wall2" << endl;
				collision[2] = true;
			}
		} else if(collision[2] == true) collision[2] = false;

		if(player->hasCollided(tmpFloor)) {
			if(!collision[3]) {
				cout << "Collision: Floor" << endl;
				collision[3] = true;
			}
		} else if(collision[3] == true) collision[3] = false;
#endif
		*/
		//player->drawSelf(matrix, entities); // Used to adjust camera based on player position
		//glLoadMatrixf(matrix);

		//entities->drawSelf();
			// ******************************* //
		// ========== END TEST ========== //
		level->drawEverything();
		
		SDL_GL_SwapWindow(mainWindow);

		printFPS(frames, initialTime);
	}
	
		// ========== START TEST ========== //
	// Remember to delete all models (should be entity linked list) when done!
	delete tmpModel;
	delete tmpWall1;
	delete tmpWall2;
	delete tmpFloor;
	delete player;
		// ========== END TEST ========== //
}