7

我正在尝试在 android 上使用 opencv(仅限 ndk)。我为 armeabi 编译了 git 存储库的最新源代码。(基于:Building_OpenCV4Android_from_trunk

但是我收到了这个错误(使用 ndk-build):

error: undefined reference to 'cv::Mat::deallocate()'
error: undefined reference to 'cv::fastFree(void*)'
error: undefined reference to 'cv::_OutputArray::_OutputArray(cv::Mat&)'
error: undefined reference to 'cv::Mat::copyTo(cv::_OutputArray const&)'
error: undefined reference to 'cv::Mat::inv(int) const'

简单的测试代码:

cv::Mat testMat = cv::Mat(cv::Matx44d
(
    1.0, 0.0, 0.0, 0.0,
    0.0, 1.0, 0.0, 0.0,
    0.0, 0.0, 1.0, 0.0,
    0.0, 0.0, 0.0, 1.0
));
cv::Mat testMatInv = testMat.inv();

我的安卓.mk:

LOCAL_C_INCLUDES :=  $(LOCAL_PATH)/../../../../libs/opencv/include
LOCAL_LDLIBS += -L../../../../libs/opencv/lib/android/armeabi
LOCAL_LDLIBS += -llog -lGLESv2 –lz
LOCAL_STATIC_LIBRARIES := libzip libpng libjpeg freetype
LOCAL_STATIC_LIBRARIES += libopencv_calib3d libopencv_contrib libopencv_core libopencv_features2d libopencv_flann libopencv_highgui libopencv_imgproc libopencv_legacy libopencv_ml libopencv_nonfree libopencv_objdetect libopencv_photo libopencv_stitching libopencv_ts libopencv_video libopencv_videostab

有人有任何线索吗?谢谢

4

2 回答 2

5

我现在开始工作了。我忘记在 Android.mk 中添加预构建库,如下所示:

#same for all other openCV Libs
LOCAL_MODULE := libopencv_calib3d
LOCAL_SRC_FILES := ../../opencv/lib/android/$(TARGET_ARCH_ABI)/libopencv_calib3d.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)

.....
LOCAL_STATIC_LIBRARIES += libopencv_contrib libopencv_legacy libopencv_ml libopencv_stitching libopencv_nonfree libopencv_objdetect libopencv_videostab libopencv_calib3d libopencv_photo libopencv_video libopencv_features2d libopencv_highgui libopencv_androidcamera libopencv_flann libopencv_imgproc libopencv_ts libopencv_core
于 2013-02-22T21:49:29.203 回答
3

图书馆的顺序很重要。

尝试:

LOCAL_STATIC_LIBRARIES += libopencv_contrib libopencv_legacy libopencv_ml libopencv_stitching libopencv_nonfree libopencv_objdetect libopencv_videostab libopencv_calib3d libopencv_photo libopencv_video libopencv_features2d libopencv_highgui libopencv_androidcamera libopencv_flann libopencv_imgproc libopencv_core

推荐的方法不是硬编码 .mk 文件中的所有名称,而是使用 OpenCV SDK 中的 OpenCV.mk 将 OpenCV 添加到您的项目中。(如果您从源代码进行自定义构建,则 OpenCV.mk 在 cmake(和 make install)步骤生成。)

于 2013-02-01T16:03:31.350 回答