Thanks a a ton.
I’m working on exactly that. Debugging opencv and UE5 crashes
Right now the inbuilt open cv is crashing on me. I cant get it to show an image. So like you said I’m trying to make sure that’s working first.
Example header
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "opencv2/core.hpp"
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
#include "Log.h"
#include "Misc/Paths.h"
#include "TestActor.generated.h"
UCLASS()
class ATestActor : public AActor
{
GENERATED_BODY()
public:
void TestOpenCV();
public:
ATestActor();
Example C++
ATestActor::ATestActor(){
//TestOpenCV();
}
void ATestActor::TestOpenCV(){
FString RelativePath = FPaths::ProjectDir();
FString FullPath = IFileManager::Get().ConvertToAbsolutePathForExternalAppForRead(*RelativePath);
std::string path(TCHAR_TO_UTF8(*FullPath));
UE_LOG(LogEndoVRCore, Log, TEXT("Testing OpenCV..."));
cv::Mat img = cv::imread(path+"ThirdParty/Data/Lenna.png", cv::IMREAD_COLOR);
cv::imshow("Display window", img);
cv::waitKey(0); // Wait for a keystroke in the window
}
void ATestActor::BeginPlay(){
Super::BeginPlay();
TestOpenCV();
}
ATestActor::ATestActor(){
//TestOpenCV();
}
void ATestActor::TestOpenCV(){
FString RelativePath = FPaths::ProjectDir();
FString FullPath = IFileManager::Get().ConvertToAbsolutePathForExternalAppForRead(*RelativePath);
std::string path(TCHAR_TO_UTF8(*FullPath));
UE_LOG(LogEndoVRCore, Log, TEXT("Testing OpenCV..."));
cv::Mat img = cv::imread(path+"ThirdParty/Data/Lenna.png", cv::IMREAD_COLOR);
cv::imshow("Display window", img);
cv::waitKey(0); // Wait for a keystroke in the window
}
void ATestActor::BeginPlay(){
Super::BeginPlay();
TestOpenCV();
}
I’m getting a crash on the imshow() function.
This is the thread to the discussion is.
Cheers and thanks for your help.
b