Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
f4352e50
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
331
Star
4
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
271
列表
看板
标记
里程碑
合并请求
78
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle-Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
271
Issue
271
列表
看板
标记
里程碑
合并请求
78
合并请求
78
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f4352e50
编写于
7月 04, 2018
作者:
R
Ruilong Liu
提交者:
GitHub
7月 04, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' into develop
上级
85f79a2d
076db279
变更
23
隐藏空白更改
内联
并排
Showing
23 changed file
with
1061 addition
and
1 deletion
+1061
-1
demo/android/PaddleMobile_Android/.gitignore
demo/android/PaddleMobile_Android/.gitignore
+9
-0
demo/android/PaddleMobile_Android/app/.gitignore
demo/android/PaddleMobile_Android/app/.gitignore
+1
-0
demo/android/PaddleMobile_Android/app/build.gradle
demo/android/PaddleMobile_Android/app/build.gradle
+23
-0
demo/android/PaddleMobile_Android/app/proguard-rules.pro
demo/android/PaddleMobile_Android/app/proguard-rules.pro
+21
-0
demo/android/PaddleMobile_Android/app/src/main/AndroidManifest.xml
...oid/PaddleMobile_Android/app/src/main/AndroidManifest.xml
+24
-0
demo/android/PaddleMobile_Android/app/src/main/java/com/baidu/paddle/MainActivity.java
...roid/app/src/main/java/com/baidu/paddle/MainActivity.java
+408
-0
demo/android/PaddleMobile_Android/app/src/main/java/com/baidu/paddle/PML.java
...obile_Android/app/src/main/java/com/baidu/paddle/PML.java
+23
-0
demo/android/PaddleMobile_Android/app/src/main/res/drawable/ic_launcher_background.xml
...roid/app/src/main/res/drawable/ic_launcher_background.xml
+170
-0
demo/android/PaddleMobile_Android/app/src/main/res/layout/main_activity.xml
...eMobile_Android/app/src/main/res/layout/main_activity.xml
+55
-0
demo/android/PaddleMobile_Android/app/src/main/res/mipmap-hdpi/ic_launcher.png
...bile_Android/app/src/main/res/mipmap-hdpi/ic_launcher.png
+0
-0
demo/android/PaddleMobile_Android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
...ndroid/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
+0
-0
demo/android/PaddleMobile_Android/app/src/main/res/values/colors.xml
...d/PaddleMobile_Android/app/src/main/res/values/colors.xml
+6
-0
demo/android/PaddleMobile_Android/app/src/main/res/values/strings.xml
.../PaddleMobile_Android/app/src/main/res/values/strings.xml
+5
-0
demo/android/PaddleMobile_Android/app/src/main/res/values/styles.xml
...d/PaddleMobile_Android/app/src/main/res/values/styles.xml
+11
-0
demo/android/PaddleMobile_Android/build.gradle
demo/android/PaddleMobile_Android/build.gradle
+27
-0
demo/android/PaddleMobile_Android/gradle.properties
demo/android/PaddleMobile_Android/gradle.properties
+18
-0
demo/android/PaddleMobile_Android/gradle/wrapper/gradle-wrapper.jar
...id/PaddleMobile_Android/gradle/wrapper/gradle-wrapper.jar
+0
-0
demo/android/PaddleMobile_Android/gradle/wrapper/gradle-wrapper.properties
...leMobile_Android/gradle/wrapper/gradle-wrapper.properties
+6
-0
demo/android/PaddleMobile_Android/gradlew
demo/android/PaddleMobile_Android/gradlew
+160
-0
demo/android/PaddleMobile_Android/gradlew.bat
demo/android/PaddleMobile_Android/gradlew.bat
+90
-0
demo/android/PaddleMobile_Android/settings.gradle
demo/android/PaddleMobile_Android/settings.gradle
+1
-0
doc/development_doc.md
doc/development_doc.md
+1
-0
tools/op.cmake
tools/op.cmake
+2
-1
未找到文件。
demo/android/PaddleMobile_Android/.gitignore
0 → 100644
浏览文件 @
f4352e50
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
demo/android/PaddleMobile_Android/app/.gitignore
0 → 100644
浏览文件 @
f4352e50
demo/android/PaddleMobile_Android/app/build.gradle
0 → 100644
浏览文件 @
f4352e50
apply
plugin:
'com.android.application'
android
{
compileSdkVersion
21
defaultConfig
{
applicationId
"com.baidu.paddle"
minSdkVersion
15
targetSdkVersion
21
versionCode
1
versionName
"1.0"
}
buildTypes
{
release
{
minifyEnabled
false
proguardFiles
getDefaultProguardFile
(
'proguard-android.txt'
),
'proguard-rules.pro'
}
}
}
dependencies
{
implementation
fileTree
(
dir:
'libs'
,
include:
[
'*.jar'
])
implementation
'com.android.support:appcompat-v7:21.0.3'
}
demo/android/PaddleMobile_Android/app/proguard-rules.pro
0 → 100644
浏览文件 @
f4352e50
# Add project specific ProGuard rules here.
#
You
can
control
the
set
of
applied
configuration
files
using
the
#
proguardFiles
setting
in
build
.
gradle
.
#
#
For
more
details
,
see
#
http
://
developer
.
android
.
com
/
guide
/
developing
/
tools
/
proguard
.
html
#
If
your
project
uses
WebView
with
JS
,
uncomment
the
following
#
and
specify
the
fully
qualified
class
name
to
the
JavaScript
interface
#
class
:
#-
keepclassmembers
class
fqcn
.
of
.
javascript
.
interface
.
for
.
webview
{
#
public
*
;
#
}
#
Uncomment
this
to
preserve
the
line
number
information
for
#
debugging
stack
traces
.
#-
keepattributes
SourceFile
,
LineNumberTable
#
If
you
keep
the
line
number
information
,
uncomment
this
to
#
hide
the
original
source
file
name
.
#-
renamesourcefileattribute
SourceFile
demo/android/PaddleMobile_Android/app/src/main/AndroidManifest.xml
0 → 100644
浏览文件 @
f4352e50
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"com.baidu.paddle"
>
<!-- 往SDCard写入数据权限 -->
<uses-permission
android:name=
"android.permission.WRITE_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.CAMERA"
/>
<application
android:allowBackup=
"true"
android:icon=
"@mipmap/ic_launcher"
android:label=
"@string/app_name"
android:supportsRtl=
"true"
android:theme=
"@style/AppTheme"
>
<activity
android:name=
".MainActivity"
android:label=
"@string/app_name"
>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
</application>
</manifest>
demo/android/PaddleMobile_Android/app/src/main/java/com/baidu/paddle/MainActivity.java
0 → 100755
浏览文件 @
f4352e50
/*
* Copyright (c) 2016 Baidu, Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
* to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of
* the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
* THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
package
com.baidu.paddle
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.graphics.Bitmap
;
import
android.graphics.BitmapFactory
;
import
android.graphics.Canvas
;
import
android.graphics.Color
;
import
android.graphics.Paint
;
import
android.net.Uri
;
import
android.os.AsyncTask
;
import
android.os.Bundle
;
import
android.os.Environment
;
import
android.provider.MediaStore
;
import
android.util.Log
;
import
android.view.View
;
import
android.widget.Button
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
java.io.BufferedWriter
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
static
android
.
graphics
.
Color
.
blue
;
import
static
android
.
graphics
.
Color
.
green
;
import
static
android
.
graphics
.
Color
.
red
;
import
static
com
.
baidu
.
paddle
.
MainActivity
.
TYPE
.
googlenet
;
public
class
MainActivity
extends
Activity
{
public
static
final
int
TAKE_PHOTO_REQUEST_CODE
=
1001
;
private
Context
mContext
=
null
;
private
int
inputSize
=
224
;
enum
TYPE
{
googlenet
}
private
TYPE
type
=
googlenet
;
private
ImageView
imageView
;
private
TextView
tvSpeed
;
private
Button
button
;
private
Bitmap
bmp
;
static
{
try
{
System
.
loadLibrary
(
"paddle-mobile"
);
}
catch
(
SecurityException
e
)
{
e
.
printStackTrace
();
}
catch
(
UnsatisfiedLinkError
e
)
{
e
.
printStackTrace
();
}
catch
(
NullPointerException
e
)
{
e
.
printStackTrace
();
}
}
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
mContext
=
this
;
setContentView
(
R
.
layout
.
main_activity
);
init
();
}
private
void
init
()
{
imageView
=
(
ImageView
)
findViewById
(
R
.
id
.
imageView
);
tvSpeed
=
(
TextView
)
findViewById
(
R
.
id
.
tv_speed
);
button
=
(
Button
)
findViewById
(
R
.
id
.
button
);
button
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
if
(!
isHasSdCard
())
{
Toast
.
makeText
(
mContext
,
R
.
string
.
sdcard_not_available
,
Toast
.
LENGTH_LONG
).
show
();
return
;
}
Intent
intent
=
new
Intent
(
MediaStore
.
ACTION_IMAGE_CAPTURE
);
// save pic in sdcard
Uri
imageUri
=
Uri
.
fromFile
(
getTempImage
());
intent
.
putExtra
(
MediaStore
.
EXTRA_OUTPUT
,
imageUri
);
startActivityForResult
(
intent
,
TAKE_PHOTO_REQUEST_CODE
);
}
});
Button
bt_load
=
(
Button
)
findViewById
(
R
.
id
.
bt_load
);
bt_load
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
String
assetPath
=
"pml_demo"
;
String
sdcardPath
=
Environment
.
getExternalStorageDirectory
()
+
File
.
separator
+
assetPath
+
File
.
separator
+
type
;
PML
.
load
(
sdcardPath
);
}
});
Button
bt_clear
=
(
Button
)
findViewById
(
R
.
id
.
bt_clear
);
bt_clear
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
PML
.
clear
();
}
});
String
assetPath
=
"pml_demo"
;
String
sdcardPath
=
Environment
.
getExternalStorageDirectory
()
+
File
.
separator
+
assetPath
;
copyFilesFromAssets
(
this
,
assetPath
,
sdcardPath
);
}
public
void
copyFilesFromAssets
(
Context
context
,
String
oldPath
,
String
newPath
)
{
try
{
String
[]
fileNames
=
context
.
getAssets
().
list
(
oldPath
);
if
(
fileNames
.
length
>
0
)
{
// directory
File
file
=
new
File
(
newPath
);
file
.
mkdirs
();
// copy recursivelyC
for
(
String
fileName
:
fileNames
)
{
copyFilesFromAssets
(
context
,
oldPath
+
"/"
+
fileName
,
newPath
+
"/"
+
fileName
);
}
}
else
{
// file
InputStream
is
=
context
.
getAssets
().
open
(
oldPath
);
FileOutputStream
fos
=
new
FileOutputStream
(
new
File
(
newPath
));
byte
[]
buffer
=
new
byte
[
1024
];
int
byteCount
;
while
((
byteCount
=
is
.
read
(
buffer
))
!=
-
1
)
{
fos
.
write
(
buffer
,
0
,
byteCount
);
}
fos
.
flush
();
is
.
close
();
fos
.
close
();
}
}
catch
(
Exception
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
}
public
File
getTempImage
()
{
if
(
Environment
.
getExternalStorageState
().
equals
(
Environment
.
MEDIA_MOUNTED
))
{
File
tempFile
=
new
File
(
Environment
.
getExternalStorageDirectory
(),
"temp.jpg"
);
try
{
tempFile
.
createNewFile
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
tempFile
;
}
return
null
;
}
public
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
switch
(
requestCode
)
{
case
TAKE_PHOTO_REQUEST_CODE:
if
(
resultCode
==
RESULT_OK
)
{
DetectionTask
detectionTask
=
new
DetectionTask
();
detectionTask
.
execute
(
getTempImage
().
getPath
());
}
break
;
default
:
break
;
}
}
/**
* draw rect on imageView
*
* @param bitmap
* @param predicted
* @param viewWidth
* @param viewHeight
*/
private
void
drawRect
(
Bitmap
bitmap
,
float
[]
predicted
,
int
viewWidth
,
int
viewHeight
)
{
Canvas
canvas
=
new
Canvas
(
bitmap
);
canvas
.
drawBitmap
(
bitmap
,
0
,
0
,
null
);
if
(
type
==
googlenet
)
{
Paint
paint
=
new
Paint
();
paint
.
setColor
(
Color
.
RED
);
paint
.
setStyle
(
Paint
.
Style
.
STROKE
);
paint
.
setStrokeWidth
(
3.0f
);
float
x1
=
0
;
float
x2
=
0
;
float
y1
=
0
;
float
y2
=
0
;
// the googlenet result sequence is (left top right top bottom)
x1
=
(
predicted
[
0
]
*
viewWidth
/
224
);
y1
=
(
predicted
[
1
]
*
viewHeight
/
224
);
x2
=
(
predicted
[
2
]
*
viewWidth
/
224
);
y2
=
(
predicted
[
3
]
*
viewHeight
/
224
);
canvas
.
drawRect
(
x1
,
y1
,
x2
,
y2
,
paint
);
}
imageView
.
setImageBitmap
(
bitmap
);
}
float
getMaxIndex
(
float
[]
predicted
)
{
float
max
=
0
;
int
index
=
0
;
for
(
int
i
=
0
;
i
<
predicted
.
length
;
i
++)
{
if
(
predicted
[
i
]
>
max
)
{
max
=
predicted
[
i
];
index
=
i
;
}
}
return
index
;
}
public
float
[]
getScaledMatrix
(
Bitmap
bitmap
,
int
desWidth
,
int
desHeight
)
{
float
[]
dataBuf
=
new
float
[
3
*
desWidth
*
desHeight
];
int
rIndex
;
int
gIndex
;
int
bIndex
;
int
[]
pixels
=
new
int
[
desWidth
*
desHeight
];
Bitmap
bm
=
Bitmap
.
createScaledBitmap
(
bitmap
,
desWidth
,
desHeight
,
false
);
bm
.
getPixels
(
pixels
,
0
,
desWidth
,
0
,
0
,
desWidth
,
desHeight
);
int
j
=
0
;
int
k
=
0
;
for
(
int
i
=
0
;
i
<
pixels
.
length
;
i
++)
{
int
clr
=
pixels
[
i
];
j
=
i
/
desHeight
;
k
=
i
%
desWidth
;
rIndex
=
j
*
desWidth
+
k
;
gIndex
=
rIndex
+
desHeight
*
desWidth
;
bIndex
=
gIndex
+
desHeight
*
desWidth
;
dataBuf
[
rIndex
]
=
(
float
)((
clr
&
0x00ff0000
)>>
16
)
-
148
;
dataBuf
[
gIndex
]
=
(
float
)((
clr
&
0x0000ff00
)>>
8
)
-
148
;
dataBuf
[
bIndex
]
=
(
float
)((
clr
&
0x000000ff
))
-
148
;
}
if
(
bm
.
isRecycled
())
{
bm
.
recycle
();
}
return
dataBuf
;
}
/**
* check whether sdcard is mounted
*
* @return
*/
public
boolean
isHasSdCard
()
{
if
(
Environment
.
getExternalStorageState
().
equals
(
Environment
.
MEDIA_MOUNTED
))
{
return
true
;
}
else
{
return
false
;
}
}
public
void
dumpData
(
float
[]
results
,
String
filename
)
{
try
{
File
writename
=
new
File
(
filename
);
writename
.
createNewFile
();
BufferedWriter
out
=
new
BufferedWriter
(
new
FileWriter
(
writename
));
for
(
float
result
:
results
)
{
out
.
write
(
result
+
" "
);
}
out
.
flush
();
out
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
/**
* scale bitmap in case of OOM
*
* @param ctx
* @param filePath
* @return
*/
public
Bitmap
getScaleBitmap
(
Context
ctx
,
String
filePath
)
{
BitmapFactory
.
Options
opt
=
new
BitmapFactory
.
Options
();
opt
.
inJustDecodeBounds
=
true
;
BitmapFactory
.
decodeFile
(
filePath
,
opt
);
int
bmpWidth
=
opt
.
outWidth
;
int
bmpHeight
=
opt
.
outHeight
;
int
maxSize
=
500
;
opt
.
inSampleSize
=
1
;
while
(
true
)
{
if
(
bmpWidth
/
opt
.
inSampleSize
<
maxSize
||
bmpHeight
/
opt
.
inSampleSize
<
maxSize
)
{
break
;
}
opt
.
inSampleSize
*=
2
;
}
opt
.
inJustDecodeBounds
=
false
;
Bitmap
bmp
=
BitmapFactory
.
decodeFile
(
filePath
,
opt
);
return
bmp
;
}
@Override
public
void
onBackPressed
()
{
super
.
onBackPressed
();
Log
.
d
(
"mdl"
,
"mdl clear"
);
// clear mdl
PML
.
clear
();
}
class
DetectionTask
extends
AsyncTask
<
String
,
Void
,
float
[]>
{
private
long
time
;
public
DetectionTask
()
{
super
();
}
@Override
protected
void
onPreExecute
()
{
super
.
onPreExecute
();
if
(
type
==
googlenet
)
{
inputSize
=
224
;
}
}
@Override
protected
void
onPostExecute
(
float
[]
result
)
{
super
.
onPostExecute
(
result
);
try
{
Bitmap
src
=
Bitmap
.
createScaledBitmap
(
bmp
,
imageView
.
getWidth
(),
imageView
.
getHeight
(),
false
);
drawRect
(
src
,
result
,
imageView
.
getWidth
(),
imageView
.
getHeight
());
tvSpeed
.
setText
(
"detection cost:"
+
time
+
"ms"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
@Override
protected
void
onProgressUpdate
(
Void
...
values
)
{
super
.
onProgressUpdate
(
values
);
}
@Override
protected
void
onCancelled
()
{
super
.
onCancelled
();
}
@Override
protected
float
[]
doInBackground
(
String
...
strings
)
{
bmp
=
getScaleBitmap
(
mContext
,
strings
[
0
]);
float
[]
inputData
=
getScaledMatrix
(
bmp
,
inputSize
,
inputSize
);
float
[]
result
=
null
;
try
{
long
start
=
System
.
currentTimeMillis
();
result
=
PML
.
predict
(
inputData
);
long
end
=
System
.
currentTimeMillis
();
time
=
end
-
start
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
result
;
}
}
}
demo/android/PaddleMobile_Android/app/src/main/java/com/baidu/paddle/PML.java
0 → 100644
浏览文件 @
f4352e50
package
com.baidu.paddle
;
public
class
PML
{
/**
* Load
* @param modelPath
* @return
*/
public
static
native
boolean
load
(
String
modelPath
);
/**
* object detection
*
* @param buf
* @return
*/
public
static
native
float
[]
predict
(
float
[]
buf
);
public
static
native
void
clear
();
}
demo/android/PaddleMobile_Android/app/src/main/res/drawable/ic_launcher_background.xml
0 → 100644
浏览文件 @
f4352e50
<?xml version="1.0" encoding="utf-8"?>
<vector
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:width=
"108dp"
android:height=
"108dp"
android:viewportHeight=
"108"
android:viewportWidth=
"108"
>
<path
android:fillColor=
"#26A69A"
android:pathData=
"M0,0h108v108h-108z"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M9,0L9,108"
android:strokeColor=
"#33FFFFFF"
android:strokeWidth=
"0.8"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M19,0L19,108"
android:strokeColor=
"#33FFFFFF"
android:strokeWidth=
"0.8"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M29,0L29,108"
android:strokeColor=
"#33FFFFFF"
android:strokeWidth=
"0.8"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M39,0L39,108"
android:strokeColor=
"#33FFFFFF"
android:strokeWidth=
"0.8"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M49,0L49,108"
android:strokeColor=
"#33FFFFFF"
android:strokeWidth=
"0.8"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M59,0L59,108"
android:strokeColor=
"#33FFFFFF"
android:strokeWidth=
"0.8"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M69,0L69,108"
android:strokeColor=
"#33FFFFFF"
android:strokeWidth=
"0.8"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M79,0L79,108"
android:strokeColor=
"#33FFFFFF"
android:strokeWidth=
"0.8"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M89,0L89,108"
android:strokeColor=
"#33FFFFFF"
android:strokeWidth=
"0.8"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M99,0L99,108"
android:strokeColor=
"#33FFFFFF"
android:strokeWidth=
"0.8"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M0,9L108,9"
android:strokeColor=
"#33FFFFFF"
android:strokeWidth=
"0.8"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M0,19L108,19"
android:strokeColor=
"#33FFFFFF"
android:strokeWidth=
"0.8"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M0,29L108,29"
android:strokeColor=
"#33FFFFFF"
android:strokeWidth=
"0.8"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M0,39L108,39"
android:strokeColor=
"#33FFFFFF"
android:strokeWidth=
"0.8"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M0,49L108,49"
android:strokeColor=
"#33FFFFFF"
android:strokeWidth=
"0.8"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M0,59L108,59"
android:strokeColor=
"#33FFFFFF"
android:strokeWidth=
"0.8"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M0,69L108,69"
android:strokeColor=
"#33FFFFFF"
android:strokeWidth=
"0.8"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M0,79L108,79"
android:strokeColor=
"#33FFFFFF"
android:strokeWidth=
"0.8"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M0,89L108,89"
android:strokeColor=
"#33FFFFFF"
android:strokeWidth=
"0.8"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M0,99L108,99"
android:strokeColor=
"#33FFFFFF"
android:strokeWidth=
"0.8"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M19,29L89,29"
android:strokeColor=
"#33FFFFFF"
android:strokeWidth=
"0.8"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M19,39L89,39"
android:strokeColor=
"#33FFFFFF"
android:strokeWidth=
"0.8"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M19,49L89,49"
android:strokeColor=
"#33FFFFFF"
android:strokeWidth=
"0.8"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M19,59L89,59"
android:strokeColor=
"#33FFFFFF"
android:strokeWidth=
"0.8"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M19,69L89,69"
android:strokeColor=
"#33FFFFFF"
android:strokeWidth=
"0.8"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M19,79L89,79"
android:strokeColor=
"#33FFFFFF"
android:strokeWidth=
"0.8"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M29,19L29,89"
android:strokeColor=
"#33FFFFFF"
android:strokeWidth=
"0.8"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M39,19L39,89"
android:strokeColor=
"#33FFFFFF"
android:strokeWidth=
"0.8"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M49,19L49,89"
android:strokeColor=
"#33FFFFFF"
android:strokeWidth=
"0.8"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M59,19L59,89"
android:strokeColor=
"#33FFFFFF"
android:strokeWidth=
"0.8"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M69,19L69,89"
android:strokeColor=
"#33FFFFFF"
android:strokeWidth=
"0.8"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M79,19L79,89"
android:strokeColor=
"#33FFFFFF"
android:strokeWidth=
"0.8"
/>
</vector>
demo/android/PaddleMobile_Android/app/src/main/res/layout/main_activity.xml
0 → 100644
浏览文件 @
f4352e50
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:orientation=
"vertical"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<LinearLayout
android:id=
"@+id/ll_bottom"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"horizontal"
android:layout_alignParentBottom=
"true"
android:background=
"@android:color/background_light"
>
<TextView
android:id=
"@+id/tv_speed"
android:layout_width=
"match_parent"
android:layout_weight=
"1"
android:layout_height=
"wrap_content"
android:textColor=
"@android:color/background_dark"
android:text=
"@string/time_cost"
/>
<Button
android:id=
"@+id/button"
android:layout_width=
"match_parent"
android:layout_height=
"50dp"
android:text=
"take photo"
android:layout_weight=
"1"
/>
</LinearLayout>
<LinearLayout
android:id=
"@+id/ll_test"
android:layout_above=
"@id/ll_bottom"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"horizontal"
>
<Button
android:id=
"@+id/bt_load"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:text=
"load"
/>
<Button
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:id=
"@+id/bt_clear"
android:layout_weight=
"1"
android:text=
"clear"
/>
</LinearLayout>
<ImageView
android:id=
"@+id/imageView"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:scaleType=
"centerInside"
android:layout_above=
"@id/ll_test"
android:background=
"@android:color/background_light"
/>
</RelativeLayout>
\ No newline at end of file
demo/android/PaddleMobile_Android/app/src/main/res/mipmap-hdpi/ic_launcher.png
0 → 100644
浏览文件 @
f4352e50
3.0 KB
demo/android/PaddleMobile_Android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
0 → 100644
浏览文件 @
f4352e50
4.9 KB
demo/android/PaddleMobile_Android/app/src/main/res/values/colors.xml
0 → 100644
浏览文件 @
f4352e50
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color
name=
"colorPrimary"
>
#3F51B5
</color>
<color
name=
"colorPrimaryDark"
>
#303F9F
</color>
<color
name=
"colorAccent"
>
#FF4081
</color>
</resources>
demo/android/PaddleMobile_Android/app/src/main/res/values/strings.xml
0 → 100644
浏览文件 @
f4352e50
<resources>
<string
name=
"app_name"
>
PaddleMobile_Android
</string>
<string
name=
"sdcard_not_available"
>
sdcard not available
</string>
<string
name=
"time_cost"
>
detection cost:
</string>
</resources>
demo/android/PaddleMobile_Android/app/src/main/res/values/styles.xml
0 → 100644
浏览文件 @
f4352e50
<resources>
<!-- Base application theme. -->
<style
name=
"AppTheme"
parent=
"Theme.AppCompat.Light.DarkActionBar"
>
<!-- Customize your theme here. -->
<item
name=
"colorPrimary"
>
@color/colorPrimary
</item>
<item
name=
"colorPrimaryDark"
>
@color/colorPrimaryDark
</item>
<item
name=
"colorAccent"
>
@color/colorAccent
</item>
</style>
</resources>
demo/android/PaddleMobile_Android/build.gradle
0 → 100644
浏览文件 @
f4352e50
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript
{
repositories
{
google
()
jcenter
()
}
dependencies
{
classpath
'com.android.tools.build:gradle:3.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects
{
repositories
{
google
()
jcenter
()
}
}
task
clean
(
type:
Delete
)
{
delete
rootProject
.
buildDir
}
demo/android/PaddleMobile_Android/gradle.properties
0 → 100644
浏览文件 @
f4352e50
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs
=
-Xmx1536m
android.injected.testOnly
=
false
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
demo/android/PaddleMobile_Android/gradle/wrapper/gradle-wrapper.jar
0 → 100644
浏览文件 @
f4352e50
文件已添加
demo/android/PaddleMobile_Android/gradle/wrapper/gradle-wrapper.properties
0 → 100644
浏览文件 @
f4352e50
#Mon Jul 02 13:58:58 CST 2018
distributionBase
=
GRADLE_USER_HOME
distributionPath
=
wrapper/dists
zipStoreBase
=
GRADLE_USER_HOME
zipStorePath
=
wrapper/dists
distributionUrl
=
https
\:
//services.gradle.org/distributions/gradle-4.4-all.zip
demo/android/PaddleMobile_Android/gradlew
0 → 100755
浏览文件 @
f4352e50
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS
=
""
APP_NAME
=
"Gradle"
APP_BASE_NAME
=
`
basename
"
$0
"
`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD
=
"maximum"
warn
(
)
{
echo
"
$*
"
}
die
(
)
{
echo
echo
"
$*
"
echo
exit
1
}
# OS specific support (must be 'true' or 'false').
cygwin
=
false
msys
=
false
darwin
=
false
case
"
`
uname
`
"
in
CYGWIN
*
)
cygwin
=
true
;;
Darwin
*
)
darwin
=
true
;;
MINGW
*
)
msys
=
true
;;
esac
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG
=
"
$0
"
# Need this for relative symlinks.
while
[
-h
"
$PRG
"
]
;
do
ls
=
`
ls
-ld
"
$PRG
"
`
link
=
`
expr
"
$ls
"
:
'.*-> \(.*\)$'
`
if
expr
"
$link
"
:
'/.*'
>
/dev/null
;
then
PRG
=
"
$link
"
else
PRG
=
`
dirname
"
$PRG
"
`
"/
$link
"
fi
done
SAVED
=
"
`
pwd
`
"
cd
"
`
dirname
\"
$PRG
\"
`
/"
>
/dev/null
APP_HOME
=
"
`
pwd
-P
`
"
cd
"
$SAVED
"
>
/dev/null
CLASSPATH
=
$APP_HOME
/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if
[
-n
"
$JAVA_HOME
"
]
;
then
if
[
-x
"
$JAVA_HOME
/jre/sh/java"
]
;
then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD
=
"
$JAVA_HOME
/jre/sh/java"
else
JAVACMD
=
"
$JAVA_HOME
/bin/java"
fi
if
[
!
-x
"
$JAVACMD
"
]
;
then
die
"ERROR: JAVA_HOME is set to an invalid directory:
$JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD
=
"java"
which java
>
/dev/null 2>&1
||
die
"ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if
[
"
$cygwin
"
=
"false"
-a
"
$darwin
"
=
"false"
]
;
then
MAX_FD_LIMIT
=
`
ulimit
-H
-n
`
if
[
$?
-eq
0
]
;
then
if
[
"
$MAX_FD
"
=
"maximum"
-o
"
$MAX_FD
"
=
"max"
]
;
then
MAX_FD
=
"
$MAX_FD_LIMIT
"
fi
ulimit
-n
$MAX_FD
if
[
$?
-ne
0
]
;
then
warn
"Could not set maximum file descriptor limit:
$MAX_FD
"
fi
else
warn
"Could not query maximum file descriptor limit:
$MAX_FD_LIMIT
"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if
$darwin
;
then
GRADLE_OPTS
=
"
$GRADLE_OPTS
\"
-Xdock:name=
$APP_NAME
\"
\"
-Xdock:icon=
$APP_HOME
/media/gradle.icns
\"
"
fi
# For Cygwin, switch paths to Windows format before running java
if
$cygwin
;
then
APP_HOME
=
`
cygpath
--path
--mixed
"
$APP_HOME
"
`
CLASSPATH
=
`
cygpath
--path
--mixed
"
$CLASSPATH
"
`
JAVACMD
=
`
cygpath
--unix
"
$JAVACMD
"
`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW
=
`
find
-L
/
-maxdepth
1
-mindepth
1
-type
d 2>/dev/null
`
SEP
=
""
for
dir
in
$ROOTDIRSRAW
;
do
ROOTDIRS
=
"
$ROOTDIRS$SEP$dir
"
SEP
=
"|"
done
OURCYGPATTERN
=
"(^(
$ROOTDIRS
))"
# Add a user-defined pattern to the cygpath arguments
if
[
"
$GRADLE_CYGPATTERN
"
!=
""
]
;
then
OURCYGPATTERN
=
"
$OURCYGPATTERN
|(
$GRADLE_CYGPATTERN
)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i
=
0
for
arg
in
"
$@
"
;
do
CHECK
=
`
echo
"
$arg
"
|egrep
-c
"
$OURCYGPATTERN
"
-
`
CHECK2
=
`
echo
"
$arg
"
|egrep
-c
"^-"
`
### Determine if an option
if
[
$CHECK
-ne
0
]
&&
[
$CHECK2
-eq
0
]
;
then
### Added a condition
eval
`
echo
args
$i
`
=
`
cygpath
--path
--ignore
--mixed
"
$arg
"
`
else
eval
`
echo
args
$i
`
=
"
\"
$arg
\"
"
fi
i
=
$((
i+1
))
done
case
$i
in
(
0
)
set
--
;;
(
1
)
set
--
"
$args0
"
;;
(
2
)
set
--
"
$args0
"
"
$args1
"
;;
(
3
)
set
--
"
$args0
"
"
$args1
"
"
$args2
"
;;
(
4
)
set
--
"
$args0
"
"
$args1
"
"
$args2
"
"
$args3
"
;;
(
5
)
set
--
"
$args0
"
"
$args1
"
"
$args2
"
"
$args3
"
"
$args4
"
;;
(
6
)
set
--
"
$args0
"
"
$args1
"
"
$args2
"
"
$args3
"
"
$args4
"
"
$args5
"
;;
(
7
)
set
--
"
$args0
"
"
$args1
"
"
$args2
"
"
$args3
"
"
$args4
"
"
$args5
"
"
$args6
"
;;
(
8
)
set
--
"
$args0
"
"
$args1
"
"
$args2
"
"
$args3
"
"
$args4
"
"
$args5
"
"
$args6
"
"
$args7
"
;;
(
9
)
set
--
"
$args0
"
"
$args1
"
"
$args2
"
"
$args3
"
"
$args4
"
"
$args5
"
"
$args6
"
"
$args7
"
"
$args8
"
;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function
splitJvmOpts
()
{
JVM_OPTS
=(
"
$@
"
)
}
eval
splitJvmOpts
$DEFAULT_JVM_OPTS
$JAVA_OPTS
$GRADLE_OPTS
JVM_OPTS[
${#
JVM_OPTS
[*]
}
]=
"-Dorg.gradle.appname=
$APP_BASE_NAME
"
exec
"
$JAVACMD
"
"
${
JVM_OPTS
[@]
}
"
-classpath
"
$CLASSPATH
"
org.gradle.wrapper.GradleWrapperMain
"
$@
"
demo/android/PaddleMobile_Android/gradlew.bat
0 → 100644
浏览文件 @
f4352e50
@if
"
%DEBUG%
"
==
""
@echo
off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if
"
%OS%
"
==
"Windows_NT"
setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set
DEFAULT_JVM_OPTS
=
set
DIRNAME
=
%~dp0
if
"
%DIRNAME%
"
==
""
set
DIRNAME
=
.
set
APP_BASE_NAME
=
%~n0
set
APP_HOME
=
%DIRNAME%
@rem Find java.exe
if
defined
JAVA_HOME
goto
findJavaFromJavaHome
set
JAVA_EXE
=
java
.exe
%JAVA_EXE%
-version
>
NUL
2
>&
1
if
"
%ERRORLEVEL%
"
==
"0"
goto
init
echo
.
echo
ERROR
:
JAVA_HOME
is
not
set
and
no
'java'
command
could
be
found
in
your
PATH
.
echo
.
echo
Please
set
the
JAVA_HOME
variable
in
your
environment
to
match
the
echo
location
of
your
Java
installation
.
goto
fail
:findJavaFromJavaHome
set
JAVA_HOME
=
%JAVA
_HOME:
"=
%
set JAVA_EXE=
%JAVA_HOME%
/bin/java.exe
if exist "
%JAVA_EXE%
" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory:
%JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "
%OS%
" == "
Windows_NT
" goto win9xME_args
if "
%
@eval
[
2
+
2
]
" == "
4
" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "
x
%
~
1
" == "
x
" goto execute
set CMD_LINE_ARGS=
%
*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=
%
$
:execute
@rem Setup the command line
set CLASSPATH=
%APP_HOME%
\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"
%JAVA_EXE%
"
%DEFAULT_JVM_OPTS%
%JAVA_OPTS%
%GRADLE_OPTS%
"
-Dorg
.gradle.appname
=
%APP_BASE_NAME%
" -classpath "
%CLASSPATH%
" org.gradle.wrapper.GradleWrapperMain
%CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "
%ERRORLEVEL%
"=="
0
" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code
!
if not "" == "
%GRADLE_EXIT_CONSOLE%
" exit 1
exit /b 1
:mainEnd
if "
%OS%
"=="
Windows_NT
" endlocal
:omega
demo/android/PaddleMobile_Android/settings.gradle
0 → 100644
浏览文件 @
f4352e50
include
':app'
doc/development_doc.md
浏览文件 @
f4352e50
...
...
@@ -60,6 +60,7 @@ PaddleMobile.h
# Android开发文档
用户可通过如下两种方式,交叉编译Android平台上适用的paddle-mobile库:
-
基于Docker容器编译
...
...
tools/op.cmake
浏览文件 @
f4352e50
...
...
@@ -19,7 +19,8 @@ elseif (NET STREQUAL "mobilenet")
set
(
BATCHNORM_OP ON
)
set
(
POOL_OP ON
)
set
(
RESHAPE_OP ON
)
set
(
FUSION_CONVADDBNRELU_OP
)
set
(
FUSION_CONVADDBNRELU_OP ON
)
set
(
FUSION_CONVADD_OP ON
)
elseif
(
NET STREQUAL
"yolo"
)
set
(
BATCHNORM_OP ON
)
set
(
CONV_OP ON
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录