Download

help with opencv object init

Trying to write code for opencv that I’ve implemented into UE. I get this error when i run:

Unhandled exception at 0x000007FED136617B (UE4Editor-VRProject-Win64-DebugGame.dll) in UE4Editor.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.

I’m not sure if the garbage collector has said goodbye to my object or not. Here is the relevant code:

header:

public: cv::StereoBM* SBM;

cpp:

void ACameraDepthReader::DisparityMap()

{

NumDisparities = 100;
BlockSize = 21;
SBM = cv::StereoBM::create(NumDisparities, BlockSize);
SBM->compute(*Left, *Right, *OD);

}

It fails on compute. Pointers matrixes left,right and od seem to be fine as left and right carry my video signals and work when accessed directly. From what i’ve read the instantiating/garbage collector has not been handled correctly but the only thing ive found is to use fgcobject and then add a reference to the gc:

void AddReferencedObjects(FReferenceCollector& Collector) override
{
Collector.AddReferencedObject(SBM);
}

but this just gave me an error. I cant find very much information on this. Any help would be appreciated.