Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

like i thought:

return cv::Mat(img.height(), img.width(),format, img.bits(), img.bytesPerLine());

you're taking a shallow copy of the data pointer here, it will be invalid, once you leave that callback function.

add a clone() as in:

return cv::Mat(img.height(), img.width(),format, img.bits(), img.bytesPerLine()).clone();

like i thought: the problem is here:

return cv::Mat(img.height(), img.width(),format, img.bits(), img.bytesPerLine());

you're taking a shallow copy of the data pointer (img.bits()) here, it will be invalid, once you leave that callback function.

add a clone() as in:

return cv::Mat(img.height(), img.width(),format, img.bits(), img.bytesPerLine()).clone();

the problem is here:

return cv::Mat(img.height(), img.width(),format, img.bits(), img.bytesPerLine());

you're taking a shallow copy of the data pointer (img.bits()) here, it will be invalid, once you leave that callback function.

remedy: add a clone() as in:

return cv::Mat(img.height(), img.width(),format, img.bits(), img.bytesPerLine()).clone();