Ask Your Question
3

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

asked 2017-06-22 10:17:48 -0600

bhornde gravatar image

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);
edit retag flag offensive close merge delete

Comments

nice catch ;)

it's reproducable, and probably should go here

berak gravatar imageberak ( 2017-06-22 10:55:05 -0600 )edit

^^ good boy, much appreciated ;)

berak gravatar imageberak ( 2017-06-23 05:26:58 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2017-06-23 05:25:44 -0600

bhornde gravatar image

@berak Thanks, I submitted a new issue (https://github.com/opencv/opencv/issu...) :)

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-06-22 10:17:48 -0600

Seen: 270 times

Last updated: Jun 22 '17