Skip to content

Commit

Permalink
improved accuracy and speed
Browse files Browse the repository at this point in the history
  • Loading branch information
ismai117 committed Dec 8, 2024
1 parent ff14271 commit 3d08c75
Show file tree
Hide file tree
Showing 13 changed files with 442 additions and 274 deletions.
2 changes: 1 addition & 1 deletion lib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ mavenPublishing {
// or when publishing to https://s01.oss.sonatype.org
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL, automaticRelease = true)
signAllPublications()
coordinates("io.github.ismai117", "KScan", "0.1.0-alpha03")
coordinates("io.github.ismai117", "KScan", "0.1.0-alpha04")

pom {
name.set(project.name)
Expand Down
285 changes: 152 additions & 133 deletions lib/src/androidMain/kotlin/org/ncgroup/kscan/BarcodeAnalyzer.kt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,17 @@ actual object BarcodeFormats {
actual val FORMAT_AZTEC: BarcodeFormat = BarcodeFormat.FORMAT_AZTEC
actual val FORMAT_DATA_MATRIX: BarcodeFormat = BarcodeFormat.FORMAT_DATA_MATRIX
actual val FORMAT_ALL_FORMATS: BarcodeFormat = BarcodeFormat.FORMAT_ALL_FORMATS
actual val TYPE_UNKNOWN: BarcodeFormat = BarcodeFormat.TYPE_UNKNOWN
actual val TYPE_CONTACT_INFO: BarcodeFormat = BarcodeFormat.TYPE_CONTACT_INFO
actual val TYPE_EMAIL: BarcodeFormat = BarcodeFormat.TYPE_EMAIL
actual val TYPE_ISBN: BarcodeFormat = BarcodeFormat.TYPE_ISBN
actual val TYPE_PHONE: BarcodeFormat = BarcodeFormat.TYPE_PHONE
actual val TYPE_PRODUCT: BarcodeFormat = BarcodeFormat.TYPE_PRODUCT
actual val TYPE_SMS: BarcodeFormat = BarcodeFormat.TYPE_SMS
actual val TYPE_TEXT: BarcodeFormat = BarcodeFormat.TYPE_TEXT
actual val TYPE_URL: BarcodeFormat = BarcodeFormat.TYPE_URL
actual val TYPE_WIFI: BarcodeFormat = BarcodeFormat.TYPE_WIFI
actual val TYPE_GEO: BarcodeFormat = BarcodeFormat.TYPE_GEO
actual val TYPE_CALENDAR_EVENT: BarcodeFormat = BarcodeFormat.TYPE_CALENDAR_EVENT
actual val TYPE_DRIVER_LICENSE: BarcodeFormat = BarcodeFormat.TYPE_DRIVER_LICENSE
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import androidx.lifecycle.compose.LocalLifecycleOwner
actual fun ScannerView(
codeTypes: List<BarcodeFormat>,
colors: ScannerColors,
onFrameOutside: () -> Unit,
result: (BarcodeResult) -> Unit,
) {
val context = LocalContext.current
Expand Down Expand Up @@ -72,7 +73,7 @@ actual fun ScannerView(
}
}

val frame = LocalDensity.current.run { 260.dp.toPx() }
val frame = LocalDensity.current.run { 280.dp.toPx() }

Box(
modifier = Modifier.fillMaxSize(),
Expand All @@ -92,7 +93,7 @@ actual fun ScannerView(

val imageAnalysis =
ImageAnalysis.Builder()
.setTargetResolution(Size(1200, 720))
.setTargetResolution(Size(1280, 720))
.setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
.build()

Expand All @@ -114,6 +115,7 @@ actual fun ScannerView(
},
onFailed = { result(BarcodeResult.OnFailed(Exception(it))) },
onCanceled = { result(BarcodeResult.OnCanceled) },
onFrameOutside = onFrameOutside,
).also { barcodeAnalyzer = it },
)

Expand Down
26 changes: 26 additions & 0 deletions lib/src/commonMain/kotlin/org/ncgroup/kscan/BarcodeFormats.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@ enum class BarcodeFormat {
FORMAT_AZTEC,
FORMAT_DATA_MATRIX,
FORMAT_ALL_FORMATS,
TYPE_UNKNOWN,
TYPE_CONTACT_INFO,
TYPE_EMAIL,
TYPE_ISBN,
TYPE_PHONE,
TYPE_PRODUCT,
TYPE_SMS,
TYPE_TEXT,
TYPE_URL,
TYPE_WIFI,
TYPE_GEO,
TYPE_CALENDAR_EVENT,
TYPE_DRIVER_LICENSE,
}

expect object BarcodeFormats {
Expand All @@ -32,4 +45,17 @@ expect object BarcodeFormats {
val FORMAT_AZTEC: BarcodeFormat
val FORMAT_DATA_MATRIX: BarcodeFormat
val FORMAT_ALL_FORMATS: BarcodeFormat
val TYPE_UNKNOWN: BarcodeFormat
val TYPE_CONTACT_INFO: BarcodeFormat
val TYPE_EMAIL: BarcodeFormat
val TYPE_ISBN: BarcodeFormat
val TYPE_PHONE: BarcodeFormat
val TYPE_PRODUCT: BarcodeFormat
val TYPE_SMS: BarcodeFormat
val TYPE_TEXT: BarcodeFormat
val TYPE_URL: BarcodeFormat
val TYPE_WIFI: BarcodeFormat
val TYPE_GEO: BarcodeFormat
val TYPE_CALENDAR_EVENT: BarcodeFormat
val TYPE_DRIVER_LICENSE: BarcodeFormat
}
1 change: 1 addition & 0 deletions lib/src/commonMain/kotlin/org/ncgroup/kscan/ScannerView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ import androidx.compose.runtime.Composable
expect fun ScannerView(
codeTypes: List<BarcodeFormat>,
colors: ScannerColors = scannerColors(),
onFrameOutside: () -> Unit = {},
result: (BarcodeResult) -> Unit,
)
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
package org.ncgroup.kscan

actual object BarcodeFormats {
actual val FORMAT_CODE_128: BarcodeFormat
get() = TODO("Not yet implemented")
actual val FORMAT_CODE_39: BarcodeFormat
get() = TODO("Not yet implemented")
actual val FORMAT_CODE_93: BarcodeFormat
get() = TODO("Not yet implemented")
actual val FORMAT_CODABAR: BarcodeFormat
get() = TODO("Not yet implemented")
actual val FORMAT_EAN_13: BarcodeFormat
get() = TODO("Not yet implemented")
actual val FORMAT_EAN_8: BarcodeFormat
get() = TODO("Not yet implemented")
actual val FORMAT_ITF: BarcodeFormat
get() = TODO("Not yet implemented")
actual val FORMAT_UPC_A: BarcodeFormat
get() = TODO("Not yet implemented")
actual val FORMAT_UPC_E: BarcodeFormat
get() = TODO("Not yet implemented")
actual val FORMAT_QR_CODE: BarcodeFormat
get() = TODO("Not yet implemented")
actual val FORMAT_PDF417: BarcodeFormat
get() = TODO("Not yet implemented")
actual val FORMAT_AZTEC: BarcodeFormat
get() = TODO("Not yet implemented")
actual val FORMAT_DATA_MATRIX: BarcodeFormat
get() = TODO("Not yet implemented")
actual val FORMAT_ALL_FORMATS: BarcodeFormat
get() = TODO("Not yet implemented")
actual val FORMAT_CODE_128: BarcodeFormat = BarcodeFormat.FORMAT_CODE_128
actual val FORMAT_CODE_39: BarcodeFormat = BarcodeFormat.FORMAT_CODE_39
actual val FORMAT_CODE_93: BarcodeFormat = BarcodeFormat.FORMAT_CODE_93
actual val FORMAT_CODABAR: BarcodeFormat = BarcodeFormat.FORMAT_CODABAR
actual val FORMAT_EAN_13: BarcodeFormat = BarcodeFormat.FORMAT_EAN_13
actual val FORMAT_EAN_8: BarcodeFormat = BarcodeFormat.FORMAT_EAN_8
actual val FORMAT_ITF: BarcodeFormat = BarcodeFormat.FORMAT_ITF
actual val FORMAT_UPC_A: BarcodeFormat = BarcodeFormat.FORMAT_UPC_A
actual val FORMAT_UPC_E: BarcodeFormat = BarcodeFormat.FORMAT_UPC_E
actual val FORMAT_QR_CODE: BarcodeFormat = BarcodeFormat.FORMAT_QR_CODE
actual val FORMAT_PDF417: BarcodeFormat = BarcodeFormat.FORMAT_PDF417
actual val FORMAT_AZTEC: BarcodeFormat = BarcodeFormat.FORMAT_AZTEC
actual val FORMAT_DATA_MATRIX: BarcodeFormat = BarcodeFormat.FORMAT_DATA_MATRIX
actual val FORMAT_ALL_FORMATS: BarcodeFormat = BarcodeFormat.FORMAT_ALL_FORMATS
actual val TYPE_UNKNOWN: BarcodeFormat = BarcodeFormat.TYPE_UNKNOWN
actual val TYPE_CONTACT_INFO: BarcodeFormat = BarcodeFormat.TYPE_CONTACT_INFO
actual val TYPE_EMAIL: BarcodeFormat = BarcodeFormat.TYPE_EMAIL
actual val TYPE_ISBN: BarcodeFormat = BarcodeFormat.TYPE_ISBN
actual val TYPE_PHONE: BarcodeFormat = BarcodeFormat.TYPE_PHONE
actual val TYPE_PRODUCT: BarcodeFormat = BarcodeFormat.TYPE_PRODUCT
actual val TYPE_SMS: BarcodeFormat = BarcodeFormat.TYPE_SMS
actual val TYPE_TEXT: BarcodeFormat = BarcodeFormat.TYPE_TEXT
actual val TYPE_URL: BarcodeFormat = BarcodeFormat.TYPE_URL
actual val TYPE_WIFI: BarcodeFormat = BarcodeFormat.TYPE_WIFI
actual val TYPE_GEO: BarcodeFormat = BarcodeFormat.TYPE_GEO
actual val TYPE_CALENDAR_EVENT: BarcodeFormat = BarcodeFormat.TYPE_CALENDAR_EVENT
actual val TYPE_DRIVER_LICENSE: BarcodeFormat = BarcodeFormat.TYPE_DRIVER_LICENSE
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ import androidx.compose.runtime.Composable
actual fun ScannerView(
codeTypes: List<BarcodeFormat>,
colors: ScannerColors,
onFrameOutside: () -> Unit,
result: (BarcodeResult) -> Unit,
) {}
13 changes: 13 additions & 0 deletions lib/src/iosMain/kotlin/org/ncgroup/kscan/BarcodeFormats.ios.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,17 @@ actual object BarcodeFormats {
actual val FORMAT_AZTEC: BarcodeFormat = BarcodeFormat.FORMAT_AZTEC
actual val FORMAT_DATA_MATRIX: BarcodeFormat = BarcodeFormat.FORMAT_DATA_MATRIX
actual val FORMAT_ALL_FORMATS: BarcodeFormat = BarcodeFormat.FORMAT_ALL_FORMATS
actual val TYPE_UNKNOWN: BarcodeFormat = BarcodeFormat.TYPE_UNKNOWN
actual val TYPE_CONTACT_INFO: BarcodeFormat = BarcodeFormat.TYPE_CONTACT_INFO
actual val TYPE_EMAIL: BarcodeFormat = BarcodeFormat.TYPE_EMAIL
actual val TYPE_ISBN: BarcodeFormat = BarcodeFormat.TYPE_ISBN
actual val TYPE_PHONE: BarcodeFormat = BarcodeFormat.TYPE_PHONE
actual val TYPE_PRODUCT: BarcodeFormat = BarcodeFormat.TYPE_PRODUCT
actual val TYPE_SMS: BarcodeFormat = BarcodeFormat.TYPE_SMS
actual val TYPE_TEXT: BarcodeFormat = BarcodeFormat.TYPE_TEXT
actual val TYPE_URL: BarcodeFormat = BarcodeFormat.TYPE_URL
actual val TYPE_WIFI: BarcodeFormat = BarcodeFormat.TYPE_WIFI
actual val TYPE_GEO: BarcodeFormat = BarcodeFormat.TYPE_GEO
actual val TYPE_CALENDAR_EVENT: BarcodeFormat = BarcodeFormat.TYPE_CALENDAR_EVENT
actual val TYPE_DRIVER_LICENSE: BarcodeFormat = BarcodeFormat.TYPE_DRIVER_LICENSE
}
Loading

0 comments on commit 3d08c75

Please # to comment.