References
This page contains references for possible error codes, object structure, etc. Most of this can be obtained from the javadoc/clicking into code via Android Studio, but it is also provided here as a reference.
Document Camera Result
Whether the Document Camera was launched via activity or via composition, its success case result is returned as a DocumentProcessingState.Result
.
sealed interface Result : DocumentProcessingState
/**
* Exception received during processing or configuration change
*
* @param message error description if available
* @param component component which caused error to happen
* @param cause exception which caused error to happen
*/
data class Failure(
val message: String = "",
val component: ErrorComponent = ErrorComponent.Other,
val cause: Throwable? = null
) : Result
/**
* Document captured successfully by analyzing camera feed or taking a picture
*
* @param image captured document JPEG image
* @param method capture method
*/
data class Success(
val image: DocumentImage,
val method: CaptureMethod
) : Result
The image
represents a captured document. It holds a raw JPEG byte array, but you can convert it to Bitmap
using toBitmap()
method.
/**
* Camera frame or a picture representing the document
*
* @param image represented as JPEG ByteArray
* @param width image width
* @param height image height
* @param rotation image rotation
*/
data class DocumentImage(
val image: ByteArray,
val width: Int,
val height: Int,
val rotation: Int
) {
fun toBitmap(rotate: Boolean = true): Bitmap {
...
}
}