googlesamples / android-vision

Deprecated: The Mobile Vision API is now a part of ML Kit: Check out this repo:
https://github.com/firebase/quickstart-android/tree/master/mlkit
Apache License 2.0
2.92k stars 1.73k forks source link

How to capture the image of scanned barcode in vision barcode reader vision api #57

Open urlAkash opened 8 years ago

urlAkash commented 8 years ago

In camera source activity the take picture method is given but how to use it and how to take picture? Where to call the take picture method and how to store and display the captured picture in Resulting Activity?? Please help me soon

alikarimi64 commented 8 years ago

I have same issue~ When i tap it doesn't capture

gbdslmad commented 7 years ago

The current Mobile Vision Barcode API does not appear to allow the developer to access the bitmap image that was used to successfully scan the barcode. If this is indeed possible, please could you advise how it can be achieved? Otherwise please consider this as a feature enhancement of the API.

This requirement is especially relevant to payments that involve the scan of a barcode on a bill or invoice. The ability to retain the image as part of the payment audit trail would provide evidence of the origin of the payment details, in the event of a dispute (i.e. the barcode could be re-scanned).

New EU Payments legislation (PSD2) demands segregation between the display and initiation of payments. This is challenging to achieve on a mobile device. The retention of the barcode image may help meet these segregation requirements.

pchx-zz commented 7 years ago

You can easily retain images in your application without any modification to the API itself.

For example, you can wrap BarcodeDetector in another Detector<Barcode> and supplement it with your own logic (e.g. if the results array is non-empty, start a background task to save the Frame data):

public class CapturingBarcodeDetector extends Detector<Barcode> {
  private BarcodeDetector mDetector;
  public CapturingBarcodeDetector(BarcodeDetector detector) {
    mDetector = detector;
  }

  [...]
  @Override
  public SparseArray<Barcode> detect(Frame frame) {
    SparseArray<Barcode> barcodes = mDetector.detect(frame);
    if (barcodes.size() > 0) {
      // Do whatever you like with frame.
    }
  }
}

Then attach your custom Detector to CameraSource and you're done.

mrcodecloud commented 6 years ago

When we are calling detect method from Main, where from we will get Frame to send to detect method ?