我正在尝试在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();
我的Android.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
任何人都有任何线索?感谢
答案 0 :(得分:4)
我现在就开始工作了。 我忘了在Android.mk中添加prebuild库,如下所示:
#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
答案 1 :(得分: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添加到项目中。 (如果从源代码进行自定义构建,则在cmake(和make install)步骤中生成OpenCV.mk。)