I have a problem with qr-code which is gray and white. The problem is that I can scan it when the environment around is dark, and when it is bright during the day, the camera doesn't catch either the contrast or the qr reader doesn't distinguish between colors that's why it's not readable. I am using a 'me.dm7.barcodescanner:zxing:1.9.13' library. Any ideas how I should change the contrast or set camera mode to monochrome or how to deal with it? Also I found an app in google play store which reads this code without problem so there must be a sollution.
Greetings
Yeah... The QR code you use can be scanned by a lot of cameras... BUT zxiling supports BLACK and WHITE QRcodes only. You can use the built-in object Bitmap in android to work with the image... Also you should try to change the QR code with another
Related
I noticed a strange issue with Google's ML Kit Barcode scanner. I try to scan a QR code which has a green background, and it does not recognize the QR code at all. However if I crop the same QR code and remove the green background then it scans perfectly well. I don't put any code examples of my implementation here as the official example has the exact same issue.
Here is my image. I don't even know how to research this problem as I totally don't understand what green background can do.
Well, after spending some time on trying to solve this problem with various image processing techniques etc. I found out that the solution is rather simple and was always there right in front of me.
So while building the image analyzer, there is a configuration function to set Target Resolution setTargetResolution(#NonNull Size resolution), which if not set explicitly is defaulting to 640x480, which is probably ok for general use cases related to image analyzer (otherwise I wonder why Google should pick this resolution as a default). And it's also OK for normal QR codes, but for problematic QRs like this it seems to mess thing up, so ML kit needs a higher resolution images for processing.
So just changing this default 640x480 to 1920x1440 immediately solved the issue, and the QR code without borders started to be scanned immediately and with very good performance. I tried other, smaller resolutions as well, tried on different high and low end devices with good and bad cameras, and came to this resolution, which seems to perform the best.
So currently me Image Analyzer builder looks like this, and it works just fine
private val analyzerUseCase = ImageAnalysis.Builder()
.setTargetResolution(Size(1440, 1920))
.setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
.build()
I'm building an Android app that has to identify, in realtime, a mark/pattern which will be on the four corners of a visiting card. I'm using a preview stream of the rear camera of the phone as input.
I want to overlay a small circle on the screen where the mark is present. This is similar to how reference dots will be shown on screen by a QR reader at the corner points of the QR code preview.
I'm aware about how to get the frames from camera using native Android SDK, but I have no clue about the processing which needs to be done and optimization for real time detection. I tried messing around with OpenCV and there seems to be a bit of lag in its preview frames.
So I'm trying to write a native algorithm usint raw pixel values from the frame. Is this advisable? The mark/pattern will always be the same in my case. Please guide me with the algorithm to use to find the pattern.
The below image shows my pattern along with some details (ratios) about the same (same as the one used in QR, but I'm having it at 4 corners instead of 3)
I think one approach is to find black and white pixels in the ratio mentioned below to detect the mark and find coordinates of its center, but I have no idea how to code it in Android. I looking forward for an optimized approach for real-time recognition and display.
Any help is much appreciated! Thanks
Detecting patterns on four corners of a visiting card:
Assuming background is white, you can simply try this method.
Needs to be done and optimization for real time detection:
Yes, you need OpenCV
Here is an example of real-time marker detection on Google Glass using OpenCV
In this example, image showing in tablet has delay (blutooth), Google Glass preview is much faster than that of tablet. But, still have lag.
I was working on a QRCode reader within my app using the Vision API. I realized the API can't detect negative colors. My customer has thousand of cards with white QRCodes on a blue background.
Attached is an example of 2 qrcodes. The first works perfectly (default colors). The second one doesn't (white on blue). Some commercial QRCode readers are able to read it but I couldn't discover how they do it.
I really want to avoid using third party libs and apps to do this. So far, I'm using the NEGATIVE effect on the camera. But this is a workaround that I want to avoid too.
Invert the bitmap on the fly is very slow and is out of question.
I read somewhere that detection of negative colors is optional on the QRCode specification and it seems that Google Vision API doesn't support it. Suggestions?
Thank you for your attention.
QRCode Working
QRCode Not Working
I'm doing black box automation testing (with appium & ruby) for app which use camera in few cases:
- taking photo
- scan QR code
- scan PDF code
I'm looking for a way to set image in to image preview to scan it.
This should(ideally) word for both emulators and real devices.
I was willing to do the same for my app (which scann QR code), and the solution I used was to add an EditText (which appears only in test mode) to put the string, which corresponds to the QR code, and then handling the string as the result of the scan.
The problem with that solution is that you can't test the camera or the functions/methods you made to decode, but it's the only problem so if you are using a library (like ZXing) it's not a big deal, because I assume you want only the string that corresponds with the QR code.
I have a small Android app I am building to apply filters/effects on a picture taken from the camera or from the image gallery. So far I have blur, sepia, emboss, b&w, contrast, etc. However, the one I am looking for seems to be hard to find using google. I would like to apply the toy camera effect as well. I see a lot of Android apps doing this, but I can't find the algorithm to implement to Android.
Does anyone know how I can achieve this?
As #You said above the toy camera effect is more than likely a number of adjustments. In my experience you should look into adding a vignette (http://en.wikipedia.org/wiki/Vignetting) and emulating E6/C41 cross processing. Cross-processing can be easily achieved by manipulating the individual RGB channel such as the curves shown here http://www.reynsphoto.com/articles/Post_Processing/html/Digital_cross-processing_C-41_as_E-6.php. Furthermore, you can add a slight yellow tint.
hope this helps