Using Unreal Engine 5.0.3 or 5.1.0 built-in OpenCV plugin

I’m trying to use the built-in OpenCV plugin for Unreal Engine 5.0.3 or 5.1.0.

I added the plugin to the project level build file, like so:
PublicDependencyModuleNames.AddRange(new string[] {
“Core”,
“CoreUObject”,
“Engine”,
“InputCore”,
“RHI”,
“RenderCore”,
“Media”,
“MediaAssets”,
“OpenCV”,
“OpenCVHelper”
});

I am able to include the following import statements and compile:
#include “opencv2/core.hpp”
#include “opencv2/highgui.hpp”

However when I try to launch the editor, it loads up to 75% Initializing and then crashes with this error:

Unhandled Exception: 0xc06d007e

KERNELBASE
UnrealEditor_QRCode!__delayLoadHelper2() D:\a_work\1\s\src\vctools\delayimp\delayhlp.cpp:312]
UnrealEditor_QRCode!_tailMerge_opencv_world455_dll()
UnrealEditor_QRCode!ACameraReader::ACameraReader() [C:\Users\matth\Documents\Unreal Projects\QRCode\Source\QRCode\Private\CameraReader.cpp:8]
UnrealEditor_CoreUObject

I’m not sure how the D drive path is related.

If I comment out: “cv::Mat cvMat;”, the project will launch, but of course I need access to the cv::Mat type.

“cv::Size cvSize;” works though.

If anyone has been able to get OpenCV working in Unreal Engine 5, I would love any insight and help.

Hi. Im also currently doing something using OpenCV in Unreal.
I got my project to compile by also including the Modules as a private Dependency.
And then I found in a video that the includes for OpenCV should apperently look like this:

#include “PreOpenCVHeaders.h”
#include “OpenCVHelper.h”
#include <ThirdParty/OpenCV/include/opencv2/imgproc.hpp>
#include <ThirdParty/OpenCV/include/opencv2/highgui/highgui.hpp>
#include <ThirdParty/OpenCV/include/opencv2/core.hpp>
#include “PostOpenCVHeaders.h”

Link to Video

You do not need all of the includes, but I still but them in so that people are able to detect the scheme.

I did not find any documentation on using OpenCV with UE. So if you know some good links these would be apprecieated. Currently I am figuring everthing out myself. Wich is more time consuming than I anticipated.

2 Likes

thank you for your comment. does it work with all the include. and can you use Mat after that?

I have the same issue using UE5.2 built-in OpenCV, and solved it by copy the opencv_world455.dll from UE_5.2\Engine\Plugins\Runtime\OpenCV\Binaries\ThirdParty\Win64 to my project’s Binaries\Win64 Folder.

1 Like

TSM. This post is appreciated.
Why after so many years that CV has been going around there are no dedicated features/plugins to make this easier?
I’ll follow this thread as I am also looking to avoid UI controllers.