Skip to content

Instantly share code, notes, and snippets.

@satojkovic
Created March 15, 2014 00:46
Show Gist options
  • Save satojkovic/9560093 to your computer and use it in GitHub Desktop.
Save satojkovic/9560093 to your computer and use it in GitHub Desktop.
#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <glut.h>
static void display(void)
{
cv::Mat img = cv::imread("test.jpg");
cv::flip(img, img, 0);
cv::cvtColor(img, img, CV_BGR2RGB);
glClear(GL_COLOR_BUFFER_BIT);
glDrawPixels(img.cols, img.rows,
GL_RGB, GL_UNSIGNED_BYTE, img.data);
glFlush();
}
static void keyboard(unsigned char key, int x, int y)
{
switch(key) {
case 'q':
case 'Q':
case '\033':
exit(1);
default:
break;
}
}
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA);
glutInitWindowSize(640, 640);
glutCreateWindow("TEST");
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 640, 640, 0.0);
glViewport(0, 0, 640, 640);
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
glutMainLoop();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment