Commit d4ac7aba authored by liuyang's avatar liuyang

APK图片抓取识别及轮播流地址抓取, 优化识别结果提取

#BYLSERVER-1438
parent 43097d09
...@@ -12,8 +12,8 @@ android { ...@@ -12,8 +12,8 @@ android {
applicationId "com.duolebo.bylrobot" applicationId "com.duolebo.bylrobot"
minSdkVersion 15 minSdkVersion 15
targetSdkVersion 22 targetSdkVersion 22
versionCode 20 versionCode 23
versionName "1.6.2" versionName "1.6.3"
} }
signingConfigs { signingConfigs {
......
...@@ -441,7 +441,7 @@ class Task : Thread, IAppBaseCallback { ...@@ -441,7 +441,7 @@ class Task : Thread, IAppBaseCallback {
private fun imageOcrToNumber() { private fun imageOcrToNumber() {
val channelArr = this.reportJson.optJSONArray("channels") val channelArr = this.reportJson.optJSONArray("channels")
for ( i in 0..channelArr.length()) { for ( i in 0 until channelArr.length()) {
try { try {
val channelJson = channelArr.optJSONObject(i) val channelJson = channelArr.optJSONObject(i)
var imagePath = this.taskPath + "/" + channelJson.optString("channelImage") var imagePath = this.taskPath + "/" + channelJson.optString("channelImage")
......
...@@ -70,7 +70,7 @@ class OcrManager { ...@@ -70,7 +70,7 @@ class OcrManager {
val num = result.getInt("words_result_num") val num = result.getInt("words_result_num")
if (wordsResult != null && num > 0) { if (wordsResult != null && num > 0) {
val len = wordsResult.length() val len = wordsResult.length()
for ( i in 0..len) { for ( i in 0 until len) {
val wordsObject = wordsResult.getJSONObject(i) val wordsObject = wordsResult.getJSONObject(i)
try { try {
val rawWords = wordsObject.getString("words") val rawWords = wordsObject.getString("words")
...@@ -79,7 +79,7 @@ class OcrManager { ...@@ -79,7 +79,7 @@ class OcrManager {
val p = Pattern.compile(regEx) val p = Pattern.compile(regEx)
val m = p.matcher(rawWords) val m = p.matcher(rawWords)
val newWords = m.replaceAll("").trim() val newWords = m.replaceAll("").trim()
if (newWords.length == 11) { if (newWords.length == 10) {
words = newWords words = newWords
break break
} }
......
...@@ -100,7 +100,7 @@ object AppUtil { ...@@ -100,7 +100,7 @@ object AppUtil {
val bitmap = BitmapFactory.decodeFile(imagePath) val bitmap = BitmapFactory.decodeFile(imagePath)
try { try {
val height = bitmap.height val height = bitmap.height
val cropBitmap = Bitmap.createBitmap(bitmap, 0, height - 100, 1024, 100) val cropBitmap = Bitmap.createBitmap(bitmap, 0, height - 100, bitmap.width, 100)
val index = imagePath.lastIndexOf('.') val index = imagePath.lastIndexOf('.')
val partName = imagePath.substring(0, index) val partName = imagePath.substring(0, index)
val newPath = partName + "_ocr.jpg" val newPath = partName + "_ocr.jpg"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment