VisionEngine::VisionEngine(const char* name, application_settings *config) : error_( false ) , pause_( false ) , calibrate_( false ) , help_( false ) , display_lock_( false ) , current_fps_( 0 ) , camera_ (NULL) , framenumber_( 0 ) #ifndef NDEBUG , recording_( false ) #endif , interface_ ( NULL ) , frames_( 0 ) , width_( WIDTH ) , height_( HEIGHT ) , format_( 1 ) { app_config_ = config; camera_config_ = CameraTool::readSettings(app_config_->camera_config); setupCamera(); lastTime_ = currentSeconds(); cameraTime_ = processingTime_ = interfaceTime_ = totalTime_ = 0.0f; app_name_ = std::string(name); }
void VisionEngine::frameStatistics(long cameraTime, long processingTime, long totalTime) { frames_++; cameraTime_+=cameraTime; processingTime_+=(processingTime-cameraTime); interfaceTime_+=(totalTime-processingTime); totalTime_+=totalTime; long currentTime_ = currentSeconds(); long diffTime = currentTime_ - lastTime_ ; if (diffTime >= 1) { current_fps_ = (int)floor( (frames_ / diffTime) + 0.5 ); std::cout << current_fps_ << "fps "; std::cout << std::fixed << std::setprecision(2) << "c:" << (cameraTime_/frames_)/1000.0f << "ms p:" << (processingTime_/frames_)/1000.0f << "ms i:" << (interfaceTime_/frames_)/1000.0f << "ms t:" << (totalTime_/frames_)/1000.0f << "ms" << std::endl; cameraTime_ = processingTime_ = interfaceTime_ = totalTime_ = 0.0f; lastTime_ = currentTime_; frames_ = 0; } }
void display(void) { static double t0 /*= currentSeconds()*/; double t1, elapsedTime; static unsigned N; float fps; char cfps[256]; glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(ortho_left, -ortho_left, ortho_bottom, -ortho_bottom, ortho_znear, ortho_zfar); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(eye_x, eye_y, eye_z, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); glPushMatrix(); glRotatef(angle, rotate_x, rotate_y, rotate_z); drawAxes(); glPopMatrix(); glTranslatef(translate_x, translate_y, translate_z); glPushMatrix(); glRotatef(angle, rotate_x, rotate_y, rotate_z); drawJulia(); glPopMatrix(); /* compute FPS */ N++; t1 = currentSeconds(); elapsedTime = t1 - t0; if (elapsedTime > FPS_TIME_WINDOW) { fps = (float) N / elapsedTime; N = 0; t0 = t1; sprintf(cfps, "Julia Fractal GL (%d x %d): %3.1f fps", WIDTH, HEIGHT, fps); printf("%s\n", cfps); glutSetWindowTitle(cfps); } glutPostRedisplay(); glutSwapBuffers(); }
void display(void) { static unsigned n; static double t0; double t1, elapsedTime; float fps; char cfps[256]; glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(eye_x, eye_y, eye_z, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); glRotatef(rotate_y_angle, 0.0, 1.0, 0.0); glRotatef(rotate_x_angle, 1.0, 0.0, 0.0); glRotatef(rotate_z_angle, 0.0, 0.0, 1.0); drawSpace(); drawJulia(dm); n++; t1 = currentSeconds(); elapsedTime = t1 - t0; if (elapsedTime > FPS_TIME_WINDOW) { fps = (float) n / elapsedTime; n = 0; t0 = t1; sprintf(cfps, "Julia Fractal GL (%d x %d): %3.1f fps", WIDTH, HEIGHT, fps); printf("%s\n", cfps); glutSetWindowTitle(cfps); } glutPostRedisplay(); glutSwapBuffers(); }
void display(void) { int i, j, m, n; int color; float deltax = (XMAX-XMIN)/JULIA_WIDTH, deltay = (YMAX-YMIN)/JULIA_HEIGHT; static double t0 /*= currentSeconds()*/; double t1, elapsedTime; static unsigned N; float fps; char cfps[256]; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(0.0, 0.0, eye_z, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); glTranslatef(0.0, 0.0, translate_z); glRotatef(rotate_x, 1.0, 0.0, 0.0); glRotatef(rotate_y, 0.0, 1.0, 0.0); /* draw the x-z plane */ glColor3f(1.0, 1.0, 1.0); glBegin(GL_LINES); n = JULIA_WIDTH/2; for (i = 0; i <= JULIA_WIDTH; i += 32) { glVertex3i(i-n, 0, 0); glVertex3i(i-n, 0, -512); } for (j = 0; j <= 512; j += 32) { glVertex3i(-n, 0, -j); glVertex3i( n, 0, -j); } glEnd(); /* draw Julia */ glBegin(GL_POINTS); n = JULIA_WIDTH/2; m = JULIA_HEIGHT/2; for (i = 0; i < JULIA_WIDTH; i++) { for (j = 0; j < JULIA_HEIGHT; j++) { color = genColorJulia(XMIN + (float)(i) * deltax, YMIN + (float)(j) * deltay, theta); glColor3f((float)( color&0xff ) /128, (float)((color&0xff00 )>> 8)/128, (float)((color&0xff0000)>>16)/128); glVertex3i(i-n, j-m, 0); if (j >= 0 && j < 64) glVertex3i(i-n, j-m, -128); else if (j >= 64 && j < 128) glVertex3i(i-n, j-m, -256); else if (j >= 128 && j < 192) glVertex3i(i-n, j-m, -384); else glVertex3i(i-n, j-m, -512); } } glEnd(); /* compute FPS */ N++; t1 = currentSeconds(); elapsedTime = t1 - t0; if (elapsedTime > FPS_TIME_WINDOW) { fps = (float) N / elapsedTime; N = 0; t0 = t1; sprintf(cfps, "Julia Fractal GL (%d x %d): %3.1f fps", WIDTH, HEIGHT, fps); printf("%s\n", cfps); glutSetWindowTitle(cfps); } glutPostRedisplay(); glutSwapBuffers(); }
void display(void) { static unsigned N; static double t0; double t1, elapsedTime; float fps; char cfps[256]; glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); /* left viewport */ glViewport(0, 0, WIDTH/2, HEIGHT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(60, 1.0, 16.0, 512.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(160.0, 64.0, 160.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); glPushMatrix(); glRotatef(angle, 0.0, 1.0, 0.0); drawPlane(); drawJulia(); glPopMatrix(); /* right viewport */ glViewport(WIDTH/2, 0, WIDTH/2, HEIGHT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-256.0, 256.0, -256.0, 256.0, 0.0, 512.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(160.0, 64.0, 160.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); glPushMatrix(); glRotatef(angle, 0.0, 1.0, 0.0); drawPlane(); drawJulia(); glPopMatrix(); /* calculate and show FPS */ N++; t1 = currentSeconds(); elapsedTime = t1 - t0; if (elapsedTime > FPS_TIME_WINDOW) { fps = (float) N / elapsedTime; N = 0; t0 = t1; sprintf(cfps, "Julia Fractal GL (%d x %d): %3.1f fps", WIDTH, HEIGHT, fps); printf("%s\n", cfps); glutSetWindowTitle(cfps); } glutPostRedisplay(); glutSwapBuffers(); }