我需要为我的研究。 我接受了littleimp的建议,但修复颜色和翻转图像花费宝贵的时间来弄清楚。
这就是我最终的结果。
typedef Mat Image ;
typedef struct {
int width;
int height;
char* title;
float field_of_view_angle;
float z_near;
float z_far;
} glutWindow;
glutWindow win;
Image glutTakeCVImage() {
// take a picture within glut and return formatted
// for use in openCV
int width = win.width;
int height = win.height;
unsigned char* buffer = new unsigned char[width*height*3];
glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, buffer);
Image img(height, width, CV_8UC3, buffer);
Image flipped_img;
flip(img,flipped_img,0);
Image BGR_img;
cvtColor(flipped_img,BGR_img, COLOR_RGB2BGR);
return BGR_img;
}
我希望有人认为这有用。
“OpenGL图像”在这种情况下意味着什么?纹理?一个场景呈现给framebuffer?一个场景呈现给一些离屏缓冲区? –
@MatsPetersson我用更多的解释更新了这个问题 – mFeinstein
@MatsPetersson我猜它是“一个渲染到framebuffer的场景”选项,要更清楚。我还在深入学习OpenGL,所以我试图找到更多关于所有必读内容的信息,而且我找不到太多的东西......任何方向都是最受欢迎的! – mFeinstein