My Unreal Project has triggered a breakpoint and causing heap corruptions when implementing OpenCV in Custom C++ Class

asked 2020-02-20 18:19:22 -0600

Zerotoe gravatar image

I'm trying to implement OpenCV (Face Module in specific) into my UE4 Project.

But it always have been crushed when I use facemark::loadModel() while building UE Custom C++ Class.

I've already tested the code in another empty windows project and it worked fine. Here's the code that I want to implement.

cv::String cstProjectContentPath = cv::String(std::string(TCHAR_TO_UTF8(*FPaths::ProjectContentDir())).c_str());
cv::String cstYamlPath = cstProjectContentPath + cv::String("Data/lbfmodel.yaml");

cv::Ptr<cv::face::Facemark> facemark = createFacemarkLBF();
facemark->loadModel(cstYamlPath); //UE4 always triggers a breakpoint at this line

and a heap corruption follows when I click continue while stuck in a breakpoint.

the above code works fine without Facemark->loadModel().

I'm using Visual studio 2017 and OpenCV 4.2.0. Engine Version of UE4 is 4.21.2.

Thank you.

edit retag flag offensive close merge delete

Comments

Please use this code

LBerger gravatar imageLBerger ( 2020-02-21 02:05:07 -0600 )edit

I've already tested the code in another empty windows project and it worked fine

we probably cannot help you, then, there's no support for unreal things from opencv.

TCHAR_TO_UTF8 -- strings are ascii here, not utf8

berak gravatar imageberak ( 2020-02-21 02:20:08 -0600 )edit

Sorry for the confusion. I tested the code but cstYamlPath was a static path with plain string in quotes. (and of course, I tested above code in plain string for unreal project and have failed compile.)

Zerotoe gravatar imageZerotoe ( 2020-02-22 13:37:09 -0600 )edit