lessthanoptimal / BoofAndroidDemo

Demonstration of BoofCV for Android devices
125 stars 42 forks source link

QR code with inverted colors #17

Closed rojepp closed 4 years ago

rojepp commented 4 years ago

Hi, First of all, thanks for your hard work.

Is there a way to make BoofCV detect inverted QR codes?

This is the code that won't work, brown where white would usually be and white where black would usually be. Firebase ML vision will detect this, but it takes about three seconds. :-/

58591D35-9C72-4BEC-8C48-9C6BB5393422_4_5005_c

lessthanoptimal commented 4 years ago

If this is only type of QR code you wish to detect a quick hack is to simply invert the image. Even if it's not the only QR Code you wish to detect it might be faster to process every image twice compared to firebase. How fast does BoofCV run here? Otherwise I guess create a ticket on Github. I've been aware of this issue for a bit, but haven't thought of an inexpensive way to detect these images and they aren't that common.

On Wed, Apr 15, 2020 at 5:54 AM Robert Jeppesen notifications@github.com wrote:

Hi, First of all, thanks for your hard work.

Is there a way to make BoofCV detect inverted QR codes?

This is the code that won't work, brown where white would usually be and white where black would usually be. Firebase ML vision will detect this, but it takes about three seconds. :-/

[image: 58591D35-9C72-4BEC-8C48-9C6BB5393422_4_5005_c] https://user-images.githubusercontent.com/445888/79339114-ac0a5880-7f28-11ea-9bbc-0aa56d16c10a.jpeg

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/lessthanoptimal/BoofAndroidDemo/issues/17, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFUOVYIN23SZIHL4SBGFRTRMWU6ZANCNFSM4MIRSQUA .

-- "Now, now my good man, this is no time for making enemies." — Voltaire (1694-1778), on his deathbed in response to a priest asking that he renounce Satan.

rojepp commented 4 years ago

Thanks. I was thinking about inverting every other frame as BoofCV is plenty fast enough anyway. I'd be fine with this hack, but I'm not sure where and how to do it. I've shamefully used this example code without fully knowing how it works. :)

rojepp commented 4 years ago

I found out how to do it. Thanks for your help! A simple val g = GrayImageOps.invert(image as GrayU8, 255, null) before detector.process does the trick.

lessthanoptimal commented 4 years ago

Do you have the image as a GrayU8? If so this should work: PixelMath.minus(255,image,image)

On Wed, Apr 15, 2020 at 7:17 AM Robert Jeppesen notifications@github.com wrote:

Thanks. I was thinking about inverting every other frame as BoofCV is plenty fast enough anyway. I'd be fine with this hack, but I'm not sure where and how to do it. I've shamefully used this example code without fully knowing how it works. :)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/lessthanoptimal/BoofAndroidDemo/issues/17#issuecomment-614067330, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFUOVZSUN2CGOSMSG6DEB3RMW6YJANCNFSM4MIRSQUA .

-- "Now, now my good man, this is no time for making enemies." — Voltaire (1694-1778), on his deathbed in response to a priest asking that he renounce Satan.

rojepp commented 4 years ago

Cool, Is PixelMath faster or better than what I did?

Thanks again.

lessthanoptimal commented 4 years ago

Yep that's basically the same thing.

On Wed, Apr 15, 2020 at 7:45 AM Robert Jeppesen notifications@github.com wrote:

I found out how to do it. Thanks for your help! A simple val g = GrayImageOps.invert(image as GrayU8, 255, null) before detector.process does the trick.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/lessthanoptimal/BoofAndroidDemo/issues/17#issuecomment-614083086, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFUOV73XMAD3YLLQ42V7LDRMXCA3ANCNFSM4MIRSQUA .

-- "Now, now my good man, this is no time for making enemies." — Voltaire (1694-1778), on his deathbed in response to a priest asking that he renounce Satan.