OPENCV with UE5 in 2024 - Beginner mistakes

Hello,
I’m trying to get the 4.10 version of openCV working with UE5.3.
Most of the information I’m finding is related to an older version of the engine and doesn’t seem to work for me.

This is the tutorial series im following
Jordan Duncan - UE4 & openCV Part 1

I have some getting started questions. Please help if you can (hopefully someone from Epic Games too.)

  • If I use a newer version of ocv (4.10) do I still need to enable the plugin that ships with ue5 (4.5)
  • If I just cant get ocv to work via Third Party plugin process. Is there any code or example file that enables and uses the web camera using the inbuilt ocv plugin

I will describe what im doing to get the recent downloaded version of opencv linked in the ThirdParty folder l. Hopefully someone can spot some mistakes.

  1. Download a version of opencv that i am interested in 4.10 opencv download

  2. Create a UE5 VC++ project in MS Visual Studio 2022

  3. Create a ThirdPary folder and paste the necessary files there :
    ThirdParty\OpenCV\includes\opencv2
    ThirdParty\OpenCV\Libraries\Win64\opencv_world4100.dll
    ThirdParty\OpenCV\Libraries\Win64\opencv_world4100.lib
    ThirdParty\OpenCV\Libraries\Win64\opencv_videoio_ffmpeg4100_64.dll

  4. Populate the Build.cs file with the following code.
    I have a feeling im not doing something right in this step wrt to linking the path in the local project folder where the ThirdParty folder and opencv files are ? My local project is in the D drive.

// Copyright Epic Games, Inc. All Rights Reserved.

using System.IO;
using UnrealBuildTool;

public class opencv_alt : ModuleRules
{


    private string ThirdPartyPath
    {
        get { return Path.GetFullPath(Path.Combine(ModuleDirectory, "../../ThirdParty/")); }
    }

    public bool LoadOpenCV(ReadOnlyTargetRules Target)
    {
        // Start OpenCV linking here!
        bool isLibrarySupported = false;

        // Create OpenCV Path 
        string OpenCVPath = Path.Combine(ThirdPartyPath, "OpenCV");

        // Get Library Path 
        string LibPath = "";
        bool isdebug = Target.Configuration == UnrealTargetConfiguration.Debug && Target.bDebugBuildsActuallyUseDebugCRT;
        if (Target.Platform == UnrealTargetPlatform.Win64)
        {
            LibPath = Path.Combine(OpenCVPath, "Libraries", "Win64");
            isLibrarySupported = true;
        }
        else
        {
            string Err = string.Format("{0} dedicated server is made to depend on {1}. We want to avoid this, please correct module dependencies.", Target.Platform.ToString(), this.ToString()); System.Console.WriteLine(Err);
        }

        if (isLibrarySupported)
        {
            //Add Include path 
            PublicIncludePaths.AddRange(new string[] { Path.Combine(OpenCVPath, "includes") }); // original text reads as "Includes" i.e with capital I . my folder name reads "includes" i. without capitalized i

      
// EXPLICIT LIBRARY NAME PublicAdditionalLibraries.Add("D:\\behram\\UE5_dev\\opencv_5_alt\\opencv_alt\\ThirdParty\\OpenCV\\Libraries\\Win64\\opencv_world4100.lib");

//Add Dynamic Libraries            PublicDelayLoadDLLs.Add("D:\\behram\\UE5_dev\\opencv_5_alt\\opencv_alt\\ThirdParty\\OpenCV\\Libraries\\Win64\\opencv_world4100.dll");// EXPLICIT DLL PATH
            PublicDelayLoadDLLs.Add("D:\\behram\\UE5_dev\\opencv_5_alt\\opencv_alt\\ThirdParty\\OpenCV\\Libraries\\Win64\\opencv_ffmpeg320_64.dll");// EXPLICIT DLL NAME
        }

        PublicDefinitions.Add(string.Format("WITH_OPENCV_BINDING={0}", isLibrarySupported ? 1 : 0));
        //        Definitions.Add(string.Format("WITH_OPENCV_BINDING={0}", isLibrarySupported ? 1 : 0));

        return isLibrarySupported;
    }


    public opencv_alt(ReadOnlyTargetRules Target) : base(Target)
	{
		PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
               PublicDependencyModuleNames.AddRange(new string[] 
{ 
"Core", 
"CoreUObject", 
"Engine", 
"InputCore", 
"EnhancedInput", 
"Renderer", 
"RenderCore", 
"RHI", 
"RHICore",
 "D3D12RHI", 
"RenderCore",
 "Media", 
"MediaAssets" }
);
        LoadOpenCV(Target);
    }
}

  1. When I create a simple c++ Actor and include opencv headers. I get the warning, “cannot open source file ThirdParty/OpenCV…” and so on.
// Fill out your copyright notice in the Description page of Project Settings.

//OPENCV INBUILT PLUGIN MODULE DISABLED

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "ThirdParty/OpenCV/includes/opencv2/core.hpp"
#include <ThirdParty/OpenCV/include/opencv2/highgui/highgui.hpp>
#include <ThirdParty/OpenCV/include/opencv2/imgproc.hpp>
//#include "PreOpenCVHeaders.h"
//#include "OpenCVHelper.h"
//#include "PostOpenCVHeaders.h"
#include "opencv5_alt_test.generated.h"

UCLASS()
class OPENCV_ALT_API Aopencv5_alt_test : public AActor
{
	GENERATED_BODY()
	
public:	
	// Sets default values for this actor's properties
	Aopencv5_alt_test();
	void TestOpenCV();

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

public:	
	// Called every frame
	virtual void Tick(float DeltaTime) override;

};

What am i not understanding about the process so far ?

Thank you so much for your help
b