# Using Unreal Engine 5.0.3 or 5.1.0 built-in OpenCV plugin

**URL:** <https://forums.unrealengine.com/t/using-unreal-engine-5-0-3-or-5-1-0-built-in-opencv-plugin/744951>\
**Category:** C++\
**Tags:** opencv, unreal-engine, Plugins, question\
**Created:** [January 8, 2023, 6:15pm UTC](https://forums.unrealengine.com/t/using-unreal-engine-5-0-3-or-5-1-0-built-in-opencv-plugin/744951 "2023-01-08T18:15:53Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![MatthewDZane](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MatthewDZane](https://forums.unrealengine.com/u/MatthewDZane)\
**Post date:** [January 8, 2023, 6:15pm UTC](https://forums.unrealengine.com/t/using-unreal-engine-5-0-3-or-5-1-0-built-in-opencv-plugin/744951/1 "2023-01-08T18:15:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![lukassped](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/lukassped/32/469023_2.png) [@lukassped](https://forums.unrealengine.com/u/lukassped)\
**Post date:** [January 9, 2023, 4:03pm UTC](https://forums.unrealengine.com/t/using-unreal-engine-5-0-3-or-5-1-0-built-in-opencv-plugin/744951/2 "2023-01-09T16:03:50Z")

</div>

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](https://youtu.be/LX1w_etaftY?t=337)

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.

---

<div class="post-metadata">

**Author:** ![Naqib\_OG](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Naqib\_OG](https://forums.unrealengine.com/u/Naqib_OG)\
**Post date:** [February 21, 2023, 8:31pm UTC](https://forums.unrealengine.com/t/using-unreal-engine-5-0-3-or-5-1-0-built-in-opencv-plugin/744951/3 "2023-02-21T20:31:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Snowicefield](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Snowicefield](https://forums.unrealengine.com/u/Snowicefield)\
**Post date:** [February 23, 2024, 4:06pm UTC](https://forums.unrealengine.com/t/using-unreal-engine-5-0-3-or-5-1-0-built-in-opencv-plugin/744951/4 "2024-02-23T16:06:02Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![3dcinetv](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/3dcinetv/32/715555_2.png) [@3dcinetv](https://forums.unrealengine.com/u/3dcinetv)\
**Post date:** [March 31, 2024, 1:15pm UTC](https://forums.unrealengine.com/t/using-unreal-engine-5-0-3-or-5-1-0-built-in-opencv-plugin/744951/5 "2024-03-31T13:15:32Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![eray\_ozr](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@eray\_ozr](https://forums.unrealengine.com/u/eray_ozr)\
**Post date:** [May 13, 2024, 12:02pm UTC](https://forums.unrealengine.com/t/using-unreal-engine-5-0-3-or-5-1-0-built-in-opencv-plugin/744951/6 "2024-05-13T12:02:34Z")

</div>

I have have a OpenCV Windows plugin to read QR code.

> **[GitHub - FF-Plugins-Active/OpenCV\_Adv](https://github.com/FF-Plugins-Active/OpenCV_Adv)**
>
> Contribute to FF-Plugins-Active/OpenCV\_Adv development by creating an account on GitHub.

But you need to change these in order to work.

```auto
"Engine\Plugins\Runtime\OpenCV\Source\ThirdParty\OpenCV\include\opencv2\core\utility.hpp"

* 52 = #if defined(check)
* 53 = # warning Detected Apple 'check' macro definition, it can cause build conflicts. Please, include this header before any Apple headers.
* 54 = #endif
* 934 = bool check() const;

```

I am working on Android support as well but I can’t give any promise about it. Because there was another clash, too

---

<div class="post-metadata">

**Author:** ![3dcinetv](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/3dcinetv/32/715555_2.png) [@3dcinetv](https://forums.unrealengine.com/u/3dcinetv)\
**Post date:** [August 7, 2024, 11:53pm UTC](https://forums.unrealengine.com/t/using-unreal-engine-5-0-3-or-5-1-0-built-in-opencv-plugin/744951/7 "2024-08-07T23:53:38Z")

</div>

I meant, why isn’t this implemented in Unreal?  
However, I’ll take a look at your code.

---

<div class="post-metadata">

**Author:** ![eray\_ozr](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@eray\_ozr](https://forums.unrealengine.com/u/eray_ozr)\
**Post date:** [August 8, 2024, 1:41pm UTC](https://forums.unrealengine.com/t/using-unreal-engine-5-0-3-or-5-1-0-built-in-opencv-plugin/744951/8 "2024-08-08T13:41:00Z")

</div>

I set it private because I used a marketplace plugin’s android build system for ZXing side of my QR processor.

But you can check my opencv implementation for QR decode.

```auto
#ifdef _WIN64
bool UFF_QR_ProcessorBPLibrary::OpenCV_QR_Decoder_Callback(FString& DecodedString, uint8* Buffer, FVector2D ImageSize)
{
    if (!Buffer)
    {
        return false;
    }

    if (ImageSize.X == 0 || ImageSize.Y == 0)
    {
        return false;
    }

    const cv::Mat Image(cv::Size((int32)ImageSize.X, (int32)ImageSize.Y), CV_8UC4, Buffer);
    cv::Mat Points;
    cv::Mat Output;

    const cv::QRCodeDetector QR_Detector = cv::QRCodeDetector::QRCodeDetector();
    DecodedString = QR_Detector.detectAndDecode(Image, Points, Output).c_str();

    return true;
}
#endif

bool UFF_QR_ProcessorBPLibrary::OpenCV_QR_Decoder(FString& DecodedString, TArray<uint8> Buffer, FVector2D ImageSize)
{
#ifdef _WIN64
    if (Buffer.IsEmpty())
    {
        return false;
    }

    return UFF_QR_ProcessorBPLibrary::OpenCV_QR_Decoder_Callback(DecodedString, Buffer.GetData(), ImageSize);
#else
    return false;
#endif
}

```

Actual decoding is in callback because I developed an Intel RealSense plugin for UE5 and I can use this with it to decode QRs. I use callback one in realsense’s FRunnableThread and feed with uint8\* buffer from sensor without copying data to TArray.

---

<div class="post-metadata">

**Author:** ![Lukalake](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Lukalake](https://forums.unrealengine.com/u/Lukalake)\
**Post date:** [November 7, 2024, 7:35am UTC](https://forums.unrealengine.com/t/using-unreal-engine-5-0-3-or-5-1-0-built-in-opencv-plugin/744951/9 "2024-11-07T07:35:01Z")

</div>

This actually solves my similar problem.
