-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #555 from code-payments/chore/improve-code-parsing…
…-success chore(scan): scan full static image at various scan qualities to improve parse success rate
- Loading branch information
Showing
5 changed files
with
93 additions
and
50 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,34 @@ | ||
package com.kik.kikx.kikcodes | ||
|
||
import com.kik.kikx.models.ScannableKikCode | ||
import com.kik.scan.KikCode | ||
import com.kik.scan.Scanner.ScanResult | ||
|
||
sealed class ScanQuality(val headerValue: Int) { | ||
data object Low : ScanQuality(0) | ||
data object Medium : ScanQuality(3) | ||
data object High : ScanQuality(8) | ||
data object Best : ScanQuality(10) | ||
|
||
companion object { | ||
private val values = listOf(Low, Medium, High, Best) | ||
|
||
fun iterator(): Iterator<ScanQuality> { | ||
return values.iterator() | ||
} | ||
} | ||
} | ||
|
||
open class ScannerError(override val message: String) : Exception(message) | ||
|
||
interface KikCodeScanner { | ||
class NoKikCodeFoundException : Exception("No Kik Code found in image buffer") | ||
class NoKikCodeFoundException : ScannerError("No Kik Code found in image buffer") | ||
class FailedToParseCodeException(val scanResult: ScanResult) : | ||
ScannerError("Code found in image buffer, but failed to parse") | ||
|
||
class UnsupportedKikCodeFoundException(val kikCode: KikCode) : ScannerError("Code found in unsupported") | ||
|
||
suspend fun scanKikCode(imageData: ByteArray, width: Int, height: Int): Result<ScannableKikCode> | ||
suspend fun scanKikCode( | ||
imageData: ByteArray, width: Int, height: Int, quality: ScanQuality = ScanQuality.Medium | ||
): Result<ScannableKikCode> | ||
} |
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