OpenStitching / stitching

A Python package for fast and robust Image Stitching
Apache License 2.0
1.99k stars 156 forks source link

StitchingError: Invalid Contour. Try without cropping. #61

Closed AndSzyShe closed 1 year ago

AndSzyShe commented 1 year ago

I've tried everything to get the cropper part of the code to work, but I keep getting the same error no matter what I do.

Code works until:

Cropper(crop = True) from stitching.cropper import Cropper cropper = Cropper()

mask = cropper.estimate_panorama_mask(warped_low_imgs, warped_low_masks, low_corners, low_sizes) plot_image(mask, (5,5))

When I run the next section, I get an error:

from largest interiorrectangle import lir, pt1, pt2, lir_basis, lir_within_contour, lir_within_polygon lir = cropper.estimate_largest_interior_rectangle(mask) print(lir)

Error:

StitchingError Treaceback(most recent call last) ~\AppData\Local\Temp/ipykernnel_14476/1283171828.py in <module> ----> 1 lir = cropper.estimate_largest_interior_rectangle(mask) 2 print(lir)

~\anaconda3\lib\site-packages\stitching\cropper.py in estimate_largest_interior_rectangle(self, mask)

contours, hierarchy = cv.findContours(mask, cv.RETR_TREE, cv.CHAIN_APPROX_NONE) if not hierarchy.shape == (1, 1, 4) or not np.all(hierarchy == -1): raise StitchingError("Invalid Contour. Try without cropping.") contour = contours[0][:, 0, :]

StitchingError: Invalid Contour. Try without cropping.

Any advice?

lukasalexanderweber commented 1 year ago

Cropper(crop = False)

lukasalexanderweber commented 1 year ago

what would be a better error message for you to understand it directly? Should I change it to:

StitchingError: Invalid Contour. Run with --no-crop (using the stitch interface), crop=false (using the stitcher class) or Cropper(False) (using the cropper class)

lukasalexanderweber commented 1 year ago

I might help you if you share the result without cropping. Probably there is a irregular shape