1

After i stitched 2 images using OpenCV C++, i want to crop the image to remove the black area around the stitched image. I will lose a part of the image but it is ok. the image look like this:

enter image description here

How can i find the image corners and crop all the black area ??

If there any good references, please provides me with some of it.

Regards,

2 Answers2

4

I've been using this piece of code from DJI dev guide (search for section "Cropping the Panorama"). https://dji-dev.gitbooks.io/mobile-sdk-tutorials/content/en/iOS/PanoDemo/PanoDemo_en.html#stitching-photos

The algorithm does not seem very robust at first glance, but so far it has proven to be good enough for my stitching use cases. However, I believe the code got a couple of bugs on these two lines

bool isBottomNotBlack=checkBlackRow(gray, roiRect.y+roiRect.height,roiRect);
bool isRightNotBlack=checkBlackColumn(gray, roiRect.x+roiRect.width,roiRect);

which should be changed to

bool isBottomNotBlack=checkBlackRow(gray, roiRect.y+roiRect.height-1,roiRect);
bool isRightNotBlack=checkBlackColumn(gray, roiRect.x+roiRect.width-1,roiRect);

Otherwise, you may get non-systematic C's bad excess error. Hope that helps!

Khanh
  • 405
  • 3
  • 10
0

cropping is now integrated in the opencv_stitching_tool

Lukas Weber
  • 455
  • 6
  • 13