Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
BYLAppRobot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liuyang
BYLAppRobot
Commits
812c2d5b
Commit
812c2d5b
authored
Jan 08, 2019
by
liuyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
APK图片抓取识别及轮播流地址抓取, 优化识别结果提取
#BYLSERVER-1438
parent
7ea9e582
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
7 deletions
+29
-7
build.gradle
app/build.gradle
+1
-1
OcrManager.kt
app/src/main/java/com/duolebo/blyrobot/tools/OcrManager.kt
+28
-6
No files found.
app/build.gradle
View file @
812c2d5b
...
...
@@ -13,7 +13,7 @@ android {
minSdkVersion
15
targetSdkVersion
22
versionCode
20
versionName
"1.
5.4
"
versionName
"1.
6.1
"
}
signingConfigs
{
...
...
app/src/main/java/com/duolebo/blyrobot/tools/OcrManager.kt
View file @
812c2d5b
...
...
@@ -5,7 +5,7 @@ import android.content.Context
import
android.text.TextUtils
import
android.util.Log
import
com.baidu.aip.ocr.AipOcr
import
java.
io.File
import
java.
util.regex.Pattern
class
OcrManager
{
...
...
@@ -51,7 +51,7 @@ class OcrManager {
res
=
getOcrWords
(
result
)
// 如果无法识别,调用高精度识别,每天500次额度
if
(
!
TextUtils
.
isDigitsOnl
y
(
res
))
{
if
(
TextUtils
.
isEmpt
y
(
res
))
{
result
=
aipOcr
.
basicAccurateGeneral
(
filePath
,
options
)
res
=
getOcrWords
(
result
)
}
...
...
@@ -69,9 +69,31 @@ class OcrManager {
val
wordsResult
=
result
.
getJSONArray
(
"words_result"
)
val
num
=
result
.
getInt
(
"words_result_num"
)
if
(
wordsResult
!=
null
&&
num
>
0
)
{
val
wordsObject
=
wordsResult
.
getJSONObject
(
0
)
words
=
wordsObject
.
getString
(
"words"
)
words
=
words
.
replace
(
"-"
,
""
)
val
len
=
wordsResult
.
length
()
for
(
i
in
0
..
len
)
{
val
wordsObject
=
wordsResult
.
getJSONObject
(
i
)
try
{
val
rawWords
=
wordsObject
.
getString
(
"words"
)
// 提取数字
val
regEx
=
"[^0-9]"
val
p
=
Pattern
.
compile
(
regEx
)
val
m
=
p
.
matcher
(
rawWords
)
val
newWords
=
m
.
replaceAll
(
""
).
trim
()
if
(
newWords
.
length
==
11
)
{
words
=
newWords
break
}
else
if
(
words
.
isEmpty
())
{
words
=
newWords
}
else
if
(
newWords
.
length
>
words
.
length
)
{
words
=
newWords
}
}
catch
(
e
:
java
.
lang
.
Exception
)
{
e
.
printStackTrace
()
}
}
}
return
words
...
...
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