com.google.android.gms.vision.Detector Java Examples

The following examples show how to use com.google.android.gms.vision.Detector. 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: 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 #2
Source File: BarcodeGraphicTracker.java    From Barcode-Reader with Apache License 2.0 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 #3
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 #4
Source File: CameraSource.java    From flutter_mobile_vision with MIT License 5 votes vote down vote up
/**
 * Creates a camera source builder with the supplied context and detector.  Camera preview
 * images will be streamed to the associated detector upon starting the camera source.
 */
public Builder(Context context, Detector<?> detector) {
    if (context == null) {
        throw new IllegalArgumentException("No context supplied.");
    }
    if (detector == null) {
        throw new IllegalArgumentException("No detector supplied.");
    }

    this.detector = detector;
    cameraSource.context = context;
}
 
Example #5
Source File: CameraSource.java    From android-vision with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a camera source builder with the supplied context and detector.  Camera preview
 * images will be streamed to the associated detector upon starting the camera source.
 */
public Builder(Context context, Detector<?> detector) {
    if (context == null) {
        throw new IllegalArgumentException("No context supplied.");
    }
    if (detector == null) {
        throw new IllegalArgumentException("No detector supplied.");
    }

    this.detector = detector;
    cameraSource.context = context;
}
 
Example #6
Source File: CameraSource.java    From flutter_barcode_scanner with MIT License 5 votes vote down vote up
/**
 * Creates a camera source builder with the supplied context and detector.  Camera preview
 * images will be streamed to the associated detector upon starting the camera source.
 */
public Builder(Context context, Detector<?> detector) {
    if (context == null) {
        throw new IllegalArgumentException("No context supplied.");
    }
    if (detector == null) {
        throw new IllegalArgumentException("No detector supplied.");
    }

    mDetector = detector;
    mCameraSource.mContext = context;
}
 
Example #7
Source File: CameraSource.java    From Barcode-Reader with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a camera source builder with the supplied context and detector.  Camera preview
 * images will be streamed to the associated detector upon starting the camera source.
 */
public Builder(Context context, Detector<?> detector) {
    if (context == null) {
        throw new IllegalArgumentException("No context supplied.");
    }
    if (detector == null) {
        throw new IllegalArgumentException("No detector supplied.");
    }

    mDetector = detector;
    mCameraSource.mContext = context;
}
 
Example #8
Source File: Camera2Source.java    From Machine-Learning-Projects-for-Mobile-Applications with MIT License 5 votes vote down vote up
/**
 * Creates a camera source builder with the supplied context and detector.  Camera preview
 * images will be streamed to the associated detector upon starting the camera source.
 */
public Builder(Context context, Detector<?> detector) {
    if (context == null) {
        throw new IllegalArgumentException("No context supplied.");
    }
    if (detector == null) {
        throw new IllegalArgumentException("No detector supplied.");
    }

    mDetector = detector;
    mCameraSource.mContext = context;
}
 
Example #9
Source File: CameraSource.java    From Bluefruit_LE_Connect_Android with MIT License 5 votes vote down vote up
/**
 * Creates a camera source builder with the supplied context and detector.  Camera preview
 * images will be streamed to the associated detector upon starting the camera source.
 */
public Builder(Context context, Detector<?> detector) {
    if (context == null) {
        throw new IllegalArgumentException("No context supplied.");
    }
    if (detector == null) {
        throw new IllegalArgumentException("No detector supplied.");
    }

    mDetector = detector;
    mCameraSource.mContext = context;
}
 
Example #10
Source File: CameraSource.java    From samples-android with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a camera source builder with the supplied context and detector.  Camera preview
 * images will be streamed to the associated detector upon starting the camera source.
 */
public Builder(Context context, Detector<?> detector) {
    if (context == null) {
        throw new IllegalArgumentException("No context supplied.");
    }
    if (detector == null) {
        throw new IllegalArgumentException("No detector supplied.");
    }

    mDetector = detector;
    mCameraSource.mContext = context;
}
 
