-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ee7fb0e
commit 10d20ae
Showing
19 changed files
with
77 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 5 additions & 23 deletions
28
acuantcamera/src/main/java/com/acuant/acuantcamera/detector/AcuantDetectorWorker.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,19 @@ | ||
package com.acuant.acuantcamera.detector | ||
|
||
import android.graphics.* | ||
import android.media.Image | ||
import android.os.AsyncTask | ||
import com.acuant.acuantcamera.detector.document.AcuantDocumentDetector | ||
import java.lang.Exception | ||
import kotlin.concurrent.thread | ||
|
||
class AcuantDetectorWorker(private val detectors: List<IAcuantDetector>, private val image: Image, private val runDocumentDetection: Boolean = true): AsyncTask<Void, Void, Void>(){ | ||
class AcuantDetectorWorker(private val detectors: List<IAcuantDetector>, private val bitmap: Bitmap, private val runDocumentDetection: Boolean = true): AsyncTask<Void, Void, Void>(){ | ||
override fun doInBackground(vararg params: Void?): Void? { | ||
var bitmap:Bitmap? = null | ||
try{ | ||
bitmap = imageToBitmap(image) | ||
} | ||
catch(e:Exception){ | ||
e.printStackTrace() | ||
} | ||
finally { | ||
image.close() | ||
|
||
detectors.forEach{ | ||
if (runDocumentDetection || it !is AcuantDocumentDetector) { | ||
thread { | ||
it.detect(bitmap) | ||
} | ||
detectors.forEach{ | ||
if (runDocumentDetection || it !is AcuantDocumentDetector) { | ||
thread { | ||
it.detect(bitmap) | ||
} | ||
} | ||
} | ||
return null | ||
} | ||
|
||
private fun imageToBitmap(image: Image):Bitmap { | ||
val imageBytes = ImageSaver.imageToByteArray(image) | ||
return BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.size) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters