I am getting Barcode(com.google.android.gms.vision.barcode) object from a physical sales card via camera. Is there a way to convert it back to a image using gms:play-services-vision library?
I think you will get barcode value in a string. you may try to below code
TextView tv = (TextView)findViewById(R.id.textview);
tv.setText(bitmapstring);
tv.buildDrawingCache();
ImageView img = (ImageView)findViewById(R.id.imageview);
img.setImageBitmap(tv.getDrawingCache());
Seems like there's no way of doing that by using the play-services-vision library. My first thought would be to take a screen capture of the preview of the camera before actually reading the barcode, but let's suppose you cannot do that.
If you have the actual data and the format of the barcode you can use ZXing to generate back the barcode image.
Here's an example of how to do it: Generate barcode image in Android application
Related
I am currently working on an android application, that should be able to detect a QR code from a picture taken. It is not necessary to decode the QR code because it's only needed to calibrate the camera.
I am using openCV and when I tried to detect the QR code from the original downloaded picture of the QR code it works fine. That's the code I used:
bitmap= BitmapFactory.decodeResource(getResources(),R.drawable.qrcodemitzeugs);
Mat img =new Mat();
Utils.bitmapToMat(bitmap,img)
Mat points= new Mat();
QRCodeDetector detector=new QRCodeDetector();
boolean data = detector.detect(img, points);
But when I try the same Code on a photo taken with my smartphone's camera, the QR code doesn't get detected. I searched for a solution and found that maybe the contrast wasn't high enough so converted the picture into binary using following code:
Imgproc.cvtColor(img,img2,Imgproc.COLOR_BGR2GRAY);
Imgproc.threshold(img2,img2,100,255,Imgproc.THRESH_BINARY);
It returned the whole image in black and white but still the QR code wasn't detected.
Did I do something wrong or is there a solution for this problem?
One of the images i used
I had to resize the picture before uploading it
So I solved my problem, by resizing the Mat to a max of 1200x1200. Apparently the OpenCV QRCodeDetector can only handle Mats between ca. 85x85 and ca. 1200x1200, in which the QR Code itself has to have at least a size of ca. 80x80. I tested this with the image of the original QR Code, which had a size of 600x600. I resized it until the QR Code wasn't detected anymore.
Currently I'm working on a android program using Mobile Vision. I am using the "TextRecognizer" class and one of the methods is .detect(Frame frame). Right now I have a image I want to input into it, however, the image is the file type "Bitmap". I have tried to convert it to "Frame" by casting it but that hasn't worked. If anyone has any suggesting it would be much appreciated.
Use the setBitmap method in the Frame.Builder class:
Frame outputFrame = new Frame.Builder().setBitmap(myBitmap).build();
I am working on camera based application.
I want to normalize image that is captured by device's camera.
Is it possible to normalize image in android? any idea how can i do that?
Thanks...
Try to use Catalano Framework. Here contains the article that you can learn how to use.
I implemented Image Normalization using this approach.
FastBitmap fb = new FastBitmap("image.jpg");
fb.toGrayscale();
ImageNormalization in = new ImageNormalization();
in.applyInPlace(fb);
I have developed an application that calls the ZXing library to invoke the camera.
I have now just been told that we need this working in the emulator for testing purposes.
I don't want to change the code to read from a file, I wan't to call the library, which will call the camera and I wan't the camera to think its looking at an image (if that makes sense).
I've seen a lot around of using webcams but I don't want a live feed.
Does anyone know if this is at all possible?
It depends on how you're integrating with Zxing. If you are scanning barcodes via intent, then the web-cam style live feed may be your only option.
AFAIK there is a reader class that expects you to supply the images. Something like this...
Reader reader = new MultiFormatReader(); //If you are calling the reader in your code
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); //The source as
//supplied by you
Result result = reader.decode(bitmap);
String text = result.getText();
Note that the above code is bits and pieces taken from here .
So it looks like you should be able to supply some image and have the bar code reader take a shot at it.
Hello everyone,
If any one of you can help me this. I am using zxing to decode barCode image, but it returns com.google.zxing.NotFoundException, don't know why. The same image gets decoded via Intent provided to zxing, but not when I use it to decode from image file.
The code that I am using is below :
mMultiFormatReader = new MultiFormatReader();
mMultiFormatReader.setHints(null);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(new RGBLuminanceSource(path)));
Result result = mMultiFormatReader.decodeWithState(bitmap);
I don't think it's exactly the same image, since you can't have it scan a file by Intent. I assume you mean that you can scan the image off your screen fine, but the image itself does not decode.
That's just life, really. Some images won't happen to decode. But you may try TRY_HARDER mode or use a different binarizer to see if that works.