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

stitch image error:libc++abi.dylib: terminating with uncaught exception of type cvflann::anyimpl::bad_any_cast #8018

Closed
sushangjin opened this issue Jan 17, 2017 · 18 comments

Comments

@sushangjin
Copy link

System information (version)
  • OpenCV => 3.2.0
  • Operating System / Platform => iOS 10.2
  • Compiler =>
Detailed description

stitching images on iphone will crash,output error:
libc++abi.dylib: terminating with uncaught exception of type cvflann::anyimpl::bad_any_cast

but stitching images success on the simulator.

Steps to reproduce

the iOS project file:
opencvtest.zip

@visez
Copy link

visez commented Jan 24, 2017

This user had the same problem 6 years ago, is it still applicable?
http://opencv-users.1802565.n2.nabble.com/cdiggins-anyimpl-bad-any-cast-while-using-flann-td7020469.html

@dbulaienko
Copy link

+1

@p-i-
Copy link

p-i- commented Jun 3, 2017

@alalek
Copy link
Member

alalek commented Jun 3, 2017

Could someone try this patch ? It resolves memory corruption problem in flann library for some Apple compilers.

@p-i-
Copy link

p-i- commented Jun 3, 2017

I'm also getting hit by this bug: runtime error upon executing Stitcher::Status s = stitcher.estimateTransform(images);.

The error only occurs in debug build. Release build works okay.

Was it just that modules/flann/include/opencv2/flann/any.h operator to add? I inserted the code & rebuilt but it didn't change anything.

I noticed that patch is part of a larger commit (18 files modified). Should I be downloading and applying the whole commit? (can't see how to do this).

@alalek
Copy link
Member

alalek commented Jun 3, 2017

@p-i- Thank you for check! Other changes are not related to flann library.

@p-i-
Copy link

p-i- commented Jun 3, 2017

How does one go about debugging an iOS build? I can imagine setting up the project in Xcode copying across all the linker flags etc from opencv/platforms/ios/build_framework.py but that looks like a backbreaker.

@p-i-
Copy link

p-i- commented Jun 3, 2017

For my particular situation, replacing:
#import <opencv2/opencv.hpp>

... with:
#import <opencv2/stitching.hpp>
#import <opencv2/imgcodecs/ios.h> // UIImageToMat

... did the trick.

Hope this helps narrow it down for someone.

@devajith
Copy link

in my case replacing #include <opencv2/opencv.hpp>
with #include <opencv2/imgcodecs.hpp> worked.

@alex0-0
Copy link

alex0-0 commented Dec 14, 2017

Tried all of methods mentioned above, no one works... Struggling with this exception for so long time, can anybody help me?

@eduardramon
Copy link

Hi @alex0-0. I'm facing a very similar issue. Could you finally fix it?

@biomiker
Copy link

Here's a total hack that has gotten me past the cvflann::anyimpl::bad_any_cast exception. I suspect it will prove to be problematic down the road, but I'd be curious if anyone can comment on how feasible it is.

In Pods->OpenCV2->opencv_modules.hpp, on line 17, change:

#define HAVE_OPENCV_FLANN
to
#undef HAVE_OPENCV_FLANN

@tosone
Copy link

tosone commented Dec 1, 2018

Any idea now? I met this problem on ios 12.0 with opencv 3.4.4.

@SergioGeeK7
Copy link

same

@SergioGeeK7
Copy link

My issue was solved starting the Flann as
flann::Index lsh_index(Mat(), flann::LshIndexParams(20,15,2));

@dannydaddy3
Copy link

dannydaddy3 commented Nov 15, 2019

I had similar problem: Fixed it by replacing general import to specific ones.
But it didn't work for the first time, and then I realised I had 'PrefixHeader.pch' file which had include <opencv2/opencv.hpp>.
I commented the line and it resolved problem with crash

@sunshinfight
Copy link

Including headers necessary but import <opencv2/opencv.hpp> work for me.
thanks.

@alalek
Copy link
Member

alalek commented Aug 12, 2020

bad_any_cast problem should be fixed here: #17640 (3.4.11 / 4.4.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests