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

The following examples show how to use com.google.android.gms.vision.Tracker. 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: BarcodeScannerView.java    From react-native-barcode-scanner-google with MIT License 6 votes vote down vote up
@Override
public Tracker<Barcode> create(Barcode barcode) {
    return new Tracker<Barcode>() {
        /**
         * Start tracking the detected item instance within the item overlay.
         */
        @Override
        public void onNewItem(int id, Barcode item) {
            // Act on new barcode found
            WritableMap event = Arguments.createMap();
            event.putString("data", item.displayValue);
            event.putString("type", BarcodeFormat.get(item.format));

            sendNativeEvent(BARCODE_FOUND_KEY, event);
        }
    };
}
 
Example #2
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 #3
Source File: OcrTrackerFactory.java    From flutter_mobile_vision with MIT License 5 votes vote down vote up
@Override
public Tracker<TextBlock> create(TextBlock textBlock) {
    OcrGraphic graphic = new OcrGraphic(graphicOverlay, showText);
    try {
        return new OcrGraphicTracker(graphicOverlay, graphic);
    } catch (Exception ex) {
        Log.d("OcrTrackerFactory", ex.getMessage(), ex);
    }
    return null;
}
 
Example #4
Source File: FaceTrackerFactory.java    From flutter_mobile_vision with MIT License 5 votes vote down vote up
@Override
public Tracker<Face> create(Face face) {
    FaceGraphic graphic = new FaceGraphic(graphicOverlay, showText);
    try {
        return new FaceGraphicTracker(graphicOverlay, graphic);
    } catch (Exception ex) {
        Log.d("FaceTrackerFactory", ex.getMessage(), ex);
    }
    return null;
}
 
Example #5
Source File: BarcodeTrackerFactory.java    From flutter_mobile_vision with MIT License 5 votes vote down vote up
@Override
public Tracker<Barcode> create(Barcode barcode) {
    BarcodeGraphic graphic = new BarcodeGraphic(graphicOverlay, showText);
    try {
        return new BarcodeGraphicTracker(graphicOverlay, graphic, barcodeUpdateListener);
    } catch (Exception ex) {
        Log.d("BarcodeTrackerFactory", ex.getMessage(), ex);
    }
    return null;
}
 
Example #6
Source File: BarcodeTrackerFactory.java    From android-vision with Apache License 2.0 4 votes vote down vote up
@Override
public Tracker<Barcode> create(Barcode barcode) {
    BarcodeGraphic graphic = new BarcodeGraphic(mGraphicOverlay);
    return new GraphicTracker<>(mGraphicOverlay, graphic);
}
 
Example #7
Source File: FaceAnalyser.java    From UserAwareVideoView with Apache License 2.0 4 votes vote down vote up
@Override
public Tracker<Face> create(Face face) {
    return new GraphicFaceTracker();
}
 
Example #8
Source File: FaceAnalyser.java    From Prevent-Screen-Off with Apache License 2.0 4 votes vote down vote up
@Override
public Tracker<Face> create(Face face) {
    return new GraphicFaceTracker();
}
 
Example #9
Source File: BarcodeTrackerFactory.java    From MVBarcodeReader with Apache License 2.0 4 votes vote down vote up
@Override
public Tracker<Barcode> create(Barcode barcode) {
    BarcodeGraphic graphic = new BarcodeGraphic(mGraphicOverlay);
    return new BarcodeGraphicTracker(mGraphicOverlay, graphic, mListener);
}
 
Example #10
Source File: DocumentProcessor.java    From CVScanner with GNU General Public License v3.0 4 votes vote down vote up
public DocumentProcessor(Detector<Document> detector, Tracker<Document> tracker) {
    super(detector, tracker);
}
 
Example #11
Source File: DocumentTrackerFactory.java    From CVScanner with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Tracker<Document> create(Document document) {
    DocumentGraphic graphic = new DocumentGraphic(mOverlay, document);
    return new DocumentTracker(mOverlay, graphic, mListener);
}
 
Example #12
Source File: GooglyEyesActivity.java    From android-vision with Apache License 2.0 4 votes vote down vote up
/**
 * Creates the face detector and associated processing pipeline to support either front facing
 * mode or rear facing mode.  Checks if the detector is ready to use, and displays a low storage
 * warning if it was not possible to download the face library.
 */
@NonNull
private FaceDetector createFaceDetector(Context context) {
    // For both front facing and rear facing modes, the detector is initialized to do landmark
    // detection (to find the eyes), classification (to determine if the eyes are open), and
    // tracking.
    //
    // Use of "fast mode" enables faster detection for frontward faces, at the expense of not
    // attempting to detect faces at more varied angles (e.g., faces in profile).  Therefore,
    // faces that are turned too far won't be detected under fast mode.
    //
    // For front facing mode only, the detector will use the "prominent face only" setting,
    // which is optimized for tracking a single relatively large face.  This setting allows the
    // detector to take some shortcuts to make tracking faster, at the expense of not being able
    // to track multiple faces.
    //
    // Setting the minimum face size not only controls how large faces must be in order to be
    // detected, it also affects performance.  Since it takes longer to scan for smaller faces,
    // we increase the minimum face size for the rear facing mode a little bit in order to make
    // tracking faster (at the expense of missing smaller faces).  But this optimization is less
    // important for the front facing case, because when "prominent face only" is enabled, the
    // detector stops scanning for faces after it has found the first (large) face.
    FaceDetector detector = new FaceDetector.Builder(context)
            .setLandmarkType(FaceDetector.ALL_LANDMARKS)
            .setClassificationType(FaceDetector.ALL_CLASSIFICATIONS)
            .setTrackingEnabled(true)
            .setMode(FaceDetector.FAST_MODE)
            .setProminentFaceOnly(mIsFrontFacing)
            .setMinFaceSize(mIsFrontFacing ? 0.35f : 0.15f)
            .build();

    Detector.Processor<Face> processor;
    if (mIsFrontFacing) {
        // For front facing mode, a single tracker instance is used with an associated focusing
        // processor.  This configuration allows the face detector to take some shortcuts to
        // speed up detection, in that it can quit after finding a single face and can assume
        // that the nextIrisPosition face position is usually relatively close to the last seen
        // face position.
        Tracker<Face> tracker = new GooglyFaceTracker(mGraphicOverlay);
        processor = new LargestFaceFocusingProcessor.Builder(detector, tracker).build();
    } else {
        // For rear facing mode, a factory is used to create per-face tracker instances.  A
        // tracker is created for each face and is maintained as long as the same face is
        // visible, enabling per-face state to be maintained over time.  This is used to store
        // the iris position and velocity for each face independently, simulating the motion of
        // the eyes of any number of faces over time.
        //
        // Both the front facing mode and the rear facing mode use the same tracker
        // implementation, avoiding the need for any additional code.  The only difference
        // between these cases is the choice of Processor: one that is specialized for tracking
        // a single face or one that can handle multiple faces.  Here, we use MultiProcessor,
        // which is a standard component of the mobile vision API for managing multiple items.
        MultiProcessor.Factory<Face> factory = new MultiProcessor.Factory<Face>() {
            @Override
            public Tracker<Face> create(Face face) {
                return new GooglyFaceTracker(mGraphicOverlay);
            }
        };
        processor = new MultiProcessor.Builder<>(factory).build();
    }

    detector.setProcessor(processor);

    if (!detector.isOperational()) {
        // Note: The first time that an app using face API is installed on a device, GMS will
        // download a native library to the device in order to do detection.  Usually this
        // completes before the app is run for the first time.  But if that download has not yet
        // completed, then the above call will not detect any faces.
        //
        // isOperational() can be used to check if the required native library is currently
        // available.  The detector will automatically become operational once the library
        // download completes on device.
        Log.w(TAG, "Face detector dependencies are not yet available.");

        // Check for low storage.  If there is low storage, the native library will not be
        // downloaded, so detection will not become operational.
        IntentFilter lowStorageFilter = new IntentFilter(Intent.ACTION_DEVICE_STORAGE_LOW);
        boolean hasLowStorage = registerReceiver(null, lowStorageFilter) != null;

        if (hasLowStorage) {
            Toast.makeText(this, R.string.low_storage_error, Toast.LENGTH_LONG).show();
            Log.w(TAG, getString(R.string.low_storage_error));
        }
    }
    return detector;
}
 
Example #13
Source File: BarcodeTrackerFactory.java    From android-vision with Apache License 2.0 4 votes vote down vote up
@Override
public Tracker<Barcode> create(Barcode barcode) {
    BarcodeGraphic graphic = new BarcodeGraphic(mGraphicOverlay);
    return new BarcodeGraphicTracker(mGraphicOverlay, graphic, mContext);
}
 
Example #14
Source File: BarcodeTrackerFactory.java    From Bluefruit_LE_Connect_Android with MIT License 4 votes vote down vote up
@Override
public Tracker<Barcode> create(Barcode barcode) {
    BarcodeGraphic graphic = new BarcodeGraphic(mGraphicOverlay);
    return new BarcodeGraphicTracker(mGraphicOverlay, graphic, mListener);
}
 
