Add timing information

This commit is contained in:
mmcwilliams 2024-04-01 14:00:22 -04:00
parent 0f42160ee9
commit a5ceca86f6
1 changed files with 12 additions and 8 deletions

View File

@ -17,14 +17,16 @@
using namespace cv; using namespace cv;
using namespace std; using namespace std;
using namespace std::chrono;
using time_stamp = time_point<system_clock, microseconds>;
Mat image; Mat image;
GLuint imageTexture; GLuint imageTexture;
GLint screenWidth = 0; GLint screenWidth = 0;
GLint screenHeight = 0; GLint screenHeight = 0;
time_stamp ts;
void displayMe(void) void getScreenDimensions () {
{
if (screenWidth == 0 && screenHeight == 0) { if (screenWidth == 0 && screenHeight == 0) {
GLint dims[4] = {0}; GLint dims[4] = {0};
glGetIntegerv(GL_VIEWPORT, dims); glGetIntegerv(GL_VIEWPORT, dims);
@ -32,6 +34,11 @@ void displayMe(void)
screenHeight = dims[3]; screenHeight = dims[3];
cout << screenWidth << "," << screenHeight << endl; cout << screenWidth << "," << screenHeight << endl;
} }
}
void displayMe(void)
{
getScreenDimensions();
string image_path = samples::findFile("chart.png"); string image_path = samples::findFile("chart.png");
Mat image = imread(image_path, IMREAD_COLOR); Mat image = imread(image_path, IMREAD_COLOR);
@ -47,7 +54,7 @@ void displayMe(void)
glColor3f(1, 0, 0); glVertex3f(-1.0, -1.0, 0.5); glColor3f(1, 0, 0); glVertex3f(-1.0, -1.0, 0.5);
glColor3f(0, 1, 0); glVertex3f(1.0, -1.0, 0); glColor3f(0, 1, 0); glVertex3f(1.0, -1.0, 0);
glColor3f(0, 0, 1); glVertex3f(1.0, 1.0, 0); glColor3f(0, 0, 1); glVertex3f(1.0, 1.0, 0);
glVertex3f(-1.0, 1.0, 0); glColor3f(0, 0, 0); glVertex3f(-1.0, 1.0, 0);
glEnd(); glEnd();
// Flush drawing command buffer to make drawing happen as soon as possible. // Flush drawing command buffer to make drawing happen as soon as possible.
@ -56,15 +63,12 @@ void displayMe(void)
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
ts = time_point_cast<microseconds>(system_clock::now());
glutInit(&argc, argv); glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE); glutInitDisplayMode(GLUT_SINGLE);
glutCreateWindow("opengl_opencv_example"); glutCreateWindow("opengl_opencv_example");
glutFullScreen(); glutFullScreen();
glutDisplayFunc(displayMe); glutDisplayFunc(displayMe);
glutMainLoop(); glutMainLoop();
return 0; return 0;
} }