Example #11
Source File: CameraSource.java    From android-vision with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a camera source builder with the supplied context and detector.  Camera preview
 * images will be streamed to the associated detector upon starting the camera source.
 */
public Builder(Context context, Detector<?> detector) {
    if (context == null) {
        throw new IllegalArgumentException("No context supplied.");
    }
    if (detector == null) {
        throw new IllegalArgumentException("No detector supplied.");
    }

    mDetector = detector;
    mCameraSource.mContext = context;
}
 
Example #12
Source File: CameraSource.java    From OCR-Reader with MIT License 5 votes vote down vote up
/**
 * Creates a camera source builder with the supplied context and detector.  Camera preview
 * images will be streamed to the associated detector upon starting the camera source.
 */
public Builder(Context context, Detector<?> detector) {
    if (context == null) {
        throw new IllegalArgumentException("No context supplied.");
    }
    if (detector == null) {
        throw new IllegalArgumentException("No detector supplied.");
    }

    mDetector = detector;
    mCameraSource.mContext = context;
}
 
Example #13
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 #14
Source File: CameraSource.java    From Camera2Vision with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a camera source builder with the supplied context and detector.  Camera preview
 * images will be streamed to the associated detector upon starting the camera source.
 */
public Builder(Context context, Detector<?> detector) {
    if (context == null) {
        throw new IllegalArgumentException("No context supplied.");
    }
    if (detector == null) {
        throw new IllegalArgumentException("No detector supplied.");
    }

    usesFaceDetector = true;
    mDetector = detector;
    mCameraSource.mContext = context;
}
 
Example #15
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 #16
Source File: Camera2Source.java    From Camera2Vision with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a camera source builder with the supplied context and detector.  Camera preview
 * images will be streamed to the associated detector upon starting the camera source.
 */
public Builder(Context context, Detector<?> detector) {
    if (context == null) {
        throw new IllegalArgumentException("No context supplied.");
    }
    if (detector == null) {
        throw new IllegalArgumentException("No detector supplied.");
    }

    mDetector = detector;
    mCameraSource.mContext = context;
}
 
Example #17
Source File: BarcodeCentralFocusingProcessor.java    From google-authenticator-android with Apache License 2.0 5 votes vote down vote up
public BarcodeCentralFocusingProcessor(
    Detector<Barcode> detector,
    Tracker<Barcode> tracker,
    Boolean centralFilterEnabled) {
  super(detector, tracker);
  mCentralFilterEnabled = centralFilterEnabled;
}
 
Example #18
Source File: OcrDetectorProcessor.java    From Moneycim 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 icon_save 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) {

        final TextBlock item = items.valueAt(i);
        OcrGraphic graphic = new OcrGraphic(mGraphicOverlay, item);
        mGraphicOverlay.add(graphic);
        //detectedText += item.getValue();
    }
}
 
Example #19
Source File: CameraSourcePreview.java    From react-native-barcode-scanner-google with MIT License 5 votes vote down vote up
@RequiresPermission(Manifest.permission.CAMERA)
public void replaceBarcodeDetector(Detector<?> detector, boolean shouldResume) throws IOException, SecurityException {
    if (mCameraSource != null) {
        mCameraSource.release();
        mCameraSource.setDetector(detector);

        if (shouldResume && mSurfaceAvailable) {
            start(mCameraSource);
        }
    }
}
 
Example #20
Source File: CameraSource.java    From react-native-barcode-scanner-google with MIT License 5 votes vote down vote up
public void setDetector(Detector<?> detector) {
    if (mFrameProcessor != null && mFrameProcessor.mActive) {
        throw new RuntimeException("Can't replace detector while frame processor is active!");
    }

    this.mFrameProcessor = this.new FrameProcessingRunnable(detector);
}
 
Example #21
Source File: CameraSource.java    From AndroidApp with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Creates a camera source builder with the supplied context and detector.  Camera preview
 * images will be streamed to the associated detector upon starting the camera source.
 */
