小编T. *_*mod的帖子

将OpenGL纹理收敛到OpenCV矩阵

我一直在寻找一种将OpenGL纹理转换为OpenCV矩阵类型的方法。我发现了许多指南,这些指南显示了从OpenCV矩阵到OpenGL纹理的转换,但不幸的是却没有相反的方法。我也阅读了此内容及其答案,但并没有使我变得更明智。我正在用C ++编写并使用OpenCV3.1和OpenGL4.4。

编辑:更新的代码

main.cpp:

#include "CameraCapture.h"
#include "GUIMainWindow.h"
#include "glfw3.h"
#include "Texture.h"

using namespace std;

int main(int argc, char* argv[]) {

    if (!glfwInit()) {
        fprintf(stderr, "Failed to initialize GLFW \n");
        return -1;
    }

    glfwWindowHint(GLFW_VISIBLE, GL_FALSE);
    GLFWwindow* window = glfwCreateWindow(1929, 1341, "OpenGL", NULL, NULL);

    if (window == NULL) {
        fprintf(stderr, "Failed to make GLFW window.");
        glfwTerminate();
        return -1;
    }

    glfwMakeContextCurrent(window);

    CameraCapture *cc = new CameraCapture();
    cc->CameraCapture::AvailableCameras();
    GLuint texture = cc->CameraCapture::OpenCamera(0);

    glEnable(GL_TEXTURE_2D);

    glBindTexture(GL_TEXTURE_2D, texture);

    drawGLTexture(window);

    Mat out = …
Run Code Online (Sandbox Code Playgroud)

c++ opengl opencv

5
推荐指数
1
解决办法
2092
查看次数

标签 统计

c++ ×1

opencv ×1

opengl ×1