Android下的OpenCV - imdecode连接错误

时间:2012-03-16 01:08:16

标签: android opencv android-ndk

我使用OpenCV 2.3.1的预建库在我的Android原生代码中调用cv::imdecode()的问题已经困难了几个小时。

这是我想要做的。我的库现在检测到图像BarcodesLibrary中的QR码,它是作为静态库构建的。然后我为JNI编写了一些包装器,确保Java / C ++对象之间的转换 - 这些模块打包到共享库JNI_QRBarcodesLibrary中,BarcodesLibrary也链接到它。

现在变成了这个转储中显示的错误。错误与插入highgui模块和调用imdecode()有关。只需要提一下,所有内容编译都很好,并且在没有imdecode()的情况下将库成功导入到android中。

"Compile++ thumb : JNI_QRBarcodesLibrary <= JNI_QRBarcodesLibrary.cpp
"Compile++ thumb : JNI_QRBarcodesLibrary <= jDetectedMark.cpp
"Compile++ thumb : JNI_QRBarcodesLibrary <= jImage.cpp
"Compile++ thumb : JNI_QRBarcodesLibrary <= JNIWrapper.cpp
"Compile++ thumb : JNI_QRBarcodesLibrary <= jPoint.cpp
"Compile++ thumb : JNI_QRBarcodesLibrary <= jSize.cpp
"Compile++ thumb : BarcodesLibrary <= Image.cpp
"Compile++ thumb : BarcodesLibrary <= Barcode.cpp
"Compile++ thumb : BarcodesLibrary <= QrBarcode.cpp
Prebuilt       : libopencv_contrib.a <= ../OpenCV/libs/Android/armeabi/
Prebuilt       : libopencv_calib3d.a <= ../OpenCV/libs/Android/armeabi/
Prebuilt       : libopencv_objdetect.a <= ../OpenCV/libs/Android/armeabi/
Prebuilt       : libopencv_features2d.a <= ../OpenCV/libs/Android/armeabi/
Prebuilt       : libopencv_video.a <= ../OpenCV/libs/Android/armeabi/
Prebuilt       : libopencv_imgproc.a <= ../OpenCV/libs/Android/armeabi/
Prebuilt       : libopencv_highgui.a <= ../OpenCV/libs/Android/armeabi/
Prebuilt       : libopencv_ml.a <= ../OpenCV/libs/Android/armeabi/
Prebuilt       : libopencv_legacy.a <= ../OpenCV/libs/Android/armeabi/
Prebuilt       : libopencv_flann.a <= ../OpenCV/libs/Android/armeabi/
Prebuilt       : libopencv_core.a <= ../OpenCV/libs/Android/armeabi/
Prebuilt       : lib3rdparty_libjpeg.a <= ../OpenCV/libs/Android/armeabi/
Prebuilt       : lib3rdparty_libpng.a <= ../OpenCV/libs/Android/armeabi/
Prebuilt       : lib3rdparty_libtiff.a <= ../OpenCV/libs/Android/armeabi/
Prebuilt       : lib3rdparty_libjasper.a <= ../OpenCV/libs/Android/armeabi/
Prebuilt       : lib3rdparty_zlib.a <= ../OpenCV/libs/Android/armeabi/
Prebuilt       : libgnustl_static.a <= <NDK>/sources/cxx-stl/gnu-libstdc++/libs/armeabi
StaticLibrary  : libBarcodesLibrary.a
SharedLibrary  : libJNI_QRBarcodesLibrary.so

构建以此错误结束:

./obj/local/armeabi/libopencv_highgui.a(grfmt_pxm.o):(.data.rel.ro+0x0): undefined reference to `vtable for __cxxabiv1::__enum_type_info'
./obj/local/armeabi/libopencv_highgui.a(bitstrm.o):(.data.rel.ro+0x0): undefined reference to `vtable for __cxxabiv1::__enum_type_info'
collect2: ld returned 1 exit status
make: *** [obj/local/armeabi/libJNI_QRBarcodesLibrary.so] Error 1

好吧,我期待这个库中的所有功能都不会受到支持,而这个库提供了依赖于操作系统的imshow,waitKey等等。但是imdecode的问题是我没想到的。

那么您是否有任何想法如何解决此问题或任何其他可以移植到Android并提供图像解码的库 - 尤其是JPEG格式?

我很感激任何提示。感谢。

1 个答案:

答案 0 :(得分:1)

使用OpenCV发行版中的OpenCV.mk将OpenCV添加到项目中。它将解决所有依赖项。

如果您正在使用SourceForge中的OpenCV预建二进制文件,那么您可以在share / OpenCV子文件夹中找到此文件。您需要直接在该文件夹中加入OpenCV.mk