bjorn
bjorn

Reputation: 338

Opencv height/width of part of image

I've an image like this one ![enter image description here][1]. The non-black part is expanded at each iteration. So, after a certain point, I need to enlarge the final image so the non-black one can fit in. For now, what I'm doing is to find the contour of the non-black image,find the bounding box of the contours and check the width/height of the box. At a first time it works, but after some iterations my program finds a bounding box of size 1 (it seems that it doesn't find any contour). What the problem could be?

Ps: the program is a mosaic from a video file, I followed the opencv tutorial for find homography and other stuff.

EDIT Sorry but I had to remove images

Upvotes: 0

Views: 764

Answers (1)

Kornel
Kornel

Reputation: 5354

Just a suggestion:

It's easier to simply iterate through each element in the matrix and record the coordinates of the uppermost, bottommost, leftmost and rightmost non-zero elements. These will be the four corners of your up-right bounding rectangle. Of course it is not necessarily the rectangle of the minimum area enclosing the non-zero pixels (not a rotated rectangle), but further can be used as a ROI.

Upvotes: 1

Related Questions