Potential memory leaks on cv::cvtColor with Emscripten

asked 2018-08-07 09:36:52 -0500

Jendker gravatar image

updated 2018-08-08 03:47:00 -0500

Hello everyone,

I am having a curious case with OpenCV 3.4.2. When I am calling cv::cvtColor using the g++ 7.3.0 everything is fine, but it get's interesting, when I am running code compiled with em++ 1.38.10 for browser.

First:

imshow("canvasOutput", image);
cv::cvtColor(image, grey, image.channels() == 3 ? cv::COLOR_BGR2GRAY : cv::COLOR_BGRA2GRAY);

here everything is still fine (see output on canvasOutput on the right, here I am checking the input Mat "image")

image description

But if I am running imshow after cv::cvtColor it seems to influence the source, so that the following code:

cv::cvtColor(image, grey, image.channels() == 3 ? cv::COLOR_BGR2GRAY : cv::COLOR_BGRA2GRAY);
imshow("canvasOutput", image);

yields following result (again, see output on canvasOutput on the right)

image description


When I am printing the "grey" Mat after conversion everything is fine, it just happens with the source! Can anyone give me an idea what is happening here? As said, with g++ I don't have such effects.

edit retag flag offensive close merge delete

Comments

I am not sure what is the actual source of such behaviour. Should I maybe report it on OpenCV github issues or rather Emscripten?

Jendker gravatar imageJendker ( 2018-08-08 03:43:18 -0500 )edit