1. 程式人生 > >Android系統編譯:新增OpenCV庫和模型配置檔案

Android系統編譯:新增OpenCV庫和模型配置檔案

一、新增 libopencv_java3.so庫至/system/lib64/

在Android原始碼目錄的hardware/libgesture/目錄下建立libopencvhw資料夾,並將libopencv_java3.so檔案放置於該目錄下,並在此目錄下建立Android.mk檔案:

LOCAL_PATH := $(call my-dir)

#opencv libopencv_java3

include $(CLEAR_VARS)
LOCAL_MODULE := libopencv_java3
LOCAL_MULTILIB := 64
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_MODULE_SUFFIX := .so LOCAL_SRC_FILES_64 := libopencv_java3.so include $(BUILD_PREBUILT)

二、新增使用OpenCV庫時用到的模型檔案和配置檔案至/data/system/

在system目錄下建立opencv_config資料夾,將model.pb、model_config.pbtxt、opencv.properties放置在該資料夾下,建立Android.mk檔案:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE
:= model LOCAL_MODULE_CLASS := DATA LOCAL_MODULE_SUFFIX := .pb LOCAL_SRC_FILES := model.pb LOCAL_MODULE_PATH := $(PRODUCT_OUT)/data/system include $(BUILD_PREBUILT) include $(CLEAR_VARS) LOCAL_MODULE := model_config LOCAL_MODULE_CLASS := DATA LOCAL_MODULE_SUFFIX := .pbtxt LOCAL_SRC_FILES := model_config.
pbtxt LOCAL_MODULE_PATH := $(PRODUCT_OUT)/data/system include $(BUILD_PREBUILT) include $(CLEAR_VARS) LOCAL_MODULE := opencv LOCAL_MODULE_CLASS := DATA LOCAL_MODULE_SUFFIX := .properties LOCAL_SRC_FILES := opencv.properties LOCAL_MODULE_PATH := $(PRODUCT_OUT)/data/system include $(BUILD_PREBUILT)