Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wangsen
paddle_dbnet
Commits
c3bb6b52
Commit
c3bb6b52
authored
Feb 05, 2021
by
WenmuZhou
Browse files
Android demo init
parent
a2fb623f
Changes
73
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
779 additions
and
0 deletions
+779
-0
deploy/android_demo/app/src/main/java/com/baidu/paddle/lite/demo/ocr/SettingsActivity.java
...java/com/baidu/paddle/lite/demo/ocr/SettingsActivity.java
+201
-0
deploy/android_demo/app/src/main/java/com/baidu/paddle/lite/demo/ocr/Utils.java
...p/src/main/java/com/baidu/paddle/lite/demo/ocr/Utils.java
+159
-0
deploy/android_demo/app/src/main/res/drawable-v24/ic_launcher_foreground.xml
.../app/src/main/res/drawable-v24/ic_launcher_foreground.xml
+34
-0
deploy/android_demo/app/src/main/res/drawable/ic_launcher_background.xml
...demo/app/src/main/res/drawable/ic_launcher_background.xml
+170
-0
deploy/android_demo/app/src/main/res/layout/activity_main.xml
...oy/android_demo/app/src/main/res/layout/activity_main.xml
+99
-0
deploy/android_demo/app/src/main/res/layout/activity_mini.xml
...oy/android_demo/app/src/main/res/layout/activity_mini.xml
+46
-0
deploy/android_demo/app/src/main/res/menu/menu_action_options.xml
...ndroid_demo/app/src/main/res/menu/menu_action_options.xml
+21
-0
deploy/android_demo/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
...d_demo/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
+5
-0
deploy/android_demo/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
.../app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
+5
-0
deploy/android_demo/app/src/main/res/mipmap-hdpi/ic_launcher.png
...android_demo/app/src/main/res/mipmap-hdpi/ic_launcher.png
+0
-0
deploy/android_demo/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
...d_demo/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
+0
-0
deploy/android_demo/app/src/main/res/mipmap-mdpi/ic_launcher.png
...android_demo/app/src/main/res/mipmap-mdpi/ic_launcher.png
+0
-0
deploy/android_demo/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
...d_demo/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
+0
-0
deploy/android_demo/app/src/main/res/mipmap-xhdpi/ic_launcher.png
...ndroid_demo/app/src/main/res/mipmap-xhdpi/ic_launcher.png
+0
-0
deploy/android_demo/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
..._demo/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
+0
-0
deploy/android_demo/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
...droid_demo/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
+0
-0
deploy/android_demo/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
...demo/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
+0
-0
deploy/android_demo/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
...roid_demo/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
+0
-0
deploy/android_demo/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
...emo/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
+0
-0
deploy/android_demo/app/src/main/res/values/arrays.xml
deploy/android_demo/app/src/main/res/values/arrays.xml
+39
-0
No files found.
deploy/android_demo/app/src/main/java/com/baidu/paddle/lite/demo/ocr/SettingsActivity.java
0 → 100644
View file @
c3bb6b52
package
com.baidu.paddle.lite.demo.ocr
;
import
android.content.SharedPreferences
;
import
android.os.Bundle
;
import
android.preference.CheckBoxPreference
;
import
android.preference.EditTextPreference
;
import
android.preference.ListPreference
;
import
androidx.appcompat.app.ActionBar
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
SettingsActivity
extends
AppCompatPreferenceActivity
implements
SharedPreferences
.
OnSharedPreferenceChangeListener
{
ListPreference
lpChoosePreInstalledModel
=
null
;
CheckBoxPreference
cbEnableCustomSettings
=
null
;
EditTextPreference
etModelPath
=
null
;
EditTextPreference
etLabelPath
=
null
;
EditTextPreference
etImagePath
=
null
;
ListPreference
lpCPUThreadNum
=
null
;
ListPreference
lpCPUPowerMode
=
null
;
ListPreference
lpInputColorFormat
=
null
;
EditTextPreference
etInputShape
=
null
;
EditTextPreference
etInputMean
=
null
;
EditTextPreference
etInputStd
=
null
;
EditTextPreference
etScoreThreshold
=
null
;
List
<
String
>
preInstalledModelPaths
=
null
;
List
<
String
>
preInstalledLabelPaths
=
null
;
List
<
String
>
preInstalledImagePaths
=
null
;
List
<
String
>
preInstalledInputShapes
=
null
;
List
<
String
>
preInstalledCPUThreadNums
=
null
;
List
<
String
>
preInstalledCPUPowerModes
=
null
;
List
<
String
>
preInstalledInputColorFormats
=
null
;
List
<
String
>
preInstalledInputMeans
=
null
;
List
<
String
>
preInstalledInputStds
=
null
;
List
<
String
>
preInstalledScoreThresholds
=
null
;
@Override
public
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
addPreferencesFromResource
(
R
.
xml
.
settings
);
ActionBar
supportActionBar
=
getSupportActionBar
();
if
(
supportActionBar
!=
null
)
{
supportActionBar
.
setDisplayHomeAsUpEnabled
(
true
);
}
// Initialized pre-installed models
preInstalledModelPaths
=
new
ArrayList
<
String
>();
preInstalledLabelPaths
=
new
ArrayList
<
String
>();
preInstalledImagePaths
=
new
ArrayList
<
String
>();
preInstalledInputShapes
=
new
ArrayList
<
String
>();
preInstalledCPUThreadNums
=
new
ArrayList
<
String
>();
preInstalledCPUPowerModes
=
new
ArrayList
<
String
>();
preInstalledInputColorFormats
=
new
ArrayList
<
String
>();
preInstalledInputMeans
=
new
ArrayList
<
String
>();
preInstalledInputStds
=
new
ArrayList
<
String
>();
preInstalledScoreThresholds
=
new
ArrayList
<
String
>();
// Add ssd_mobilenet_v1_pascalvoc_for_cpu
preInstalledModelPaths
.
add
(
getString
(
R
.
string
.
MODEL_PATH_DEFAULT
));
preInstalledLabelPaths
.
add
(
getString
(
R
.
string
.
LABEL_PATH_DEFAULT
));
preInstalledImagePaths
.
add
(
getString
(
R
.
string
.
IMAGE_PATH_DEFAULT
));
preInstalledCPUThreadNums
.
add
(
getString
(
R
.
string
.
CPU_THREAD_NUM_DEFAULT
));
preInstalledCPUPowerModes
.
add
(
getString
(
R
.
string
.
CPU_POWER_MODE_DEFAULT
));
preInstalledInputColorFormats
.
add
(
getString
(
R
.
string
.
INPUT_COLOR_FORMAT_DEFAULT
));
preInstalledInputShapes
.
add
(
getString
(
R
.
string
.
INPUT_SHAPE_DEFAULT
));
preInstalledInputMeans
.
add
(
getString
(
R
.
string
.
INPUT_MEAN_DEFAULT
));
preInstalledInputStds
.
add
(
getString
(
R
.
string
.
INPUT_STD_DEFAULT
));
preInstalledScoreThresholds
.
add
(
getString
(
R
.
string
.
SCORE_THRESHOLD_DEFAULT
));
// Setup UI components
lpChoosePreInstalledModel
=
(
ListPreference
)
findPreference
(
getString
(
R
.
string
.
CHOOSE_PRE_INSTALLED_MODEL_KEY
));
String
[]
preInstalledModelNames
=
new
String
[
preInstalledModelPaths
.
size
()];
for
(
int
i
=
0
;
i
<
preInstalledModelPaths
.
size
();
i
++)
{
preInstalledModelNames
[
i
]
=
preInstalledModelPaths
.
get
(
i
).
substring
(
preInstalledModelPaths
.
get
(
i
).
lastIndexOf
(
"/"
)
+
1
);
}
lpChoosePreInstalledModel
.
setEntries
(
preInstalledModelNames
);
lpChoosePreInstalledModel
.
setEntryValues
(
preInstalledModelPaths
.
toArray
(
new
String
[
preInstalledModelPaths
.
size
()]));
cbEnableCustomSettings
=
(
CheckBoxPreference
)
findPreference
(
getString
(
R
.
string
.
ENABLE_CUSTOM_SETTINGS_KEY
));
etModelPath
=
(
EditTextPreference
)
findPreference
(
getString
(
R
.
string
.
MODEL_PATH_KEY
));
etModelPath
.
setTitle
(
"Model Path (SDCard: "
+
Utils
.
getSDCardDirectory
()
+
")"
);
etLabelPath
=
(
EditTextPreference
)
findPreference
(
getString
(
R
.
string
.
LABEL_PATH_KEY
));
etImagePath
=
(
EditTextPreference
)
findPreference
(
getString
(
R
.
string
.
IMAGE_PATH_KEY
));
lpCPUThreadNum
=
(
ListPreference
)
findPreference
(
getString
(
R
.
string
.
CPU_THREAD_NUM_KEY
));
lpCPUPowerMode
=
(
ListPreference
)
findPreference
(
getString
(
R
.
string
.
CPU_POWER_MODE_KEY
));
lpInputColorFormat
=
(
ListPreference
)
findPreference
(
getString
(
R
.
string
.
INPUT_COLOR_FORMAT_KEY
));
etInputShape
=
(
EditTextPreference
)
findPreference
(
getString
(
R
.
string
.
INPUT_SHAPE_KEY
));
etInputMean
=
(
EditTextPreference
)
findPreference
(
getString
(
R
.
string
.
INPUT_MEAN_KEY
));
etInputStd
=
(
EditTextPreference
)
findPreference
(
getString
(
R
.
string
.
INPUT_STD_KEY
));
etScoreThreshold
=
(
EditTextPreference
)
findPreference
(
getString
(
R
.
string
.
SCORE_THRESHOLD_KEY
));
}
private
void
reloadPreferenceAndUpdateUI
()
{
SharedPreferences
sharedPreferences
=
getPreferenceScreen
().
getSharedPreferences
();
boolean
enableCustomSettings
=
sharedPreferences
.
getBoolean
(
getString
(
R
.
string
.
ENABLE_CUSTOM_SETTINGS_KEY
),
false
);
String
modelPath
=
sharedPreferences
.
getString
(
getString
(
R
.
string
.
CHOOSE_PRE_INSTALLED_MODEL_KEY
),
getString
(
R
.
string
.
MODEL_PATH_DEFAULT
));
int
modelIdx
=
lpChoosePreInstalledModel
.
findIndexOfValue
(
modelPath
);
if
(
modelIdx
>=
0
&&
modelIdx
<
preInstalledModelPaths
.
size
())
{
if
(!
enableCustomSettings
)
{
SharedPreferences
.
Editor
editor
=
sharedPreferences
.
edit
();
editor
.
putString
(
getString
(
R
.
string
.
MODEL_PATH_KEY
),
preInstalledModelPaths
.
get
(
modelIdx
));
editor
.
putString
(
getString
(
R
.
string
.
LABEL_PATH_KEY
),
preInstalledLabelPaths
.
get
(
modelIdx
));
editor
.
putString
(
getString
(
R
.
string
.
IMAGE_PATH_KEY
),
preInstalledImagePaths
.
get
(
modelIdx
));
editor
.
putString
(
getString
(
R
.
string
.
CPU_THREAD_NUM_KEY
),
preInstalledCPUThreadNums
.
get
(
modelIdx
));
editor
.
putString
(
getString
(
R
.
string
.
CPU_POWER_MODE_KEY
),
preInstalledCPUPowerModes
.
get
(
modelIdx
));
editor
.
putString
(
getString
(
R
.
string
.
INPUT_COLOR_FORMAT_KEY
),
preInstalledInputColorFormats
.
get
(
modelIdx
));
editor
.
putString
(
getString
(
R
.
string
.
INPUT_SHAPE_KEY
),
preInstalledInputShapes
.
get
(
modelIdx
));
editor
.
putString
(
getString
(
R
.
string
.
INPUT_MEAN_KEY
),
preInstalledInputMeans
.
get
(
modelIdx
));
editor
.
putString
(
getString
(
R
.
string
.
INPUT_STD_KEY
),
preInstalledInputStds
.
get
(
modelIdx
));
editor
.
putString
(
getString
(
R
.
string
.
SCORE_THRESHOLD_KEY
),
preInstalledScoreThresholds
.
get
(
modelIdx
));
editor
.
commit
();
}
lpChoosePreInstalledModel
.
setSummary
(
modelPath
);
}
cbEnableCustomSettings
.
setChecked
(
enableCustomSettings
);
etModelPath
.
setEnabled
(
enableCustomSettings
);
etLabelPath
.
setEnabled
(
enableCustomSettings
);
etImagePath
.
setEnabled
(
enableCustomSettings
);
lpCPUThreadNum
.
setEnabled
(
enableCustomSettings
);
lpCPUPowerMode
.
setEnabled
(
enableCustomSettings
);
lpInputColorFormat
.
setEnabled
(
enableCustomSettings
);
etInputShape
.
setEnabled
(
enableCustomSettings
);
etInputMean
.
setEnabled
(
enableCustomSettings
);
etInputStd
.
setEnabled
(
enableCustomSettings
);
etScoreThreshold
.
setEnabled
(
enableCustomSettings
);
modelPath
=
sharedPreferences
.
getString
(
getString
(
R
.
string
.
MODEL_PATH_KEY
),
getString
(
R
.
string
.
MODEL_PATH_DEFAULT
));
String
labelPath
=
sharedPreferences
.
getString
(
getString
(
R
.
string
.
LABEL_PATH_KEY
),
getString
(
R
.
string
.
LABEL_PATH_DEFAULT
));
String
imagePath
=
sharedPreferences
.
getString
(
getString
(
R
.
string
.
IMAGE_PATH_KEY
),
getString
(
R
.
string
.
IMAGE_PATH_DEFAULT
));
String
cpuThreadNum
=
sharedPreferences
.
getString
(
getString
(
R
.
string
.
CPU_THREAD_NUM_KEY
),
getString
(
R
.
string
.
CPU_THREAD_NUM_DEFAULT
));
String
cpuPowerMode
=
sharedPreferences
.
getString
(
getString
(
R
.
string
.
CPU_POWER_MODE_KEY
),
getString
(
R
.
string
.
CPU_POWER_MODE_DEFAULT
));
String
inputColorFormat
=
sharedPreferences
.
getString
(
getString
(
R
.
string
.
INPUT_COLOR_FORMAT_KEY
),
getString
(
R
.
string
.
INPUT_COLOR_FORMAT_DEFAULT
));
String
inputShape
=
sharedPreferences
.
getString
(
getString
(
R
.
string
.
INPUT_SHAPE_KEY
),
getString
(
R
.
string
.
INPUT_SHAPE_DEFAULT
));
String
inputMean
=
sharedPreferences
.
getString
(
getString
(
R
.
string
.
INPUT_MEAN_KEY
),
getString
(
R
.
string
.
INPUT_MEAN_DEFAULT
));
String
inputStd
=
sharedPreferences
.
getString
(
getString
(
R
.
string
.
INPUT_STD_KEY
),
getString
(
R
.
string
.
INPUT_STD_DEFAULT
));
String
scoreThreshold
=
sharedPreferences
.
getString
(
getString
(
R
.
string
.
SCORE_THRESHOLD_KEY
),
getString
(
R
.
string
.
SCORE_THRESHOLD_DEFAULT
));
etModelPath
.
setSummary
(
modelPath
);
etModelPath
.
setText
(
modelPath
);
etLabelPath
.
setSummary
(
labelPath
);
etLabelPath
.
setText
(
labelPath
);
etImagePath
.
setSummary
(
imagePath
);
etImagePath
.
setText
(
imagePath
);
lpCPUThreadNum
.
setValue
(
cpuThreadNum
);
lpCPUThreadNum
.
setSummary
(
cpuThreadNum
);
lpCPUPowerMode
.
setValue
(
cpuPowerMode
);
lpCPUPowerMode
.
setSummary
(
cpuPowerMode
);
lpInputColorFormat
.
setValue
(
inputColorFormat
);
lpInputColorFormat
.
setSummary
(
inputColorFormat
);
etInputShape
.
setSummary
(
inputShape
);
etInputShape
.
setText
(
inputShape
);
etInputMean
.
setSummary
(
inputMean
);
etInputMean
.
setText
(
inputMean
);
etInputStd
.
setSummary
(
inputStd
);
etInputStd
.
setText
(
inputStd
);
etScoreThreshold
.
setText
(
scoreThreshold
);
etScoreThreshold
.
setSummary
(
scoreThreshold
);
}
@Override
protected
void
onResume
()
{
super
.
onResume
();
getPreferenceScreen
().
getSharedPreferences
().
registerOnSharedPreferenceChangeListener
(
this
);
reloadPreferenceAndUpdateUI
();
}
@Override
protected
void
onPause
()
{
super
.
onPause
();
getPreferenceScreen
().
getSharedPreferences
().
unregisterOnSharedPreferenceChangeListener
(
this
);
}
@Override
public
void
onSharedPreferenceChanged
(
SharedPreferences
sharedPreferences
,
String
key
)
{
if
(
key
.
equals
(
getString
(
R
.
string
.
CHOOSE_PRE_INSTALLED_MODEL_KEY
)))
{
SharedPreferences
.
Editor
editor
=
sharedPreferences
.
edit
();
editor
.
putBoolean
(
getString
(
R
.
string
.
ENABLE_CUSTOM_SETTINGS_KEY
),
false
);
editor
.
commit
();
}
reloadPreferenceAndUpdateUI
();
}
}
deploy/android_demo/app/src/main/java/com/baidu/paddle/lite/demo/ocr/Utils.java
0 → 100644
View file @
c3bb6b52
package
com.baidu.paddle.lite.demo.ocr
;
import
android.content.Context
;
import
android.graphics.Bitmap
;
import
android.graphics.Matrix
;
import
android.media.ExifInterface
;
import
android.os.Environment
;
import
java.io.*
;
public
class
Utils
{
private
static
final
String
TAG
=
Utils
.
class
.
getSimpleName
();
public
static
void
copyFileFromAssets
(
Context
appCtx
,
String
srcPath
,
String
dstPath
)
{
if
(
srcPath
.
isEmpty
()
||
dstPath
.
isEmpty
())
{
return
;
}
InputStream
is
=
null
;
OutputStream
os
=
null
;
try
{
is
=
new
BufferedInputStream
(
appCtx
.
getAssets
().
open
(
srcPath
));
os
=
new
BufferedOutputStream
(
new
FileOutputStream
(
new
File
(
dstPath
)));
byte
[]
buffer
=
new
byte
[
1024
];
int
length
=
0
;
while
((
length
=
is
.
read
(
buffer
))
!=
-
1
)
{
os
.
write
(
buffer
,
0
,
length
);
}
}
catch
(
FileNotFoundException
e
)
{
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
finally
{
try
{
os
.
close
();
is
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
public
static
void
copyDirectoryFromAssets
(
Context
appCtx
,
String
srcDir
,
String
dstDir
)
{
if
(
srcDir
.
isEmpty
()
||
dstDir
.
isEmpty
())
{
return
;
}
try
{
if
(!
new
File
(
dstDir
).
exists
())
{
new
File
(
dstDir
).
mkdirs
();
}
for
(
String
fileName
:
appCtx
.
getAssets
().
list
(
srcDir
))
{
String
srcSubPath
=
srcDir
+
File
.
separator
+
fileName
;
String
dstSubPath
=
dstDir
+
File
.
separator
+
fileName
;
if
(
new
File
(
srcSubPath
).
isDirectory
())
{
copyDirectoryFromAssets
(
appCtx
,
srcSubPath
,
dstSubPath
);
}
else
{
copyFileFromAssets
(
appCtx
,
srcSubPath
,
dstSubPath
);
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
public
static
float
[]
parseFloatsFromString
(
String
string
,
String
delimiter
)
{
String
[]
pieces
=
string
.
trim
().
toLowerCase
().
split
(
delimiter
);
float
[]
floats
=
new
float
[
pieces
.
length
];
for
(
int
i
=
0
;
i
<
pieces
.
length
;
i
++)
{
floats
[
i
]
=
Float
.
parseFloat
(
pieces
[
i
].
trim
());
}
return
floats
;
}
public
static
long
[]
parseLongsFromString
(
String
string
,
String
delimiter
)
{
String
[]
pieces
=
string
.
trim
().
toLowerCase
().
split
(
delimiter
);
long
[]
longs
=
new
long
[
pieces
.
length
];
for
(
int
i
=
0
;
i
<
pieces
.
length
;
i
++)
{
longs
[
i
]
=
Long
.
parseLong
(
pieces
[
i
].
trim
());
}
return
longs
;
}
public
static
String
getSDCardDirectory
()
{
return
Environment
.
getExternalStorageDirectory
().
getAbsolutePath
();
}
public
static
boolean
isSupportedNPU
()
{
return
false
;
// String hardware = android.os.Build.HARDWARE;
// return hardware.equalsIgnoreCase("kirin810") || hardware.equalsIgnoreCase("kirin990");
}
public
static
Bitmap
resizeWithStep
(
Bitmap
bitmap
,
int
maxLength
,
int
step
)
{
int
width
=
bitmap
.
getWidth
();
int
height
=
bitmap
.
getHeight
();
int
maxWH
=
Math
.
max
(
width
,
height
);
float
ratio
=
1
;
int
newWidth
=
width
;
int
newHeight
=
height
;
if
(
maxWH
>
maxLength
)
{
ratio
=
maxLength
*
1.0f
/
maxWH
;
newWidth
=
(
int
)
Math
.
floor
(
ratio
*
width
);
newHeight
=
(
int
)
Math
.
floor
(
ratio
*
height
);
}
newWidth
=
newWidth
-
newWidth
%
step
;
if
(
newWidth
==
0
)
{
newWidth
=
step
;
}
newHeight
=
newHeight
-
newHeight
%
step
;
if
(
newHeight
==
0
)
{
newHeight
=
step
;
}
return
Bitmap
.
createScaledBitmap
(
bitmap
,
newWidth
,
newHeight
,
true
);
}
public
static
Bitmap
rotateBitmap
(
Bitmap
bitmap
,
int
orientation
)
{
Matrix
matrix
=
new
Matrix
();
switch
(
orientation
)
{
case
ExifInterface
.
ORIENTATION_NORMAL
:
return
bitmap
;
case
ExifInterface
.
ORIENTATION_FLIP_HORIZONTAL
:
matrix
.
setScale
(-
1
,
1
);
break
;
case
ExifInterface
.
ORIENTATION_ROTATE_180
:
matrix
.
setRotate
(
180
);
break
;
case
ExifInterface
.
ORIENTATION_FLIP_VERTICAL
:
matrix
.
setRotate
(
180
);
matrix
.
postScale
(-
1
,
1
);
break
;
case
ExifInterface
.
ORIENTATION_TRANSPOSE
:
matrix
.
setRotate
(
90
);
matrix
.
postScale
(-
1
,
1
);
break
;
case
ExifInterface
.
ORIENTATION_ROTATE_90
:
matrix
.
setRotate
(
90
);
break
;
case
ExifInterface
.
ORIENTATION_TRANSVERSE
:
matrix
.
setRotate
(-
90
);
matrix
.
postScale
(-
1
,
1
);
break
;
case
ExifInterface
.
ORIENTATION_ROTATE_270
:
matrix
.
setRotate
(-
90
);
break
;
default
:
return
bitmap
;
}
try
{
Bitmap
bmRotated
=
Bitmap
.
createBitmap
(
bitmap
,
0
,
0
,
bitmap
.
getWidth
(),
bitmap
.
getHeight
(),
matrix
,
true
);
bitmap
.
recycle
();
return
bmRotated
;
}
catch
(
OutOfMemoryError
e
)
{
e
.
printStackTrace
();
return
null
;
}
}
}
deploy/android_demo/app/src/main/res/drawable-v24/ic_launcher_foreground.xml
0 → 100644
View file @
c3bb6b52
<vector
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:aapt=
"http://schemas.android.com/aapt"
android:width=
"108dp"
android:height=
"108dp"
android:viewportWidth=
"108"
android:viewportHeight=
"108"
>
<path
android:fillType=
"evenOdd"
android:pathData=
"M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeWidth=
"1"
android:strokeColor=
"#00000000"
>
<aapt:attr
name=
"android:fillColor"
>
<gradient
android:endX=
"78.5885"
android:endY=
"90.9159"
android:startX=
"48.7653"
android:startY=
"61.0927"
android:type=
"linear"
>
<item
android:color=
"#44000000"
android:offset=
"0.0"
/>
<item
android:color=
"#00000000"
android:offset=
"1.0"
/>
</gradient>
</aapt:attr>
</path>
<path
android:fillColor=
"#FFFFFF"
android:fillType=
"nonZero"
android:pathData=
"M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeWidth=
"1"
android:strokeColor=
"#00000000"
/>
</vector>
deploy/android_demo/app/src/main/res/drawable/ic_launcher_background.xml
0 → 100644
View file @
c3bb6b52
<?xml version="1.0" encoding="utf-8"?>
<vector
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:width=
"108dp"
android:height=
"108dp"
android:viewportWidth=
"108"
android:viewportHeight=
"108"
>
<path
android:fillColor=
"#008577"
android:pathData=
"M0,0h108v108h-108z"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M9,0L9,108"
android:strokeWidth=
"0.8"
android:strokeColor=
"#33FFFFFF"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M19,0L19,108"
android:strokeWidth=
"0.8"
android:strokeColor=
"#33FFFFFF"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M29,0L29,108"
android:strokeWidth=
"0.8"
android:strokeColor=
"#33FFFFFF"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M39,0L39,108"
android:strokeWidth=
"0.8"
android:strokeColor=
"#33FFFFFF"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M49,0L49,108"
android:strokeWidth=
"0.8"
android:strokeColor=
"#33FFFFFF"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M59,0L59,108"
android:strokeWidth=
"0.8"
android:strokeColor=
"#33FFFFFF"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M69,0L69,108"
android:strokeWidth=
"0.8"
android:strokeColor=
"#33FFFFFF"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M79,0L79,108"
android:strokeWidth=
"0.8"
android:strokeColor=
"#33FFFFFF"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M89,0L89,108"
android:strokeWidth=
"0.8"
android:strokeColor=
"#33FFFFFF"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M99,0L99,108"
android:strokeWidth=
"0.8"
android:strokeColor=
"#33FFFFFF"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M0,9L108,9"
android:strokeWidth=
"0.8"
android:strokeColor=
"#33FFFFFF"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M0,19L108,19"
android:strokeWidth=
"0.8"
android:strokeColor=
"#33FFFFFF"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M0,29L108,29"
android:strokeWidth=
"0.8"
android:strokeColor=
"#33FFFFFF"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M0,39L108,39"
android:strokeWidth=
"0.8"
android:strokeColor=
"#33FFFFFF"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M0,49L108,49"
android:strokeWidth=
"0.8"
android:strokeColor=
"#33FFFFFF"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M0,59L108,59"
android:strokeWidth=
"0.8"
android:strokeColor=
"#33FFFFFF"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M0,69L108,69"
android:strokeWidth=
"0.8"
android:strokeColor=
"#33FFFFFF"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M0,79L108,79"
android:strokeWidth=
"0.8"
android:strokeColor=
"#33FFFFFF"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M0,89L108,89"
android:strokeWidth=
"0.8"
android:strokeColor=
"#33FFFFFF"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M0,99L108,99"
android:strokeWidth=
"0.8"
android:strokeColor=
"#33FFFFFF"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M19,29L89,29"
android:strokeWidth=
"0.8"
android:strokeColor=
"#33FFFFFF"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M19,39L89,39"
android:strokeWidth=
"0.8"
android:strokeColor=
"#33FFFFFF"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M19,49L89,49"
android:strokeWidth=
"0.8"
android:strokeColor=
"#33FFFFFF"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M19,59L89,59"
android:strokeWidth=
"0.8"
android:strokeColor=
"#33FFFFFF"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M19,69L89,69"
android:strokeWidth=
"0.8"
android:strokeColor=
"#33FFFFFF"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M19,79L89,79"
android:strokeWidth=
"0.8"
android:strokeColor=
"#33FFFFFF"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M29,19L29,89"
android:strokeWidth=
"0.8"
android:strokeColor=
"#33FFFFFF"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M39,19L39,89"
android:strokeWidth=
"0.8"
android:strokeColor=
"#33FFFFFF"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M49,19L49,89"
android:strokeWidth=
"0.8"
android:strokeColor=
"#33FFFFFF"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M59,19L59,89"
android:strokeWidth=
"0.8"
android:strokeColor=
"#33FFFFFF"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M69,19L69,89"
android:strokeWidth=
"0.8"
android:strokeColor=
"#33FFFFFF"
/>
<path
android:fillColor=
"#00000000"
android:pathData=
"M79,19L79,89"
android:strokeWidth=
"0.8"
android:strokeColor=
"#33FFFFFF"
/>
</vector>
deploy/android_demo/app/src/main/res/layout/activity_main.xml
0 → 100644
View file @
c3bb6b52
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
tools:context=
".MainActivity"
>
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<LinearLayout
android:id=
"@+id/v_input_info"
android:layout_width=
"fill_parent"
android:layout_height=
"wrap_content"
android:layout_alignParentTop=
"true"
android:orientation=
"vertical"
>
<TextView
android:id=
"@+id/tv_input_setting"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:scrollbars=
"vertical"
android:layout_marginLeft=
"12dp"
android:layout_marginRight=
"12dp"
android:layout_marginTop=
"10dp"
android:layout_marginBottom=
"5dp"
android:lineSpacingExtra=
"4dp"
android:singleLine=
"false"
android:maxLines=
"6"
android:text=
""
/>
</LinearLayout>
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_above=
"@+id/v_output_info"
android:layout_below=
"@+id/v_input_info"
>
<ImageView
android:id=
"@+id/iv_input_image"
android:layout_width=
"400dp"
android:layout_height=
"400dp"
android:layout_centerHorizontal=
"true"
android:layout_centerVertical=
"true"
android:layout_marginLeft=
"12dp"
android:layout_marginRight=
"12dp"
android:layout_marginTop=
"5dp"
android:layout_marginBottom=
"5dp"
android:adjustViewBounds=
"true"
android:scaleType=
"fitCenter"
/>
</RelativeLayout>
<RelativeLayout
android:id=
"@+id/v_output_info"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentBottom=
"true"
android:layout_centerHorizontal=
"true"
>
<TextView
android:id=
"@+id/tv_output_result"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentTop=
"true"
android:layout_centerHorizontal=
"true"
android:layout_centerVertical=
"true"
android:scrollbars=
"vertical"
android:layout_marginLeft=
"12dp"
android:layout_marginRight=
"12dp"
android:layout_marginTop=
"5dp"
android:layout_marginBottom=
"5dp"
android:textAlignment=
"center"
android:lineSpacingExtra=
"5dp"
android:singleLine=
"false"
android:maxLines=
"5"
android:text=
""
/>
<TextView
android:id=
"@+id/tv_inference_time"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_below=
"@+id/tv_output_result"
android:layout_centerHorizontal=
"true"
android:layout_centerVertical=
"true"
android:textAlignment=
"center"
android:layout_marginLeft=
"12dp"
android:layout_marginRight=
"12dp"
android:layout_marginTop=
"5dp"
android:layout_marginBottom=
"10dp"
android:text=
""
/>
</RelativeLayout>
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
deploy/android_demo/app/src/main/res/layout/activity_mini.xml
0 → 100644
View file @
c3bb6b52
<?xml version="1.0" encoding="utf-8"?>
<!-- for MiniActivity Use Only -->
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintLeft_toRightOf=
"parent"
tools:context=
".MainActivity"
>
<TextView
android:id=
"@+id/sample_text"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:text=
"Hello World!"
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintRight_toRightOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/imageView"
android:scrollbars=
"vertical"
/>
<ImageView
android:id=
"@+id/imageView"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:paddingTop=
"20dp"
android:paddingBottom=
"20dp"
app:layout_constraintBottom_toTopOf=
"@id/imageView"
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintRight_toRightOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
tools:srcCompat=
"@tools:sample/avatars"
/>
<Button
android:id=
"@+id/button"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"4dp"
android:text=
"Button"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintRight_toRightOf=
"parent"
tools:layout_editor_absoluteX=
"161dp"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
deploy/android_demo/app/src/main/res/menu/menu_action_options.xml
0 → 100644
View file @
c3bb6b52
<menu
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
>
<group
android:id=
"@+id/pick_image"
>
<item
android:id=
"@+id/open_gallery"
android:title=
"Open Gallery"
app:showAsAction=
"withText"
/>
<item
android:id=
"@+id/take_photo"
android:title=
"Take Photo"
app:showAsAction=
"withText"
/>
</group>
<group>
<item
android:id=
"@+id/settings"
android:title=
"Settings..."
app:showAsAction=
"withText"
/>
</group>
</menu>
deploy/android_demo/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
0 → 100644
View file @
c3bb6b52
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<background
android:drawable=
"@drawable/ic_launcher_background"
/>
<foreground
android:drawable=
"@drawable/ic_launcher_foreground"
/>
</adaptive-icon>
\ No newline at end of file
deploy/android_demo/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
0 → 100644
View file @
c3bb6b52
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<background
android:drawable=
"@drawable/ic_launcher_background"
/>
<foreground
android:drawable=
"@drawable/ic_launcher_foreground"
/>
</adaptive-icon>
\ No newline at end of file
deploy/android_demo/app/src/main/res/mipmap-hdpi/ic_launcher.png
0 → 100644
View file @
c3bb6b52
2.89 KB
deploy/android_demo/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
0 → 100644
View file @
c3bb6b52
4.79 KB
deploy/android_demo/app/src/main/res/mipmap-mdpi/ic_launcher.png
0 → 100644
View file @
c3bb6b52
2.01 KB
deploy/android_demo/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
0 → 100644
View file @
c3bb6b52
2.72 KB
deploy/android_demo/app/src/main/res/mipmap-xhdpi/ic_launcher.png
0 → 100644
View file @
c3bb6b52
4.38 KB
deploy/android_demo/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
0 → 100644
View file @
c3bb6b52
6.73 KB
deploy/android_demo/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
0 → 100644
View file @
c3bb6b52
6.24 KB
deploy/android_demo/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
0 → 100644
View file @
c3bb6b52
10.2 KB
deploy/android_demo/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
0 → 100644
View file @
c3bb6b52
8.91 KB
deploy/android_demo/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
0 → 100644
View file @
c3bb6b52
14.8 KB
deploy/android_demo/app/src/main/res/values/arrays.xml
0 → 100644
View file @
c3bb6b52
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array
name=
"cpu_thread_num_entries"
>
<item>
1 threads
</item>
<item>
2 threads
</item>
<item>
4 threads
</item>
<item>
8 threads
</item>
</string-array>
<string-array
name=
"cpu_thread_num_values"
>
<item>
1
</item>
<item>
2
</item>
<item>
4
</item>
<item>
8
</item>
</string-array>
<string-array
name=
"cpu_power_mode_entries"
>
<item>
HIGH(only big cores)
</item>
<item>
LOW(only LITTLE cores)
</item>
<item>
FULL(all cores)
</item>
<item>
NO_BIND(depends on system)
</item>
<item>
RAND_HIGH
</item>
<item>
RAND_LOW
</item>
</string-array>
<string-array
name=
"cpu_power_mode_values"
>
<item>
LITE_POWER_HIGH
</item>
<item>
LITE_POWER_LOW
</item>
<item>
LITE_POWER_FULL
</item>
<item>
LITE_POWER_NO_BIND
</item>
<item>
LITE_POWER_RAND_HIGH
</item>
<item>
LITE_POWER_RAND_LOW
</item>
</string-array>
<string-array
name=
"input_color_format_entries"
>
<item>
BGR color format
</item>
<item>
RGB color format
</item>
</string-array>
<string-array
name=
"input_color_format_values"
>
<item>
BGR
</item>
<item>
RGB
</item>
</string-array>
</resources>
\ No newline at end of file
Prev
1
2
3
4
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment