Load external image to scan

25 views
Skip to first unread message

Vyacheslav

unread,
Oct 23, 2020, 7:39:52 AM10/23/20
to BoofCV
Hello, this should be a simple question: I load an image Uri from an Android Gallery. How can I scan a QR code from it? Should I use renderBitmapImage / processFrame or what method and how to convert Uri to a proper format?

Also I found this uncompleted sample here: https://github.com/lessthanoptimal/KBoofExamples

Vyacheslav

unread,
Oct 23, 2020, 10:24:54 AM10/23/20
to BoofCV
Yeah, I found and expanded the code sample in an answer below:

val bitmap: Bitmap = MediaStore.Images.Media.getBitmap(contentResolver, imageUri) //deprecated
val detector: QrCodeDetector<GrayU8> = FactoryFiducial.qrcode(null, GrayU8::class.java)
val gray = GrayU8(1, 1)
ConvertBitmap.bitmapToGray(bitmap, gray, null)
detector.process(gray)
if (detector.detections.isNotEmpty())
proceedQrCode(detector.detections[0].message)

пятница, 23 октября 2020 г. в 14:39:52 UTC+3, Vyacheslav:

Peter

unread,
Oct 27, 2020, 10:41:10 PM10/27/20
to BoofCV
I've not tried scanning all images on Android before. That worked right?

Vyacheslav

unread,
Oct 28, 2020, 4:19:36 AM10/28/20
to BoofCV
Yes, I successfully scan a QR code from an Android library image.

среда, 28 октября 2020 г. в 05:41:10 UTC+3, Peter:
Reply all
Reply to author
Forward
0 new messages