Java Code Examples for com.google.android.gms.vision.Detector#Detections

The following examples show how to use com.google.android.gms.vision.Detector#Detections . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BarcodeGraphicTracker.java    From Barcode-Reader with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Update the position/characteristics of the item within the overlay.
 */
@Override
public void onUpdate(Detector.Detections<Barcode> detectionResults, Barcode item) {
    mOverlay.add(mGraphic);
    mGraphic.updateItem(item);

    if (detectionResults != null && detectionResults.getDetectedItems().size() > 1) {
        Log.e("XX", "Multiple items detected");
        Log.e("XX", "onUpdate: " + detectionResults.getDetectedItems().size());

        if (listener != null) {
            List<Barcode> barcodes = asList(detectionResults.getDetectedItems());
            listener.onScannedMultiple(barcodes);
        }
    }
}
 
Example 2
Source File: DocumentProcessor.java    From CVScanner with GNU General Public License v3.0 6 votes vote down vote up
@Override
public int selectFocus(Detector.Detections<Document> detections) {
    SparseArray<Document> detectedItems;
    if((detectedItems = detections.getDetectedItems()).size() == 0) {
        throw new IllegalArgumentException("No documents for selectFocus.");
    } else {
        int itemKey = detectedItems.keyAt(0);
        int itemArea = detectedItems.valueAt(0).getMaxArea();

        for(int index = 1; index < detectedItems.size(); ++index) {
            int itemKey2 = detectedItems.keyAt(index);
            int itemArea2;
            if((itemArea2 = detectedItems.valueAt(index).getMaxArea()) > itemArea) {
                itemKey = itemKey2;
                itemArea = itemArea2;
            }
        }

        return itemKey;
    }
}
 
Example 3
Source File: PandroidScannerView.java    From pandroid with Apache License 2.0 6 votes vote down vote up
@Override
public void receiveDetections(final Detector.Detections<Barcode> var1) {
    if (isResume && var1.getDetectedItems().size() > 0) {
        pauseDetector();
        final Barcode barcode = var1.getDetectedItems().valueAt(0);
        handler.post(new Runnable() {
            @Override
            public void run() {
                if(!handleBarcode(barcode)){
                    resumeDetector();
                }
            }
        });

    }
}
 
Example 4
Source File: OcrDetectorProcessor.java    From Document-Scanner with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Called by the detector to deliver detection results.
 * If your application called for it, this could be a place to check for
 * equivalent detections by tracking TextBlocks that are similar in lo
 * ion and content from
 * previous frames, or reduce noise by eliminating TextBlocks that have not persisted through
 * multiple detections.
 */
@Override
public void receiveDetections(Detector.Detections<TextBlock> detections) {
    mGraphicOverlay.clear();
    SparseArray<TextBlock> items = detections.getDetectedItems();
    for (int i = 0; i < items.size(); ++i) {
        TextBlock item = items.valueAt(i);
        OcrGraphic graphic = new OcrGraphic(mGraphicOverlay, item);
        mGraphicOverlay.add(graphic);
    }
}
 
Example 5
Source File: BarcodeGraphicTracker.java    From Bluefruit_LE_Connect_Android with MIT License 5 votes vote down vote up
/**
 * Update the position/characteristics of the item within the overlay.
 */
@Override
public void onUpdate(Detector.Detections<Barcode> detectionResults, Barcode item) {
    mOverlay.add(mGraphic);
    mGraphic.updateItem(item);
    if (mListener != null) {
        mListener.onCodeScanned(item.rawValue);
    }
}
 
Example 6
Source File: OcrDetectorProcessor.java    From OCR-Reader with MIT License 5 votes vote down vote up
/**
 * Called by the detector to deliver detection results.
 * If your application called for it, this could be a place to check for
 * equivalent detections by tracking TextBlocks that are similar in location and content from
 * previous frames, or reduce noise by eliminating TextBlocks that have not persisted through
 * multiple detections.
 */
@Override
public void receiveDetections(Detector.Detections<TextBlock> detections) {
    mGraphicOverlay.clear();
    SparseArray<TextBlock> items = detections.getDetectedItems();
    for (int i = 0; i < items.size(); ++i) {
        TextBlock item = items.valueAt(i);
        OcrGraphic graphic = new OcrGraphic(mGraphicOverlay, item);
        mGraphicOverlay.add(graphic);
    }
}
 
Example 7
Source File: OcrDetectorProcessor.java    From android-vision with Apache License 2.0 5 votes vote down vote up
/**
 * Called by the detector to deliver detection results.
 * If your application called for it, this could be a place to check for
 * equivalent detections by tracking TextBlocks that are similar in location and content from
 * previous frames, or reduce noise by eliminating TextBlocks that have not persisted through
 * multiple detections.
 */
@Override
public void receiveDetections(Detector.Detections<TextBlock> detections) {
    mGraphicOverlay.clear();
    SparseArray<TextBlock> items = detections.getDetectedItems();
    for (int i = 0; i < items.size(); ++i) {
        TextBlock item = items.valueAt(i);
        OcrGraphic graphic = new OcrGraphic(mGraphicOverlay, item);
        mGraphicOverlay.add(graphic);
    }
}
 
Example 8
Source File: OcrDetectorProcessor.java    From Questor with MIT License 5 votes vote down vote up
/**
 * Called by the detector to deliver detection results.
 * If your application called for it, this could be a place to check for
 * equivalent detections by tracking TextBlocks that are similar in location and content from
 * previous frames, or reduce noise by eliminating TextBlocks that have not persisted through
 * multiple detections.
 */
@Override
public void receiveDetections(Detector.Detections<TextBlock> detections) {
    mGraphicOverlay.clear();
    SparseArray<TextBlock> items = detections.getDetectedItems();
    for (int i = 0; i < items.size(); ++i) {
        TextBlock item = items.valueAt(i);
        OcrGraphic graphic = new OcrGraphic(mGraphicOverlay, item);
        mGraphicOverlay.add(graphic);
    }
}
 
Example 9
Source File: BarcodeGraphicTracker.java    From AndroidApp with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void onUpdate(Detector.Detections<Barcode> detectionResults, Barcode item) {
    mCallback.onFound(item);
}
 
Example 10
Source File: CodeGraphicTracker.java    From prebid-mobile-android with Apache License 2.0 4 votes vote down vote up
/**
 * Update the position/characteristics of the item within the overlay.
 */
@Override
public void onUpdate(Detector.Detections<Barcode> detectionResults, Barcode item) {
    mOverlay.add(mGraphic);
    mGraphic.updateItem(item);
}
 
Example 11
Source File: BarcodeGraphicTracker.java    From samples-android with Apache License 2.0 4 votes vote down vote up
/**
 * Update the position/characteristics of the item within the overlay.
 */
@Override
public void onUpdate(Detector.Detections<Barcode> detectionResults, Barcode item) {
    mOverlay.add(mGraphic);
    mGraphic.updateItem(item);
}
 
Example 12
Source File: BarcodeGraphicTracker.java    From flutter_mobile_vision with MIT License 4 votes vote down vote up
@Override
public void onMissing(Detector.Detections<Barcode> detectionResults) {
    overlay.remove(graphic);
}
 
Example 13
Source File: DocumentTracker.java    From CVScanner with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onUpdate(Detector.Detections<Document> detections, Document document) {
    mOverlay.add(mGraphic);
    mGraphic.update(document);
}
 
Example 14
Source File: OcrGraphicTracker.java    From flutter_mobile_vision with MIT License 4 votes vote down vote up
@Override
public void onMissing(Detector.Detections<TextBlock> detections) {
    overlay.remove(graphic);
}
 
Example 15
Source File: GraphicTracker.java    From android-vision with Apache License 2.0 4 votes vote down vote up
/**
 * Update the position/characteristics of the item within the overlay.
 */
@Override
public void onUpdate(Detector.Detections<T> detectionResults, T item) {
    mOverlay.add(mGraphic);
    mGraphic.updateItem(item);
}
 
Example 16
Source File: BarcodeGraphicTracker.java    From fuse-qreader with MIT License 2 votes vote down vote up
/**
 * Hide the graphic when the corresponding object was not detected.  This can happen for
 * intermediate frames temporarily, for example if the object was momentarily blocked from
 * view.
 */
@Override
public void onMissing(Detector.Detections<Barcode> detectionResults) {
    mOverlay.remove(mGraphic);
}
 
Example 17
Source File: BarcodeGraphicTracker.java    From samples-android with Apache License 2.0 2 votes vote down vote up
/**
 * Hide the graphic when the corresponding object was not detected.  This can happen for
 * intermediate frames temporarily, for example if the object was momentarily blocked from
 * view.
 */
@Override
public void onMissing(Detector.Detections<Barcode> detectionResults) {
    mOverlay.remove(mGraphic);
}
 
Example 18
Source File: BarcodeGraphicTracker.java    From MVBarcodeReader with Apache License 2.0 2 votes vote down vote up
/**
 * Hide the graphic when the corresponding object was not detected.  This can happen for
 * intermediate frames temporarily, for example if the object was momentarily blocked from
 * view.
 */
@Override
public void onMissing(Detector.Detections<Barcode> detectionResults) {
    mOverlay.remove(mGraphic);
}
 
Example 19
Source File: BarcodeGraphicTracker.java    From android-vision with Apache License 2.0 2 votes vote down vote up
/**
 * Hide the graphic when the corresponding object was not detected.  This can happen for
 * intermediate frames temporarily, for example if the object was momentarily blocked from
 * view.
 */
@Override
public void onMissing(Detector.Detections<Barcode> detectionResults) {
    mOverlay.remove(mGraphic);
}
 
Example 20
Source File: BarcodeGraphicTracker.java    From Bluefruit_LE_Connect_Android with MIT License 2 votes vote down vote up
/**
 * Hide the graphic when the corresponding object was not detected.  This can happen for
 * intermediate frames temporarily, for example if the object was momentarily blocked from
 * view.
 */
@Override
public void onMissing(Detector.Detections<Barcode> detectionResults) {
    mOverlay.remove(mGraphic);
}