iOS 上的拼接全景崩溃与 cvflann::anyimpl::bad_any_cast
Stitching panorama on iOS crashes with cvflann::anyimpl::bad_any_cast
我没有使用 c++ 的经验,但我需要在 iOS 应用程序中与 OpenCV 交互。我正确地构建了它,但在调用一些 c++ 代码时它崩溃了。
下面的代码崩溃并显示以下消息:libc++abi.dylib: libc++abi.dylib: terminating with uncaught exception of type cvflann::anyimpl::bad_any_cast
terminating with uncaught exception of type cvflann::anyimpl::bad_any_cast
bool stitch(const std::vector <cv::Mat> & images, cv::Mat &result) {
Stitcher stitcher = Stitcher::createDefault(false);
Stitcher::Status status = stitcher.stitch(images, result); <-- Crash!
if (status != Stitcher::OK) {
return false;
}
return true;
}
我认为这是因为stitch(...)
的输入或输出是不正确的类型,但我无法弄清楚我需要给它什么或如何转换它。
我调用的函数定义如下:
Status stitch(InputArrayOfArrays images, OutputArray pano);
其中InputArrayOfArrays
和OutputArray
都是_InputArray的别名
怎么办?
编辑:这是使用OpenCV 3.0,我认为我使用的示例代码是用于OpenCV 2.4的。也许这就是问题所在。
我在IOS中遇到了与导入相关的类似问题,并添加了
#import <opencv2/opencv.hpp>
导致一堆链接器警告,最终每次调用任何 OpenCV 函数都因上述错误而失败,在我用更具体的导入替换上面的导入后,问题消失了:
#import <opencv2/imgcodecs.hpp>
我认为问题可能与导入订购或导入重复有关,请注意希望它有所帮助......
openCV 中已经存在了一段时间,它仅在调试模式下输出此错误时崩溃。尝试产品 ->方案 ->编辑方案,并将"运行"的构建配置从调试更改为发布。
放弃opencv.hpp的包含以支持最小的包含集也对我有用。 以下是我最终在我的案例中得到的包含。
#import <opencv2/calib3d.hpp>
#import <opencv2/features2d.hpp>
#import <opencv2/xfeatures2d.hpp>
#import <opencv2/imgproc/imgproc.hpp>
当时,我从拨打FlannBasedMatcher::knnMatch的某个地方获得了bad_any_cast,并且在找到此解决方案之前尝试了许多"更正"。
谢谢!
相同的崩溃 修复了使用以下代码的问题:
使用适用于 iOS 应用程序的开放式 cv 2.4.9 版本的拼接。另外,使用此代码它将非常适合iOS应用程序
https://github.com/foundry/OpenCVSwiftStitch
我已经花太多时间来修复崩溃,但现在它得到了修复。
- 如何理解C++标准N3337中的expr.const.cast子句8
- C++Cast运算符过载
- 错误:"cast"未命名类型void setCastDescription(std::string
- 通过使用 const-cast 的非常量引用来延长临时的寿命
- "(void) cast"与功能有什么区别 "__attributes__"来沉默未使用的参数警告?
- C++:"Expected '(' for function-style cast or type construction"错误
- 为什么选择 g++ 给予者:"error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]"
- Gtk+ g_signal_connect() 和 C++ lambda 会导致"invalid cast"错误
- Shared_ptr cast vs static_cast speed
- 在 iOS 上使用 Aruco 构建 OpenCV 时"Functional-style cast from id to double is not allowed"
- 覆盖 CAST 运算符(我认为它被称为向下转换)
- C++错误,隐 <function-style-cast> 式要求使用模板化类一次调用多个构造函数的多个转换
- 如何修复<function-style-cast>错误:无法从'initializer list'转换为asdending比较<W>(模板函子)
- C++ C++ 中的函数声明,键入 CAST
- iOS 上的拼接全景崩溃与 cvflann::anyimpl::bad_any_cast
- static_cast会丢弃错误,但C风格的演员cast有效
- C++ cast char * to unsigned char
- 禁用 Clang 中的"cast from pointer to smaller type uint32_t"错误
- 是否可以使用gcc 3.3版修复与int*cast相关的Sun Solaris OS 5.8分段故障
- C++ const-cast 一个引用