Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

cv::repeat after update 2.4 -> 3.2: Bug or Feature?

Consider this Code:

std::vector<int> lin = {1,2,3,4,5};
cv::Mat linmat = cv::Mat(lin).reshape(0,1);

At this point, we should have the Mat

[1,2,3,4,5]

So far so good. When applying cv::repeat to it in 2.4 like

cv::repeat(linmat,5,1,linmat);

The result in 2.4.8 was (like it should be):

[1,2,3,4,5,
 1,2,3,4,5,
 1,2,3,4,5,
 1,2,3,4,5,
 1,2,3,4,5]

But in 3.2, some memory-corruption happens when src = dst. The result is some memory-garbage. When I use a second Mat as dst, everything works fine. Is this supposed to be like this or is this a bug?

Full Code for 2.4.X

std::vector<int> lin = {1,2,3,4,5};
cv::Mat linmat = cv::Mat(lin).reshape(0,1);
cv::repeat(linmat,5,1,linmat);

"Workaround" Code for 3.2

std::vector<int> lin = {1,2,3,4,5};
cv::Mat temp = cv::Mat(lin).reshape(0,1), linmat;
cv::repeat(temp,5,1,linmat);