I can confirm the the heap error is the same without wx dependency: cv::Mat src = cv::imread("C:/circleTest.jpg"); cv::Mat srcGray; cvtColor(src, srcGray, cv::COLOR_BGR2GRAY);
Unfortunatly, I do not know enough to be able to get rid of loading the image data from a file.
For the wxImage version, GetData() is RGB, so use cv::COLOR_RGB2GRAY for the intended grayscale conversion. That changes the color interpretation, but it doesn’t explain why the imread version also reports the error.
The Mat constructor wrapping GetData() doesn’t copy or own the pixels. Keep the wxImage and its data alive and unchanged for as long as the Mat uses them. Also check the row stride when wrapping any raw buffer: Mat’s default step assumes tightly packed rows (width × 3 bytes here). Pass the actual byte step if the source has padding. wxImage documents its GetData() as consecutive RGB triplets.
Since imread reproduces it too, could you share a minimal complete program and the exact diagnostic, including when it appears (during cvtColor or at shutdown)? The lines shown look like allocation records, so knowing what reports them would help distinguish a leak report from heap corruption.