简体   繁体   English

运行ogl :: Arrays的默认构造函数时,Opencv2崩溃

[英]Opencv2 crashes when the default constructor for ogl::Arrays runs

I'm trying to run one of the code examples that opencv2 provides ('opengl_interop.cpp'). 我正在尝试运行opencv2提供的代码示例之一(“ opengl_interop.cpp”)。 In the code there's the following struct of several objects that throws an error. 在代码中,以下几个对象的结构引发了错误。 I've reduced the code down to the following simple program: 我将代码简化为以下简单程序:

#include <opencv2/core/opengl.hpp>

struct DrawData {
    cv::ogl::Arrays arr;
    cv::ogl::Buffer indices;
    cv::ogl::Texture2D tex;
};


int main() {
    DrawData data;
    return 0;
}

The debugger identifies the 'Arrays' default constructor from as the culprit, and the exception is thrown in the body of the constructor during runtime: 调试器将“数组”的默认构造函数标识为罪魁祸首,并在运行时在构造函数的主体中引发异常:

inline
cv::ogl::Arrays::Arrays() : size_(0)
{
}

The compiler (Visual Studio 2015) provides the following message: "Unhandled exception at 0x00007FFAFA927788 in basic opengl program.exe: Microsoft C++ exception: cv::Exception at memory location 0x000000B51399F360." 编译器(Visual Studio 2015)提供以下消息:“基本opengl program.exe中的0x00007FFAFA927788未处理的异常:Microsoft C ++异常:内存位置0x000000B51399F360的cv :: Exception。”

In the debugger console I get the following error message: "OpenCV(3.4.3) Error: No OpenGL support (The library is compiled without OpenGL support) in `anonymous-namespace'::throw_no_ogl, file c:\\build\\3_4_winpack-build-win64-vc15\\opencv\\modules\\core\\src\\opengl.cpp, line 60" 在调试器控制台中,我收到以下错误消息:“ OpenCV(3.4.3)错误:`匿名名称空间':: throw_no_ogl,文件c:\\ build \\ 3_4_winpack-中没有OpenGL支持(该库是在没有OpenGL支持的情况下编译的) build-win64-vc15 \\ opencv \\ modules \\ core \\ src \\ opengl.cpp,第60行“

I'm on Windows 10 with an otherwise working copy of opencv2 3.4.3 installed. 我在Windows 10上并已安装了opencv2 3.4.3的其他工作副本。 Thanks. 谢谢。
EDIT: opencv was built with opengl enabled. 编辑:opencv是启用了opengl构建的。 'CMakeCache.txt' in my build folder shows the following line: //Include OpenGL support WITH_OPENGL:BOOL=ON 我的构建文件夹中的“ CMakeCache.txt”显示以下行: //Include OpenGL support WITH_OPENGL:BOOL=ON

最后,我得到了较旧版本的opencv(4.3.4),同时安装了Qt4和Qt5,并使用gui Cmake验证了安装是否正确以及是否包含了opengl,并随后进行了仔细的链接和测试,从而最终解决了该问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM