-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOGL_OCV_common.h
48 lines (42 loc) · 1.17 KB
/
OGL_OCV_common.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
* OGL_OCV_common.h
* HeadReplacement
*
* Created by Roy Shilkrot on 11/21/11.
* Copyright 2011 MIT. All rights reserved.
*
*/
#ifdef _WIN32
#include <windows.h>
#endif
#include <opencv2/opencv.hpp>
using namespace cv;
#if defined(__APPLE__)
# include <OpenGL/gl.h>
#elif defined(__linux__) || defined(__MINGW32__) || defined(WIN32)
# define GLEW_STATIC
//# include <GL/glew.h>
//# include <GL/wglew.h>
# include <GL/gl.h>
# include <GL/glu.h>
//# include <GL/glext.h>
#else
# include <gl.h>
#endif
void copyImgToTex(const Mat& _tex_img, GLuint* texID, double* _twr, double* _thr);
typedef struct my_texture {
GLuint tex_id;
double twr,thr,aspect_w2h;
Mat image;
my_texture():tex_id(-1),twr(1.0),thr(1.0) {}
bool initialized;
void set(const Mat& ocvimg) {
ocvimg.copyTo(image);
copyImgToTex(image, &tex_id, &twr, &thr);
aspect_w2h = (double)ocvimg.cols/(double)ocvimg.rows;
}
} OpenCVGLTexture;
void glEnable2D(); // setup 2D drawing
void glDisable2D(); // end 2D drawing
OpenCVGLTexture MakeOpenCVGLTexture(const Mat& _tex_img); // create an OpenCV-OpenGL image
void drawOpenCVImageInGL(const OpenCVGLTexture& tex); // draw an OpenCV-OpenGL image