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

**URL:** <https://forums.unrealengine.com/t/my-unreal-project-has-triggered-a-breakpoint-and-causing-heap-corruptions-when-implementing-opencv-in-custom-c-class/461256>\
**Category:** C++\
**Tags:** opencv, unreal-engine, question\
**Created:** [February 3, 2020, 2:38pm UTC](https://forums.unrealengine.com/t/my-unreal-project-has-triggered-a-breakpoint-and-causing-heap-corruptions-when-implementing-opencv-in-custom-c-class/461256 "2020-02-03T14:38:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_871faa22](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_871faa22](https://forums.unrealengine.com/u/anonymous_user_871faa22)\
**Post date:** [February 3, 2020, 2:38pm UTC](https://forums.unrealengine.com/t/my-unreal-project-has-triggered-a-breakpoint-and-causing-heap-corruptions-when-implementing-opencv-in-custom-c-class/461256/1 "2020-02-03T14:38:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_711859ea](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_711859ea](https://forums.unrealengine.com/u/anonymous_user_711859ea)\
**Post date:** [June 8, 2022, 1:33am UTC](https://forums.unrealengine.com/t/my-unreal-project-has-triggered-a-breakpoint-and-causing-heap-corruptions-when-implementing-opencv-in-custom-c-class/461256/2 "2022-06-08T01:33:36Z")

</div>

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