Hi guys
I'm writing a very basic program to monitor performance when copying from a cv::ogl::Texture2D to a cv::ogl::Buffer (using the copyTo function), and from there to an OpenCL cv::UMat (using cv::ogl::mapGLBuffer). It seems to me on papre this should work all on the GPU but I'm having trouble even running this code:
#include "mainwindow.h"
#include <QApplication>
#include <opencv2/core.hpp>
#include <opencv2/core/opengl.hpp>
#include <opencv2/core/ocl.hpp>
#include <opencv2/core/mat.hpp>
#include <QOpenGLWidget>
#include <QOpenGLExtraFunctions>
#include <QOpenGLShaderProgram>
#include <QOpenGLExtensions>
cv::UMat cvUMat;
cv::ogl::Texture2D* cvglTexture;
cv::ogl::Buffer cvglBuffer;
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
cv::ocl::setUseOpenCL(true);
assert(cv::ocl::haveOpenCL());
assert(cv::ocl::useOpenCL());
cv::ocl::Context::getDefault().create(cv::ocl::Device::TYPE_GPU);
cvglTexture->create(640,480,cv::ogl::Texture2D::Format::RGBA);
return a.exec();
}
This is the error I get:
Exception at 0x7ffc886da799, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) in opencv_world430d!cv::UMat::deallocate
And this is my stack:
1 RaiseException KERNELBASE 0x7ffc886da799
2 CxxThrowException VCRUNTIME140D 0x7ffc67097ec7
3 cv::UMat::deallocate opencv_world430d 0x7ffc12f21236
4 cv::UMat::deallocate opencv_world430d 0x7ffc12f21387
5 cv::UMat::deallocate opencv_world430d 0x7ffc12e7f464
6 main main.cpp 30 0x7ff79585297f
7 WinMain qtmain_win.cpp 104 0x7ff79585667d
8 invoke_main exe_common.inl 107 0x7ff795854aad
9 __scrt_common_main_seh exe_common.inl 288 0x7ff79585499e
10 __scrt_common_main exe_common.inl 331 0x7ff79585485e
11 WinMainCRTStartup exe_winmain.cpp 17 0x7ff795854b39
12 BaseThreadInitThunk KERNEL32 0x7ffc894e7bd4
13 RtlUserThreadStart ntdll 0x7ffc8ac6ce51
I'm using QT and OpenCV 430 (debug) built for VC15 (I'm using the QT 5.12.0 MSVC2017 compiler) on windows. I have other projects that use cv::UMat and everything runs smooth there but looks like there are some complications with OpenGL interop. Any thoughts on where to get started and what to check would definitely be helpful!
Cheers!