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

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 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.

hi, I am trying to do the same and coming across the same error. Did you figure out what was causing it.