Problem with OpenCV integration

I followed this tutorial (https://wiki.unrealengine.com/Integrating_OpenCV_Into_Unreal_Engine_4), the code compiles fine but I have a problem with the VideoCapture class declared in videoio.hpp. This is the crash report:



MachineId:4304F02E4E463BB3B16A1287D3383595
EpicAccountId:52fb55e8c7e14dfdae317e8248c084e7

Unknown exception - code c06d007e (first/second chance not available)

""

KERNELBASE
UE4Editor_OpenCVTest!__delayLoadHelper2() [f:\dd\vctools\delayimp\delayhlp.cpp:315]
UE4Editor_OpenCVTest!_tailMerge_opencv_world300_dll()
UE4Editor_OpenCVTest!AWebcamReader::AWebcamReader() [c:\users\sneppy\documents\unreal projects\opencvtest\source\opencvtest\webcamreader.cpp:22]
UE4Editor_CoreUObject!UClass::CreateDefaultObject() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\coreuobject\private\uobject\class.cpp:2657]
UE4Editor_CoreUObject!UObjectLoadAllCompiledInDefaultProperties() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\coreuobject\private\uobject\uobjectbase.cpp:729]
UE4Editor_CoreUObject!ProcessNewlyLoadedUObjects() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\coreuobject\private\uobject\uobjectbase.cpp:815]
UE4Editor_CoreUObject!TBaseStaticDelegateInstance<void __cdecl(void)>::ExecuteIfSafe() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\core\public\delegates\delegateinstancesimpl_variadics.inl:921]
UE4Editor_Core!TBaseMulticastDelegate<void>::Broadcast() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\core\public\delegates\delegatesignatureimpl_variadics.inl:809]
UE4Editor_Core!FModuleManager::LoadModuleWithFailureReason() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\core\private\modules\modulemanager.cpp:426]
UE4Editor_Projects!FModuleDescriptor::LoadModulesForPhase() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\projects\private\moduledescriptor.cpp:370]
UE4Editor_Projects!FProjectManager::LoadModulesForProject() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\projects\private\projectmanager.cpp:53]
UE4Editor!FEngineLoop::LoadStartupModules() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\launch\private\launchengineloop.cpp:1989]
UE4Editor!FEngineLoop::PreInit() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\launch\private\launchengineloop.cpp:1495]
UE4Editor!GuardedMain() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\launch\private\launch.cpp:110]
UE4Editor!GuardedMainWrapper() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\launch\private\windows\launchwindows.cpp:126]
UE4Editor!WinMain() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\launch\private\windows\launchwindows.cpp:200]


I made a quick search and found some people (they were not using unreal but had a similar call stack) claiming that disabling “incremental linking” should solve the problem. However in the project settings in visual studio this option doesn’t exist (for unreal projects I suppose).
Any ideas?

1 Like

The exception is thrown when I try to load the “opencv_world300.dll” file. Because PublicDelayLoadDLLs in ModuleRules create a \DELAYLOAD rule in the makefile this only happens with the first call by the program to a function in that DLL - in this case cv:VideoCapture()
In the tutorial is specified:

Provided I put the dlls in the right folders, could this problem arise because these actually aren’t the right folder?

[EDIT]
Since I’m opening the project in the editor the dlls should of course be in the “…\4.9\Engine\Binaries\Win64” folder and not in the project Binaries folder. Problem solved

1 Like