opencv_contrib icon indicating copy to clipboard operation
opencv_contrib copied to clipboard

RGBD failing to compile with OpenGL enabled

Open eezstreet opened this issue 5 years ago • 13 comments

System information (version)
  • OpenCV => Latest master
  • Operating System / Platform => Windows 10 x64
  • Compiler => Visual Studio 2017 x64
Detailed description

With OpenGL enabled and RGBD, it does not compile due to an error:

OpenCV-Contrib\modules\rgbd\src\dynafu.cpp(234): error C2131: expression did not evaluate to a constant
OpenCV-Contrib\modules\rgbd\src\dynafu.cpp(234): note: failure was caused by a read of a variable outside its lifetime
OpenCV-Contrib\modules\rgbd\src\dynafu.cpp(234): note: see usage of 'this'
OpenCV-Contrib\modules\rgbd\src\dynafu.cpp(206): note: while compiling class template member function 'void cv::dynafu::DynaFuImpl<cv::Mat>::drawScene(cv::OutputArray,cv::OutputArray)'
OpenCV-Contrib\modules\rgbd\src\dynafu.cpp(526): note: see reference to function template instantiation 'void cv::dynafu::DynaFuImpl<cv::Mat>::drawScene(cv::OutputArray,cv::OutputArray)' being compiled
OpenCV-Contrib\modules\rgbd\src\dynafu.cpp(275): note: while compiling class template member function 'cv::dynafu::DynaFuImpl<cv::Mat>::~DynaFuImpl(void)'
OpenCV-Contrib\modules\rgbd\src\dynafu.cpp(291): note: see reference to class template instantiation 'cv::dynafu::DynaFuImpl<cv::Mat>' being compiled
OpenCV-Contrib\modules\rgbd\src\dynafu.cpp(235): error C2131: expression did not evaluate to a constant
OpenCV-Contrib\modules\rgbd\src\dynafu.cpp(235): note: failure was caused by a read of a variable outside its lifetime
OpenCV-Contrib\modules\rgbd\src\dynafu.cpp(235): note: see usage of 'this'

The exact code that is failing is here:

float f[params.frameSize.width*params.frameSize.height];
Steps to reproduce

Compile with OpenGL and RGBD enabled.

eezstreet avatar Oct 24 '19 14:10 eezstreet

float f[params.frameSize.width*params.frameSize.height]; is it really C++ https://en.cppreference.com/w/cpp/language/array ?

LaurentBerger avatar Oct 29 '19 10:10 LaurentBerger

I also have the problem with

Severity Code Description Project File Line Suppression State Error C2131 expression did not evaluate to a constant opencv_rgbd

[234] - float f[params.frameSize.width*params.frameSize.height];
[235] - float pixels[params.frameSize.width*params.frameSize.height][3];

ThomasLengeling avatar Oct 31 '19 15:10 ThomasLengeling

I also have the same problem. Error C2131 expression did not evaluate to a constant opencv_rgbd

juxiangwu avatar Nov 01 '19 14:11 juxiangwu

If you don't need the RGB-Depth Processing module (that's where the error occurs) and just want to compile opencv on windows, just deactivate the extra module with -DBUILD_opencv_rgbd=OFF during cmake-configure and you are good to go.

minimalisticMe avatar Nov 01 '19 18:11 minimalisticMe

Problem is not easy to solve. You can use vector instaed of float[] but it does not solve problem. New problem is glext.h which is not available on windows. You can download it with khrplatform.h and then you will have link errors :

