OutofMemoryError when using large image in StructuredEdgeDetection

I’m trying to use the detectEdges function from org.opencv.ximgproc.StructuredEdgeDetection class .

This is the sample code I’m using
StructuredEdgeDetection pDollar = createStructuredEdgeDetection(file.toString());
pDollar.detectEdges(mat, edges);

The above code is working fine if the size of the image is small. When I tried with a large resolution image (12 MP). I’m getting OutOfMemoryError. Is there any solution to manage this issue ?

Assuming everything in your code is correct, and that you don’t need absolute precision, you could resize the image smaller, do the detection, and then scale the results back to match the original size

1 Like