Hi there!
I’m putting together OculusRift, Unreal Engine and OpenCV. To do this, I’m using:
- Oculus Rift DK2 with SDK 5 (SDK 6 not stable with my NVidia drivers)
- UE 4.7.6 (VR is still not working on 4.8.2)
- OpenCV 2.4.1.0 (OpenCV 3 crashes with UE)
At last I got it, but when I merged my OpenCV code into Unreal project there is a function which is not working properly. I post simplified version here:
cv::findContours(contoursImg, contours, CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE);
That function should take a binary image, detect its contours and fill a std::vector< std::vector< cv::Point>> with detected edges. I have to use these contours later in order to detect some geometries. When the method where I’m using to process images ends, it rises a memory error among nexts:
- Couldn’t read memory.
- Couldn’t write memory.
If I perform other image processing (like canny, for example: cv::Canny(contoursImg, contoursImg, 100, 100 * 2, 3);
) on the same image, it works perfectly… I deduced that the problem rises when free the vector of contours, because it rises at the end of the method (just after return statment at Unreal’s void FMallocTBB::Free( void* Ptr )
function). If i try to make my own vector destruction through clear and swap, error rises at the line where I’m trying to free those resources. BTW, I know C++ should take care of memory freeing of that vector when method ends because it’s out of scope…
As a note, the very same algorithm works with no memory leaks outside UE inside it’s own C++ project.
Any idea, tip, solution, clue, comment, etc… will be very appreciated
Best regards,