Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Affine Stitching works on horizontal alignment but fails with the same images on vertical alignment #125

Open
mcranium opened this issue Aug 14, 2023 · 3 comments
Labels
needs investigation Collect and attach more details (build flags, stacktraces, input dumps, etc)

Comments

@mcranium
Copy link

Dear developers,

thank you for this very useful tool! I will definitively use it a lot for my projects.

I just ran into an issue when trying to assemble an affine panorama that is not horizontal but vertical (i.e. the numebr of rows is bigger than the number of columns). This can be reproduced with the following images.

horizontal_left
horizontal_mid
horizontal_right

The horizontal panorama worksusing this command:

stitch --affine --detector sift *.png

vertical_lower
vertical_mid
vertical_upper

With the same images rotated 90 degrees I get the following error message after a long computation time:

stitching vertical_lower.png vertical_mid.png vertical_upper.png into result.jpg
Traceback (most recent call last):
  File "/home/mario/.local/bin/stitch", line 8, in <module>
    sys.exit(main())
  File "/home/mario/.local/lib/python3.8/site-packages/stitching/cli/stitch.py", line 278, in main
    panorama = stitcher.stitch(img_names)
  File "/home/mario/.local/lib/python3.8/site-packages/stitching/stitcher.py", line 117, in stitch
    self.blend_images(imgs, seam_masks, corners)
  File "/home/mario/.local/lib/python3.8/site-packages/stitching/stitcher.py", line 230, in blend_images
    for idx, (img, mask, corner) in enumerate(zip(imgs, masks, corners)):
  File "/home/mario/.local/lib/python3.8/site-packages/stitching/stitcher.py", line 202, in compensate_exposure_errors
    for idx, (corner, img) in enumerate(zip(corners, imgs)):
  File "/home/mario/.local/lib/python3.8/site-packages/stitching/cropper.py", line 66, in crop_images
    for idx, img in enumerate(imgs):
  File "/home/mario/.local/lib/python3.8/site-packages/stitching/warper.py", line 41, in warp_images
    yield self.warp_image(img, camera, aspect)
  File "/home/mario/.local/lib/python3.8/site-packages/stitching/warper.py", line 45, in warp_image
    _, warped_image = warper.warp(
cv2.error: OpenCV(4.7.0) /io/opencv/modules/imgproc/src/imgwarp.cpp:1724: error: (-215:Assertion failed) dst.cols < SHRT_MAX && dst.rows < SHRT_MAX && src.cols < SHRT_MAX && src.rows < SHRT_MAX in function 'remap'

I think it would be great if this inconvenience could be solved, maybe even in a way that would allow the program to rotate all images in steps of 90 degrees, if doing so without fails.

Best wishes,
Mario

@lukasalexanderweber
Copy link
Member

Could you follow the tutorial with affine settings to find out where the problem is with the vertical images? If it's already in the feature detection / matching or later during warping. In homography mode you can set wave_correct_kind to vert as input that images are vertical, but we don't do wave correction for affine images.

I suggest you rotate the images by yourself or dig deeper on why it fails and how it could be resolved (you would probably need to check in OpenCV itself rather than this wrapper)

@lukasalexanderweber lukasalexanderweber changed the title Panorama can not be vertical Affine Stitching works on horizontal alignment but fails with the same images on vertical alignment Aug 14, 2023
@lukasalexanderweber
Copy link
Member

Additionally I noticed that the order of the vertical images is wrong (or is it?). While order shouldn't be an issue it might also be worth investigating

@lukasalexanderweber lukasalexanderweber added the needs investigation Collect and attach more details (build flags, stacktraces, input dumps, etc) label Aug 14, 2023
@mstenta
Copy link
Contributor

mstenta commented Oct 14, 2024

Maybe this is fixed now? See #244

@mcranium Can you test this again and see if #244 helped?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs investigation Collect and attach more details (build flags, stacktraces, input dumps, etc)
Projects
None yet
Development

No branches or pull requests

3 participants