Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
Mace
提交
051b213b
Mace
项目概览
慢慢CG
/
Mace
与 Fork 源项目一致
Fork自
Xiaomi / Mace
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Mace
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
051b213b
编写于
11月 02, 2018
作者:
李
李滨
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'support_so_in_demo' into 'master'
support dynamic load libmace in demo See merge request !802
上级
0c43b9da
13541b1a
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
74 addition
and
20 deletion
+74
-20
.gitlab-ci.yml
.gitlab-ci.yml
+1
-1
mace/codegen/BUILD
mace/codegen/BUILD
+0
-1
mace/core/status.cc
mace/core/status.cc
+0
-0
mace/examples/android/README.md
mace/examples/android/README.md
+10
-1
mace/examples/android/app/src/main/java/com/xiaomi/mace/demo/camera/CameraApiLessM.java
...main/java/com/xiaomi/mace/demo/camera/CameraApiLessM.java
+3
-4
mace/examples/android/build.sh
mace/examples/android/build.sh
+54
-8
mace/examples/android/macelibrary/CMakeLists.txt
mace/examples/android/macelibrary/CMakeLists.txt
+5
-4
mace/libmace/mace_version_script.lds
mace/libmace/mace_version_script.lds
+1
-0
mace/utils/BUILD
mace/utils/BUILD
+0
-1
未找到文件。
.gitlab-ci.yml
浏览文件 @
051b213b
...
@@ -135,4 +135,4 @@ model_tests:
...
@@ -135,4 +135,4 @@ model_tests:
build_android_demo
:
build_android_demo
:
stage
:
build_android_demo
stage
:
build_android_demo
script
:
script
:
-
pushd mace/examples/android/ && bash build.sh
build
&& popd
-
pushd mace/examples/android/ && bash build.sh
static && bash build.sh dynamic
&& popd
mace/codegen/BUILD
浏览文件 @
051b213b
...
@@ -50,7 +50,6 @@ cc_library(
...
@@ -50,7 +50,6 @@ cc_library(
copts
=
[
"-Werror"
,
"-Wextra"
,
"-Wno-missing-field-initializers"
],
copts
=
[
"-Werror"
,
"-Wextra"
,
"-Wno-missing-field-initializers"
],
deps
=
[
deps
=
[
"//mace/public"
,
"//mace/public"
,
"//mace/utils"
,
],
],
)
)
...
...
mace/
utils
/status.cc
→
mace/
core
/status.cc
浏览文件 @
051b213b
文件已移动
mace/examples/android/README.md
浏览文件 @
051b213b
...
@@ -6,7 +6,16 @@ How to build
...
@@ -6,7 +6,16 @@ How to build
```
sh
```
sh
cd
mace/exampls/android
cd
mace/exampls/android
./build.sh
./build.sh dynamic
# if libmace.a is needed, update `macelibrary/CMakeLists.txt` and run with `./build.sh static`.
```
Install
---------------
```
sh
# running after build step and in `mace/exampls/android` directory
adb
install
./app/build/outputs/apk/app/release/app-app-release.apk
```
```
Pre-built APK
Pre-built APK
...
...
mace/examples/android/app/src/main/java/com/xiaomi/mace/demo/camera/CameraApiLessM.java
浏览文件 @
051b213b
...
@@ -105,12 +105,11 @@ public class CameraApiLessM extends CameraEngage implements Camera.AutoFocusCall
...
@@ -105,12 +105,11 @@ public class CameraApiLessM extends CameraEngage implements Camera.AutoFocusCall
Camera
.
Parameters
parameters
=
mCamera
.
getParameters
();
Camera
.
Parameters
parameters
=
mCamera
.
getParameters
();
parameters
.
setFocusMode
(
Camera
.
Parameters
.
FOCUS_MODE_AUTO
);
parameters
.
setFocusMode
(
Camera
.
Parameters
.
FOCUS_MODE_AUTO
);
Camera
.
Size
size
=
getOptimalSize
(
parameters
.
getSupportedPreviewSizes
(),
width
,
height
);
Camera
.
Size
size
=
getOptimalSize
(
parameters
.
getSupportedPreviewSizes
(),
width
,
height
);
mPreviewWidth
=
size
.
width
;
mPreviewWidth
=
size
.
height
;
mPreviewHeight
=
size
.
height
;
mPreviewHeight
=
size
.
width
;
parameters
.
setPreviewSize
(
size
.
width
,
size
.
height
);
parameters
.
setPreviewSize
(
size
.
width
,
size
.
height
);
parameters
.
setPictureSize
(
size
.
width
,
size
.
height
);
mCamera
.
setParameters
(
parameters
);
mCamera
.
setParameters
(
parameters
);
mTextureView
.
setRatio
(
size
.
height
,
size
.
width
);
mTextureView
.
setRatio
(
mPreviewWidth
,
mPreviewHeight
);
}
}
private
Camera
.
Size
getOptimalSize
(
List
<
Camera
.
Size
>
sizes
,
int
w
,
int
h
)
{
private
Camera
.
Size
getOptimalSize
(
List
<
Camera
.
Size
>
sizes
,
int
w
,
int
h
)
{
...
...
mace/examples/android/build.sh
浏览文件 @
051b213b
...
@@ -2,12 +2,47 @@
...
@@ -2,12 +2,47 @@
set
-e
-u
-o
pipefail
set
-e
-u
-o
pipefail
Usage
()
{
echo
"Usage: ./build.sh [dynamic|static]"
echo
"|==============|====================|"
echo
"| parameter | lib will linked |"
echo
"|==============|====================|"
echo
"| dynamic | libmace.so |"
echo
"|--------------|--------------------|"
echo
"| static | libmace.a |"
echo
"|--------------|--------------------|"
}
if
[
$#
-lt
1
]
;
then
Usage
exit
1
fi
MACE_LINK_TYPE
=
$1
pushd
../../../
pushd
../../../
TARGET_ABI
=
arm64-v8a
TARGET_ABI
=
arm64-v8a
LIBRARY_DIR
=
mace/examples/android/macelibrary/src/main/cpp/
ANDROID_DEMO_DIR
=
mace/examples/android/
LIBRARY_DIR
=
$ANDROID_DEMO_DIR
/macelibrary/src/main/cpp/
INCLUDE_DIR
=
$LIBRARY_DIR
/include/mace/public/
INCLUDE_DIR
=
$LIBRARY_DIR
/include/mace/public/
LIBMACE_DIR
=
$LIBRARY_DIR
/lib/
$TARGET_ABI
/
LIBMACE_DIR
=
$LIBRARY_DIR
/lib/
$TARGET_ABI
/
LIBGNUSTL_SHARED_SO
=
libgnustl_shared.so
LIBCPP_SHARED_SO
=
libc++_shared.so
JNILIBS_DIR
=
$ANDROID_DEMO_DIR
/macelibrary/src/main/jniLibs/
$TARGET_ABI
rm
-rf
$JNILIBS_DIR
if
[
$MACE_LINK_TYPE
==
"dynamic"
]
;
then
BAZEL_LIBMACE_TARGET
=
mace/libmace:libmace.so
BAZEL_GEN_LIBMACE_PATH
=
bazel-bin/mace/libmace/libmace.so
elif
[
$MACE_LINK_TYPE
==
"static"
]
;
then
BAZEL_LIBMACE_TARGET
=
mace/libmace:libmace_static
BAZEL_GEN_LIBMACE_PATH
=
bazel-genfiles/mace/libmace/libmace.a
else
Usage
exit
1
fi
rm
-rf
$LIBRARY_DIR
/include/
rm
-rf
$LIBRARY_DIR
/include/
mkdir
-p
$INCLUDE_DIR
mkdir
-p
$INCLUDE_DIR
...
@@ -21,14 +56,25 @@ python tools/converter.py convert --config=mace/examples/android/mobilenet.yml -
...
@@ -21,14 +56,25 @@ python tools/converter.py convert --config=mace/examples/android/mobilenet.yml -
cp
-rf
builds/mobilenet/include/mace/public/
*
.h
$INCLUDE_DIR
cp
-rf
builds/mobilenet/include/mace/public/
*
.h
$INCLUDE_DIR
cp
-rf
builds/mobilenet/model
$LIBRARY_DIR
cp
-rf
builds/mobilenet/model
$LIBRARY_DIR
bazel build
--config
android
--config
optimization
mace/libmace:libmace_static
--define
neon
=
true
--define
openmp
=
true
--define
opencl
=
true
--cpu
=
$TARGET_ABI
bazel build
--config
android
--config
optimization
$BAZEL_LIBMACE_TARGET
--define
neon
=
true
--define
openmp
=
true
--define
opencl
=
true
--cpu
=
$TARGET_ABI
cp
-rf
mace/public/
*
.h
$INCLUDE_DIR
cp
-rf
mace/public/
*
.h
$INCLUDE_DIR
cp
-rf
bazel-genfiles/mace/libmace/libmace.a
$LIBMACE_DIR
cp
-rf
$BAZEL_GEN_LIBMACE_PATH
$LIBMACE_DIR
popd
if
[
$MACE_LINK_TYPE
==
"dynamic"
]
;
then
mkdir
-p
$JNILIBS_DIR
cp
-rf
$BAZEL_GEN_LIBMACE_PATH
$JNILIBS_DIR
if
[
$#
-eq
1
]
&&
[
$1
==
"build"
]
;
then
if
[[
""
!=
`
$ANDROID_NDK_HOME
/ndk-depends
$BAZEL_GEN_LIBMACE_PATH
|
grep
$LIBGNUSTL_SHARED_SO
`
]]
;
then
./gradlew build
cp
-rf
$ANDROID_NDK_HOME
/sources/cxx-stl/gnu-libstdc++/4.9/libs/
$TARGET_ABI
/
$LIBGNUSTL_SHARED_SO
$JNILIBS_DIR
else
fi
./gradlew installAppRelease
if
[[
""
!=
`
$ANDROID_NDK_HOME
/ndk-depends
$BAZEL_GEN_LIBMACE_PATH
|
grep
$LIBCPP_SHARED_SO
`
]]
;
then
cp
-rf
$ANDROID_NDK_HOME
/sources/cxx-stl/llvm-libc++/libs/
$TARGET_ABI
/
$LIBCPP_SHARED_SO
$JNILIBS_DIR
fi
fi
fi
popd
# Build demo
./gradlew clean
./gradlew build
mace/examples/android/macelibrary/CMakeLists.txt
浏览文件 @
051b213b
...
@@ -14,9 +14,10 @@ cmake_minimum_required(VERSION 3.4.1)
...
@@ -14,9 +14,10 @@ cmake_minimum_required(VERSION 3.4.1)
include_directories
(
${
CMAKE_SOURCE_DIR
}
/
)
include_directories
(
${
CMAKE_SOURCE_DIR
}
/
)
include_directories
(
${
CMAKE_SOURCE_DIR
}
/src/main/cpp/include
)
include_directories
(
${
CMAKE_SOURCE_DIR
}
/src/main/cpp/include
)
set
(
mace_lib
${
CMAKE_SOURCE_DIR
}
/src/main/cpp/lib/arm64-v8a/libmace.a
)
file
(
GLOB LIBMACE
"
${
CMAKE_SOURCE_DIR
}
/src/main/cpp/lib/arm64-v8a/*"
)
set
(
mace_lib
${
LIBMACE
}
)
set
(
mobilenet_lib
${
CMAKE_SOURCE_DIR
}
/src/main/cpp/model/arm64-v8a/mobilenet.a
)
set
(
mobilenet_lib
${
CMAKE_SOURCE_DIR
}
/src/main/cpp/model/arm64-v8a/mobilenet.a
)
add_library
(
mace_lib S
TATIC
IMPORTED
)
add_library
(
mace_lib S
HARED
IMPORTED
)
set_target_properties
(
mace_lib PROPERTIES IMPORTED_LOCATION
${
mace_lib
}
)
set_target_properties
(
mace_lib PROPERTIES IMPORTED_LOCATION
${
mace_lib
}
)
add_library
(
mobilenet_lib STATIC IMPORTED
)
add_library
(
mobilenet_lib STATIC IMPORTED
)
set_target_properties
(
mobilenet_lib PROPERTIES IMPORTED_LOCATION
${
mobilenet_lib
}
)
set_target_properties
(
mobilenet_lib PROPERTIES IMPORTED_LOCATION
${
mobilenet_lib
}
)
...
@@ -49,8 +50,8 @@ find_library( # Sets the name of the path variable.
...
@@ -49,8 +50,8 @@ find_library( # Sets the name of the path variable.
target_link_libraries
(
# Specifies the target library.
target_link_libraries
(
# Specifies the target library.
mace_mobile_jni
mace_mobile_jni
mace_lib
mobilenet_lib
mobilenet_lib
mace_lib
# Links the target library to the log library
# Links the target library to the log library
# included in the NDK.
# included in the NDK.
${
log-lib
}
)
${
log-lib
}
)
\ No newline at end of file
mace/libmace/mace_version_script.lds
浏览文件 @
051b213b
...
@@ -10,6 +10,7 @@ mace {
...
@@ -10,6 +10,7 @@ mace {
# api for static library of models
# api for static library of models
*mace*logging*LogMessage*;
*mace*logging*LogMessage*;
*mace*MaceStatus*;
*mace*NetDef*;
*mace*NetDef*;
*mace*MemoryType*;
*mace*MemoryType*;
*mace*DataType*;
*mace*DataType*;
...
...
mace/utils/BUILD
浏览文件 @
051b213b
...
@@ -13,7 +13,6 @@ cc_library(
...
@@ -13,7 +13,6 @@ cc_library(
name
=
"utils"
,
name
=
"utils"
,
srcs
=
[
srcs
=
[
"logging.cc"
,
"logging.cc"
,
"status.cc"
,
"string_util.cc"
,
"string_util.cc"
,
],
],
hdrs
=
glob
([
hdrs
=
glob
([
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录