Can't create OpenCV Mat c++

I’m currently trying to use OpenCV inside a project and having issues around creating a cv::Mat

#if WITH_OPENCV
// IWYU pragma: begin_keep
#include "PreOpenCVHeaders.h"
#include "opencv2/unreal.hpp"
#include "opencv2/opencv.hpp"
#include "opencv2/core.hpp"
#include "opencv2/ml.hpp"
#include "opencv2/imgproc.hpp"
#include "PostOpenCVHeaders.h"
// IWYU pragma: end_keep
#endif


	// Create a destination matrix for the blurred image
	cv::Mat dst;

	// Convert the pixel buffer to a cv::Mat
	cv::Mat src = cv::Mat(cv::Size(TextureDimensionY, TextureDimensionX), CV_8UC4, PixelData.data());

initially i thought the PixelData was incorrect but it seems that I can even create an empty Mat.

I am not familiar with OpenCV but feel I feel like I am close and has to be the way unreal handles memory allocations and possibly causing conflicts with OpenCV as the error is around disassembly code.

Unfortunately I am at a lost as what to do here, if someone who has encountered this or knows to help would be appreciated!

1 Like

I found the problem was I hadn’t added the dll via being a module and as the DLLs and Lib files only get added to the project if the plugin is enabled, once I fixed this it worked hope this helps someone else

Thank you for posting how you fixed the issue.
I am beginning my opencv journey and it has been an exercise in frustration ,so this might help me down the road.

Just so im getting this correct, Your issue was resolved because you enabled the opencv plugin that ships with ue5 correct ?
Did you also add a Thirdparty folder in your project.

I’m stuck on making ue5 opencv webcam work because I want to use a recent version of opencv.
I have downloaded all the files ,put them in the third party folder , created the build.cs file, but on testing the project is just refusing to open past 77%.

This is the tutorial im following
opencv in UE4 part one

Thanks,
b