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<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.
Please use this code
we probably cannot help you, then, there's no support for unreal things from opencv.
TCHAR_TO_UTF8
-- strings are ascii here, not utf8Sorry 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.)