I'm using opencv to create panorama images by extracting video frames from 360 videos, and for the most part it's working great. However, I've discovered that my resulting panoramas have many "zero" values around the edges. This is a result of the camera moving up and down while the video is being recorded. Is there any efficient way to crop out all zero values?
I found this question and several working answers about how to crop an image to the minimum size necessary to include all content, but I'm trying to eliminate all empty cells from my image.
For example, if input is:
0 0 0 0 0 0 0 0
0 0 2 2 0 0 3 0
0 0 175 8 2 9 71 0
0 0 3 12 8 54 0 0
0 0 4 39 255 7 0 0
0 0 0 2 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
then output should be:
175 8 2 9
3 12 8 54
4 39 255 7
I'm sort of looking for the inverse of minAreaRect, where the output of the command is the maximum rectangle that can be formed within the nonzero portion of the image.