Android: replace camera preview with image - android

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.

Related

Google ML Kit barcode scanner does not scan QR code with green background

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()

Problem with scanning gray qr code - zxing library

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

How to know if a Android device can read QR Codes?

Currently I have a small Activity that allows me to read QR codes and returns the string that contains the code.
I do this with CameraSource and SurfaceView from the package com.google.android.gms.vision y com.view respectively.
But I wonder if there is some way through code to know if the device that runs the application has the ability to read QR codes.
Because if the device cannot read QR codes, I would like to display a TextView instead of the SurfaceView saying that the device can't do this.
Thank you, so much.
Check if the device has a camera. There's nothing special about reading QR codes; the device takes a picture, the image analysis logic does the rest.

Scan for Object with Android Camera

I need to scan a special object within my android application.
I thought about using OpenCV but it is scanning all objects inside the view of the camera. I only need the camera to regognize a rectangular piece of paper.
How can i do that?
My first thought was: How do barcode scanners work? They are able to regognize the barcode area and automatically take a picture when the barcode is inside a predefined area of the screen and when its sharp. I guess it must be possible to transfer that to my problem (tell me if im wrong).
So step by step:
Open custom camera application
Scan objects inside the view of the camera
Recognize the rectangular piece of paper
If paper is inside a predefined area and sharp -> take a picture
I would combine this with audio. If the camera recognized the paper make some noice like a peep or something and the more the object is fitting the predefined area the faster the peep sound is played. That would make taking pictures for blind people possible.
Hope someone got ideas on that.
OpenCV is an image processing framework/library. It does not "scan all objects inside the view of the camera". By itself it does nothing and yet it gives the use of a number of useful functions, many of which could be used for your specified application.
If the image is not cluttered and nothing is on the paper, I would look into using edge detection (i.e. Canny or similar) or even colour blobs (even though colour is never a good idea, if your application is always for white uncovered paper, it should work robustly).
OpenCV does add some overhead, but it would allow you to quickly use functions for a simple solution.

Android Barcode Scanner Not reading some barcodes

I am working on a Project which uses the Barcode Scanner for redeem points. I have tried Zxing,QR Droid, Red Laser,Scan Life,Shop Savy etc usig HTC EVO 3D. None of them read all barcodes. But Zbar for IOS reading all the same codes.I think its the problem with hardware of the device.Is there any Scanner App better than above mentioned ?
Bar code Image.
http://i.stack.imgur.com/7VR9I.jpg
This barcode is a form of RSS-14. zxing / Barcode Scanner reads it, but it's not the easiest to read. You need to put the image in landscape orientation (right side up). Try TRY_HARDER mode, and restrict your scan to the RSS-14 format to avoid false positives.

Categories

Resources