1>dynafu.obj : error LNK2019: unresolved external symbol glBindRenderbufferEXT referenced in function "public: __cdecl cv::dynafu::DynaFuImpl<class cv::Mat>::DynaFuImpl<class cv::Mat>(struct cv::dynafu::Params const &)" (??0?$DynaFuImpl@VMat@cv@@@dynafu@cv@@QEAA@AEBUParams@12@@Z) 1>dynafu.obj : error LNK2019: unresolved external symbol glGenRenderbuffersEXT referenced in function "public: __cdecl cv::dynafu::DynaFuImpl<class cv::Mat>::DynaFuImpl<class cv::Mat>(struct cv::dynafu::Params const &)" (??0?$DynaFuImpl@VMat@cv@@@dynafu@cv@@QEAA@AEBUParams@12@@Z) 1>dynafu.obj : error LNK2019: unresolved external symbol glRenderbufferStorageEXT referenced in function "public: __cdecl cv::dynafu::DynaFuImpl<class cv::Mat>::DynaFuImpl<class cv::Mat>(struct cv::dynafu::Params const &)" (??0?$DynaFuImpl@VMat@cv@@@dynafu@cv@@QEAA@AEBUParams@12@@Z) 1>dynafu.obj : error LNK2019: unresolved external symbol glBindFramebufferEXT referenced in function "public: __cdecl cv::dynafu::DynaFuImpl<class cv::Mat>::DynaFuImpl<class cv::Mat>(struct cv::dynafu::Params const &)" (??0?$DynaFuImpl@VMat@cv@@@dynafu@cv@@QEAA@AEBUParams@12@@Z) 1>dynafu.obj : error LNK2019: unresolved external symbol glGenFramebuffersEXT referenced in function "public: __cdecl cv::dynafu::DynaFuImpl<class cv::Mat>::DynaFuImpl<class cv::Mat>(struct cv::dynafu::Params const &)" (??0?$DynaFuImpl@VMat@cv@@@dynafu@cv@@QEAA@AEBUParams@12@@Z) 1>dynafu.obj : error LNK2019: unresolved external symbol glFramebufferRenderbufferEXT referenced in function "public: __cdecl cv::dynafu::DynaFuImpl<class cv::Mat>::DynaFuImpl<class cv::Mat>(struct cv::dynafu::Params const &)" (??0?$DynaFuImpl@VMat@cv@@@dynafu@cv@@QEAA@AEBUParams@12@@Z)

This module is not compatible with windows and msvc. It is not available in 3.4 branch

LaurentBerger avatar Nov 01 '19 21:11 LaurentBerger

I have encountered what seems to be a related problem, when compiling under Linux.

When OPENCV_ENABLE_NONFREE is set, and OpenGL_GL_PREFERENCE is set to GLVND (newer OpenGL), the build fails, with reference to libopencv_rgbd:

../../lib/libopencv_rgbd.so.4.2.0: undefined reference to `glRenderbufferStorageEXT' etc...

But if OpenGL_GL_PREFERENCE is set to LEGACY, there is no error.

MGarvinNYC avatar Jan 20 '20 10:01 MGarvinNYC

Also have the problem:dynafu.cpp:181:26: error: 'glGenRenderbuffersEXT' was not declared in this scope glGenRenderbuffersEXT(1, &fbo_depth);

zuoyizhongguo avatar Feb 21 '20 13:02 zuoyizhongguo

The issue described here and here set BUILD_opencv_rgbd=OFF for fast build fix

smartnet-club avatar Apr 28 '20 01:04 smartnet-club

Reopening... Fix #2679 handles Windows case only, we need similar approach for Linux platform too.

alalek avatar Oct 31 '20 19:10 alalek

Just adding the 'diff' from GArik's pull to my 4.4.0 release build appears to have fixed the issue on my Jetson nano (running linux).

acochrane avatar Nov 08 '20 22:11 acochrane

Confirmed building on Ubuntu 22.04, patch by @GArik works fine

twdragon avatar Oct 05 '22 18:10 twdragon

Trying to build OpenCV-4.7.0 and met this same issue.

It looks patch by @GArik works okay for this specific problem. However, I still cannot figure out this issue ...

jiapei100 avatar Jun 17 '23 22:06 jiapei100

If you don't need the RGB-Depth Processing module (that's where the error occurs) and just want to compile opencv on windows, just deactivate the extra module with -DBUILD_opencv_rgbd=OFF during cmake-configure and you are good to go.

As you said, I solved this issue by Turn OFF rgbd. Thank you ...

jiapei100 avatar May 07 '24 15:05 jiapei100