我无法通过在Android中的场景中查找对象来使用OpenCV示例。我从OpenCV4Android SDK中获取了预构建的静态库。 我的Android.mk
# Open CV libraries
include $(CLEAR_VARS)
LOCAL_MODULE := opencv_features2d
LOCAL_SRC_FILES := prebuilt/OpenCV/libs/$(TARGET_ARCH_ABI)/libopencv_features2d.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := opencv_core
LOCAL_SRC_FILES := prebuilt/OpenCV/libs/$(TARGET_ARCH_ABI)/libopencv_core.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := opencv_imgproc
LOCAL_SRC_FILES := prebuilt/OpenCV/libs/$(TARGET_ARCH_ABI)/libopencv_imgproc.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := opencv_calib3d
LOCAL_SRC_FILES := prebuilt/OpenCV/libs/$(TARGET_ARCH_ABI)/libopencv_calib3d.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := opencv_flann
LOCAL_SRC_FILES := prebuilt/OpenCV/libs/$(TARGET_ARCH_ABI)/libopencv_flann.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := opencv_contrib
LOCAL_SRC_FILES := prebuilt/OpenCV/libs/$(TARGET_ARCH_ABI)/libopencv_contrib.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := opencv_legacy
LOCAL_SRC_FILES := prebuilt/OpenCV/libs/$(TARGET_ARCH_ABI)/libopencv_legacy.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := opencv_ml
LOCAL_SRC_FILES := prebuilt/OpenCV/libs/$(TARGET_ARCH_ABI)/libopencv_ml.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := opencv_objdetect
LOCAL_SRC_FILES := prebuilt/OpenCV/libs/$(TARGET_ARCH_ABI)/libopencv_objdetect.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := opencv_tbb
LOCAL_SRC_FILES := prebuilt/OpenCV/3rdparty/libs/$(TARGET_ARCH_ABI)/libtbb.a
include $(PREBUILT_STATIC_LIBRARY)
# opencv_nonfree
include $(MY_CORE_PATH)/opencv_nonfree/Android.mk
# Detect image
include $(MY_CORE_PATH)/detectimage/Android.mk
Nonfree Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := opencv_nonfree
LOCAL_SRC_FILES := := nonfree_init.cpp \
sift.cpp \
surf.cpp
LOCAL_C_INCLUDES := $(MY_CORE_PATH)/prebuilt/OpenCV/include
LOCAL_STATIC_LIBRARIES := opencv_features2d opencv_imgproc opencv_video opencv_flann opencv_core opencv_tbb
LOCAL_LDLIBS := -ldl -lz -llog
include $(BUILD_SHARED_LIBRARY)
并检测Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := detect_image
LOCAL_SRC_FILES := detectimage.cpp
LOCAL_C_INCLUDES := $(MY_CORE_PATH)/prebuilt/OpenCV/include
LOCAL_SHARED_LIBRARIES := opencv_nonfree
LOCAL_LDLIBS := -ldl -lz -llog
include $(BUILD_SHARED_LIBRARY)
最后.cpp问题部分是
std::vector<Point2f> obj;
std::vector<Point2f> scene;
//....
Mat H = findHomography(obj, scene, CV_RANSAC);
答案 0 :(得分:1)
看起来像STL的一些问题
如果将Application.mk文件中的APP_STL标志设置为
APP_STL := gnustl_shared
一切正常