小编Lil*_*iit的帖子

黑色方块渲染而不是 OpenCV 图像

我正在尝试使用 ushort 数据类型渲染两个大小为 256x256 的图像。一个必须是灰度,另一个必须是 RGB。然而,两者都渲染为黑色方块。我相信问题出在我的 openGL 纹理定义中,但我不确定。

这是我的代码的最小版本。

#include "imgui.h"
#include "imgui_impl_glfw.h"
#include "imgui_impl_opengl3.h"
#include <glad/glad.h>    
#include <GLFW/glfw3.h>
#include <opencv2/opencv.hpp>

using namespace cv;


int main()
{
    //init glfw, window, glad, imgui
    glfwInit();
    const char* glsl_version = "#version 330 core";
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    GLFWwindow* window = glfwCreateWindow(600, 400, "test", NULL, NULL);
    glfwMakeContextCurrent(window);
    gladLoadGL();
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    ImGui::CreateContext();
    ImGui::StyleColorsDark();
    ImGui_ImplGlfw_InitForOpenGL(window, true);
    ImGui_ImplOpenGL3_Init(glsl_version);


    //define image data
    ushort value;
    Mat_<ushort> grey = Mat_<ushort>(256, 256);
    Mat_<Vec3w> rgb = Mat_<Vec3w>(256, 256);


    for …
Run Code Online (Sandbox Code Playgroud)

c++ opengl opencv glfw imgui

3
推荐指数
1
解决办法
244
查看次数

标签 统计

c++ ×1

glfw ×1

imgui ×1

opencv ×1

opengl ×1