Example #1
0
int main( int argc, char** argv )
{

	if (parse_arguments(argc, argv, &haar_cascade_path, &asef_locator_path))
		return -1;
#if 0
	struct sigaction act;
	act.sa_handler = termination_handler; 
	sigemptyset(&act.sa_mask);
	act.sa_flags = 0;
	sigaction(SIGINT, &act, NULL);
#endif

	int frame_width, frame_height;

	if ( asef_initialze(&asef, asef_locator_path, haar_cascade_path) )
		return -1;

	if( !(capture = cvCaptureFromCAM(-1)) ) {
		fprintf( stderr, "ERROR: capture is NULL \n" );
		return -1;
	}

	get_camera_properties(capture, &frame_width, &frame_height, NULL);

	CvSize frame_size = cvSize(frame_width, frame_height);

	IplImage* frame = NULL;
	color_img = cvCreateImage( frame_size, IPL_DEPTH_8U, 3 );
	gray_img = cvCreateImage( frame_size, IPL_DEPTH_8U, 1);

	cvNamedWindow(window_title, 0);
	while (1){
		printf("\r"); fflush(stdout); 
		printf("FPS: %f  ", calculate_fps());

		frame = cvQueryFrame(capture);
		cvCopyImage(frame, color_img);
		cvCvtColor(color_img, gray_img, CV_RGB2GRAY);
		asef.input_image = gray_img;

		if( asef_detect_face(&asef) ){
			asef_locate_eyes(&asef);
			draw_markers(color_img, asef.face_rect, asef.left_eye, asef.right_eye);
		}

    // Mirroring results. assuming you're using a frontal facing camera
		cvFlip(color_img, color_img, 1);
		cvShowImage( window_title, color_img);
                cvWaitKey(1);
	} 
	return 0;
}
Example #2
0
void render()
{
	glClear(GL_COLOR_BUFFER_BIT);
	glColor3f(1.0f, 0.0f, 0.0f);

	calculate_field_size();

	draw_food();
	draw_ants();
	if (grid)
		draw_grid();
	calculate_fps();
	if (debug) {
		draw_debug();
	}

	glutSwapBuffers();
}
Example #3
0
void GameTime_Impl::update()
{
	ubyte64 last_time = current_time;

	current_time = System::get_microseconds();

	if (current_time < last_time)		// Old cpu's may report time travelling on early multicore processors (iirc)
		last_time = current_time;

	ubyte64 ticks_per_microsecond = 1000000 / ticks_per_second;
	ubyte64 current_tick = (current_time - start_time) / ticks_per_microsecond;

	ticks_elapsed = current_tick - last_tick;
	time_elapsed_ms = (int) ((current_time - last_time) / 1000);
	time_elapsed = (float)((current_time - last_time) / (double) 1000000);
	tick_interpolation_time = (float)(((current_time - start_time) % ticks_per_microsecond) / (double)ticks_per_microsecond);

	last_tick = current_tick;

	if (min_update_time_ms)	// Handle max fps
		process_max_fps();

	calculate_fps();
}