MLKitAndroid
MLKitAndroid copied to clipboard
camerakit
I upgraded it from wonderklin package to new camerakit version and using AndroidX. but this code in BarCodeReaderActivity
override fun onClick(v: View) {
fabProgressCircle.show()
cameraKitView.captureImage { cameraKitImage ->
// Get the Bitmap from the captured shot
getQRCodeDetails(cameraKitImage.bitmap)
runOnUiThread {
showPreview()
imagePreview.setImageBitmap(cameraKitImage.bitmap)
}
}
}
Is not compiling. Not sure what is wrong? Any suggestions
Hi, what's the issue that you're facing @jinman?
CameraKit 1.0 breaks API compatibility with CameraKit 0.13
The example code uses com.wonderkiln.camerakit.CameraView from CameraKit 0.13 which has a captureImage
that works like that, but in CameraKit 1.0 with com.camerakit.CameraKitView captureImage
and friends only accept callbacks with this signature: (com.camerakit.CameraKitView cameraKitView, byte[] bytes)
.
I tried to figure out how to get a bitmap out of those bytes right now as there's no object that has a bitmap
property, but I gave up and moved back to 0.13, for which at least the docs and examples match.
Good news: I figured out how to get a bitmap out of the byte array and fix your function:
override fun onClick(v: View) {
fabProgressCircle.show()
cameraKitView.captureImage { cameraKitView, jpeg ->
val bitmap = BitmapFactory.decodeByteArray(jpeg, 0, jpeg.size)
// Get the Bitmap from the captured shot
getQRCodeDetails(bitmap)
runOnUiThread {
showPreview()
imagePreview.setImageBitmap(bitmap)
}
}
}
Bad news: It doesn't capture anything... as described in this CameraKit's issue: https://github.com/CameraKit/camerakit-android/issues/533
Check this out. Degrade the version. https://github.com/CameraKit/camerakit-android/issues/533#issuecomment-524150954