Example #15
Source File: FaceTrackerFactory.java    From android-vision with Apache License 2.0 4 votes vote down vote up
@Override
public Tracker<Face> create(Face face) {
    FaceGraphic graphic = new FaceGraphic(mGraphicOverlay);
    return new GraphicTracker<>(mGraphicOverlay, graphic);
}
 
Example #16
Source File: FaceTrackerActivity.java    From android-vision with Apache License 2.0 4 votes vote down vote up
@Override
public Tracker<Face> create(Face face) {
    return new GraphicFaceTracker(mGraphicOverlay);
}
 
Example #17
Source File: BarcodeTrackerFactory.java    From AndroidApp with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public Tracker<Barcode> create(Barcode barcode) {
    return new BarcodeGraphicTracker(mCallback);
}
 
Example #18
Source File: BarcodeTrackerFactory.java    From flutter_barcode_scanner with MIT License 4 votes vote down vote up
@Override
public Tracker<Barcode> create(Barcode barcode) {
    BarcodeGraphic graphic = new BarcodeGraphic(mGraphicOverlay);
    return new BarcodeGraphicTracker(mGraphicOverlay, graphic, mContext);
}
 
Example #19
Source File: BarcodeTrackerFactory.java    From fuse-qreader with MIT License 4 votes vote down vote up
@Override
public Tracker<Barcode> create(Barcode barcode) {
    BarcodeGraphic graphic = new BarcodeGraphic(mGraphicOverlay);
    return new BarcodeGraphicTracker(mGraphicOverlay, graphic,mActivity);
}
 
Example #20
Source File: BarcodeTrackerFactory.java    From BarcodeReaderSample with MIT License 4 votes vote down vote up
@Override
public Tracker<Barcode> create(Barcode barcode) {
    return new BarcodeTracker(mContext);
}
 
Example #21
Source File: BarcodeTrackerFactory.java    From Barcode-Reader with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public Tracker<Barcode> create(Barcode barcode) {
    BarcodeGraphic graphic = new BarcodeGraphic(mGraphicOverlay);
    return new BarcodeGraphicTracker(mGraphicOverlay, graphic, listener);
}
 
Example #22
Source File: CodeTrackerFactory.java    From prebid-mobile-android with Apache License 2.0 4 votes vote down vote up
@Override
public Tracker<Barcode> create(Barcode barcode) {
    CodeGraphic graphic = new CodeGraphic(mGraphicOverlay);
    return new CodeGraphicTracker(mGraphicOverlay, graphic, mContext);
}
 
Example #23
Source File: MainActivity.java    From Camera2Vision with Apache License 2.0 4 votes vote down vote up
@Override
public Tracker<Face> create(Face face) {
    return new GraphicFaceTracker(mGraphicOverlay);
}
 
Example #24
Source File: FaceFilterActivity.java    From FaceFilter with MIT License 4 votes vote down vote up
@Override
public Tracker<Face> create(Face face) {
    return new GraphicFaceTracker(mGraphicOverlay);
}
 
Example #25
Source File: BarcodeTrackerFactory.java    From samples-android with Apache License 2.0 4 votes vote down vote up
@Override
public Tracker<Barcode> create(Barcode barcode) {
    BarcodeGraphic graphic = new BarcodeGraphic(mGraphicOverlay);
    return new BarcodeGraphicTracker(mGraphicOverlay, graphic, mContext);
}
 
Example #26
Source File: BarcodeTrackerFactory.java    From trust-wallet-android-source with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Tracker<Barcode> create(Barcode barcode) {
    return new BarcodeTracker(mContext);
}
 
Example #27
Source File: ARFilterActivity.java    From Machine-Learning-Projects-for-Mobile-Applications with MIT License 4 votes vote down vote up
@Override
public Tracker<Face> create(Face face) {
    return new GraphicFaceTracker(mGraphicOverlay,context,usingFrontCamera);
}
 
Example #28
Source File: FaceFilterActivity.java    From Android-face-filters with Apache License 2.0 4 votes vote down vote up
@Override
public Tracker<Face> create(Face face) {
    return new GraphicFaceTracker(mGraphicOverlay);
}
 
Example #29
Source File: FaceFilterActivity.java    From Android-face-filters with Apache License 2.0 4 votes vote down vote up
@Override
public Tracker<String> create(String face) {
    return new GraphicTextTracker(mGraphicOverlay);
}
 
Example #30
Source File: BarcodeTrackerFactory.java    From Barcode-Reader with Apache License 2.0 4 votes vote down vote up
@Override
public Tracker<Barcode> create(Barcode barcode) {
    BarcodeGraphic graphic = new BarcodeGraphic(mGraphicOverlay);
    return new BarcodeGraphicTracker(mGraphicOverlay, graphic, listener);
}