Search code examples
androidgoogle-visionandroid-vision

What does one persist and return the RawValue from the tracker?


I am evaluating the Multi-Tracker sample and I want to get hold of the RawValue of the barcode detector once one is available.

I would like to dismiss the Tracker once a valid RawValue has been obtained and use the value elsewhere.

Any suggestions on the items below will be helpful.

  1. How to dismiss the tracker once a detection has been made

  2. How to hold and pass the RawValue up the the activity. For example, echo it in a Toast

Thanks


Solution

  • See the discussion in this thread about passing the RawValue to the activity:

    How to capture barcode values using the new Barcode API in Google Play Services?

    The tracker is active as long as the associated CameraSource/Detector is active (i.e., the release() method has not been called). But if you want to avoid receiving updates beyond the initial detection, you could have the tracker suppress sending updates beyond the first one. For example:

    @Override
    public void onUpdate(Detector.Detections<Barcode> detectionResults, Barcode item) {
        if (!mFoundCalled) {
            mCallback.onFound(item.rawValue);
            mFoundCalled = true;
        }
        ...
    }