public Builder(Context context, Detector<?> detector) {
    if (context == null) {
        throw new IllegalArgumentException("No context supplied.");
    }
    if (detector == null) {
        throw new IllegalArgumentException("No detector supplied.");
    }

    mDetector = detector;
    mCameraSource.mContext = context;
}
 
Example #22
Source File: FrameProcessingRunnable.java    From camerakit-android with MIT License 5 votes vote down vote up
public FrameProcessingRunnable(Detector<?> detector, Size mPreviewSize, Camera mCamera) {
    mDetector = detector;
    this.mPreviewSize = mPreviewSize;
    this.mCamera = mCamera;

    mProcessingThread = new Thread(this);
}
 
Example #23
Source File: TextProcessor.java    From camerakit-android with MIT License 5 votes vote down vote up
@Override
public void receiveDetections(Detector.Detections<TextBlock> detections) {

    SparseArray<TextBlock> detectedItems = detections.getDetectedItems();
    for (int i = 0; i < detectedItems.size(); ++i) {
        TextBlock item = detectedItems.valueAt(i);
        if (item != null && item.getValue() != null) {
            CameraKitTextDetect event = new CameraKitTextDetect(new CameraKitTextBlock(item));
            mEventDispatcher.dispatch(event);
            callback.callback(event);
        }
    }
}
 
Example #24
Source File: CameraSource.java    From android-vision with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a camera source builder with the supplied context and detector.  Camera preview
 * images will be streamed to the associated detector upon starting the camera source.
 */
public Builder(Context context, Detector<?> detector) {
    if (context == null) {
        throw new IllegalArgumentException("No context supplied.");
    }
    if (detector == null) {
        throw new IllegalArgumentException("No detector supplied.");
    }

    this.detector = detector;
    cameraSource.context = context;
}
 
Example #25
Source File: CameraSource.java    From BarcodeReaderSample with MIT License 5 votes vote down vote up
/**
 * Creates a camera source builder with the supplied context and detector.  Camera preview
 * images will be streamed to the associated detector upon starting the camera source.
 */
public Builder(Context context, Detector<?> detector) {
    if (context == null) {
        throw new IllegalArgumentException("No context supplied.");
    }
    if (detector == null) {
        throw new IllegalArgumentException("No detector supplied.");
    }

    mDetector = detector;
    mCameraSource.mContext = context;
}
 
Example #26
Source File: BarcodeGraphicTracker.java    From fuse-qreader 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);
    mActivity.updateResult(item);
}
 
Example #27
Source File: CameraSource.java    From android-vision with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a camera source builder with the supplied context and detector.  Camera preview
 * images will be streamed to the associated detector upon starting the camera source.
 */
public Builder(Context context, Detector<?> detector) {
    if (context == null) {
        throw new IllegalArgumentException("No context supplied.");
    }
    if (detector == null) {
        throw new IllegalArgumentException("No detector supplied.");
    }

    mDetector = detector;
    mCameraSource.mContext = context;
}
 
Example #28
Source File: CameraSource.java    From fuse-qreader with MIT License 5 votes vote down vote up
/**
 * Creates a camera source builder with the supplied context and detector.  Camera preview
 * images will be streamed to the associated detector upon starting the camera source.
 */
public Builder(Context context, Detector<?> detector) {
    if (context == null) {
        throw new IllegalArgumentException("No context supplied.");
    }
    if (detector == null) {
        throw new IllegalArgumentException("No detector supplied.");
    }

    mDetector = detector;
    mCameraSource.mContext = context;
}
 
Example #29
Source File: QrDialogFragment.java    From octoandroid with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void receiveDetections(Detector.Detections<Barcode> detections) {
    final SparseArray<Barcode> barcodes = detections.getDetectedItems();

    if (barcodes.size() != 0) {
        mApiKey = barcodes.valueAt(0).displayValue;
        getActivity().runOnUiThread(this);
    }
}
 
Example #30
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);
    }
}