Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Xiaomi
Mace
提交
2dbe26d6
Mace
项目概览
Xiaomi
/
Mace
通知
106
Star
40
Fork
27
代码
文件
提交
分支
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2dbe26d6
编写于
8月 27, 2018
作者:
刘
刘琦
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'android' into 'master'
Fix abnormal exit after create engine failed See merge request !767
上级
1c79e4a2
b16842bb
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
33 addition
and
8 deletion
+33
-8
mace/examples/android/app/src/main/java/com/xiaomi/mace/demo/AppModel.java
...roid/app/src/main/java/com/xiaomi/mace/demo/AppModel.java
+17
-3
mace/examples/android/app/src/main/java/com/xiaomi/mace/demo/CameraActivity.java
...pp/src/main/java/com/xiaomi/mace/demo/CameraActivity.java
+16
-5
未找到文件。
mace/examples/android/app/src/main/java/com/xiaomi/mace/demo/AppModel.java
浏览文件 @
2dbe26d6
...
...
@@ -28,6 +28,7 @@ import org.greenrobot.eventbus.EventBus;
public
class
AppModel
{
private
boolean
stopClassify
=
false
;
private
Handler
mJniThread
;
public
static
AppModel
instance
=
new
AppModel
();
private
AppModel
()
{
...
...
@@ -54,8 +55,18 @@ public class AppModel {
@Override
public
void
run
()
{
int
result
=
JniMaceUtils
.
maceMobilenetCreateEngine
(
initData
.
getModel
(),
initData
.
getDevice
());
if
(
result
==
-
1
&&
callback
!=
null
)
{
callback
.
onCreateEngineFail
();
Log
.
i
(
"APPModel"
,
"maceMobilenetCreateEngine result = "
+
result
);
if
(
result
==
-
1
)
{
stopClassify
=
true
;
MaceApp
.
app
.
mMainHandler
.
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
callback
.
onCreateEngineFail
(
InitData
.
DEVICES
[
0
].
equals
(
initData
.
getDevice
()));
}
});
}
else
{
stopClassify
=
false
;
}
}
});
...
...
@@ -65,6 +76,9 @@ public class AppModel {
mJniThread
.
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(
stopClassify
)
{
return
;
}
long
start
=
System
.
currentTimeMillis
();
float
[]
result
=
JniMaceUtils
.
maceMobilenetClassify
(
input
);
...
...
@@ -76,7 +90,7 @@ public class AppModel {
}
public
interface
CreateEngineCallback
{
void
onCreateEngineFail
();
void
onCreateEngineFail
(
final
boolean
quit
);
}
}
mace/examples/android/app/src/main/java/com/xiaomi/mace/demo/CameraActivity.java
浏览文件 @
2dbe26d6
...
...
@@ -25,7 +25,6 @@ import android.view.WindowManager;
import
android.widget.Button
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
com.xiaomi.mace.demo.camera.CameraEngage
;
...
...
@@ -187,17 +186,29 @@ public class CameraActivity extends Activity implements View.OnClickListener, Ap
}
@Override
public
void
onCreateEngineFail
()
{
public
void
onCreateEngineFail
(
final
boolean
quit
)
{
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
this
);
builder
.
setTitle
(
"Error"
);
builder
.
setMessage
(
"Failed to create inference engine with current setting
!"
);
builder
.
setMessage
(
"Failed to create inference engine with current setting
:\n"
+
initData
.
getModel
()
+
", "
+
initData
.
getDevice
()
);
builder
.
setCancelable
(
false
);
builder
.
setPositiveButton
(
"Qui
t"
,
new
DialogInterface
.
OnClickListener
()
{
builder
.
setPositiveButton
(
quit
?
"Quit"
:
"Rese
t"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
finish
();
if
(
quit
)
{
System
.
exit
(
0
);
}
else
{
dialog
.
dismiss
();
resetCpu
();
}
}
});
builder
.
show
();
}
private
void
resetCpu
()
{
String
content
=
InitData
.
DEVICES
[
0
];
mSelectPhoneType
.
setText
(
content
);
initData
.
setDevice
(
content
);
AppModel
.
instance
.
maceMobilenetCreateEngine
(
initData
,
CameraActivity
.
this
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录