當前位置: 首頁>>代碼示例>>Java>>正文


Java Detector類代碼示例

本文整理匯總了Java中com.google.android.gms.vision.Detector的典型用法代碼示例。如果您正苦於以下問題:Java Detector類的具體用法?Java Detector怎麽用?Java Detector使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Detector類屬於com.google.android.gms.vision包,在下文中一共展示了Detector類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: receiveDetections

import com.google.android.gms.vision.Detector; //導入依賴的package包/類
/**
 * 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);
        if (item != null && item.getValue() != null) {
            final String wort = item.getValue();
            if(wort.length() > 1 && Character.isUpperCase(wort.charAt(0)) && wort.matches("[A-Za-z-]+") && wort.charAt(wort.length() - 1) != '-') {
                Log.d("OCR", "Name detected: " + wort);
                // Show AccountDetailActivity
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        DownloadIntentService.startService(context, OcrCaptureActivity.DOWNLOAD_REQUEST_CODE, wort);
                    }
                }).start();
            } else {
                Log.d("OcrDetectorProcessor", "Text detected! " + item.getValue());
            }
        }
    }
}
 
開發者ID:Jugendhackt,項目名稱:SocialPaka,代碼行數:31,代碼來源:OcrDetectorProcessor.java

示例2: filterInvalidDetections

import com.google.android.gms.vision.Detector; //導入依賴的package包/類
private List<Text> filterInvalidDetections(Detector.Detections<TextBlock> items) {
    List<Text> result = new ArrayList<>();
    SparseArray<TextBlock> detectedItems = items.getDetectedItems();

    for (int i = 0; i < detectedItems.size(); ++i) {
        TextBlock textBlock = detectedItems.valueAt(i);

        // Get sub-components and extract only lines
        List<? extends Text> components = textBlock.getComponents();

        for (Text component : components) {
            String value = component.getValue();
            if (component instanceof Line
                    && value != null
                    && !value.isEmpty()
                    && isFoodRelated((value))) {
                result.add(component);
            } else {
                Log.d(TAG, "filterInvalidDetections: sub-component is not a Line, should we go deeper?");
            }
        }
    }
    return result;
}
 
開發者ID:dvdciri,項目名稱:DeepImagePreview-Project,代碼行數:25,代碼來源:OcrDetectorProcessor.java

示例3: onUpdate

import com.google.android.gms.vision.Detector; //導入依賴的package包/類
/**
 * 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);
        }
    }
}
 
開發者ID:ravi8x,項目名稱:Barcode-Reader,代碼行數:19,代碼來源:BarcodeGraphicTracker.java

示例4: receiveDetections

import com.google.android.gms.vision.Detector; //導入依賴的package包/類
/**
 * 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);
        if (item != null && item.getValue() != null) {
            if (item.getValue().contains("INSTITUTO FEDERAL ELECTORAL")) {
                documentIdentifier.setType(Constants.IFEB);
            } else if (item.getValue().contains("INSTITUTO NACIONAL ELECTORAL")) {
                Log.d("OcrDetectorProcessor", "INE E " + item.getValue());
                documentIdentifier.setType(Constants.IFEE);
            }
        }
        //OcrGraphic graphic = new OcrGraphic(mGraphicOverlay, item);
        //mGraphicOverlay.add(graphic);
    }
}
 
開發者ID:BrandonVargas,項目名稱:AndroidOCRFforID,代碼行數:26,代碼來源:OcrDetectorProcessor.java

示例5: receiveDetections

import com.google.android.gms.vision.Detector; //導入依賴的package包/類
/**
 * 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();
    //final String result;
    //String detectedText = "";
    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();
    }

    /*result = detectedText;
    ((OcrCaptureActivity)context).runOnUiThread(new Runnable() {
        @Override
        public void run() {
            Toast.makeText(context, result, Toast.LENGTH_SHORT).show();
        }
    });*/
}
 
開發者ID:volkansahin45,項目名稱:Moneycim,代碼行數:30,代碼來源:OcrDetectorProcessor.java

示例6: receiveDetections

import com.google.android.gms.vision.Detector; //導入依賴的package包/類
@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();
                }
            }
        });

    }
}
 
開發者ID:MobileTribe,項目名稱:pandroid,代碼行數:17,代碼來源:PandroidScannerView.java

示例7: setDetector

import com.google.android.gms.vision.Detector; //導入依賴的package包/類
public void setDetector(){
    FaceDetector detector = new FaceDetector.Builder(this)
            .setTrackingEnabled(true)
            .setLandmarkType(FaceDetector.ALL_LANDMARKS)
            .setMode(FaceDetector.ACCURATE_MODE)
            .build();


    Detector<Face> safeDetector = new SafeFaceDetector(detector);

    if (!safeDetector.isOperational()) {
        Toast.makeText(this, "Detector are having issues", Toast.LENGTH_LONG).show();
    } else {
        Frame frame = new Frame.Builder().setBitmap(mbitmap).build();
        mFaces = safeDetector.detect(frame);
        safeDetector.release();
    }

}
 
開發者ID:doomers,項目名稱:FaceDoSwip,代碼行數:20,代碼來源:MainActivity.java

示例8: selectFocus

import com.google.android.gms.vision.Detector; //導入依賴的package包/類
@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;
    }
}
 
開發者ID:Credntia,項目名稱:CVScanner,代碼行數:22,代碼來源:DocumentProcessor.java

示例9: receiveDetections

import com.google.android.gms.vision.Detector; //導入依賴的package包/類
@Override
public void receiveDetections(Detector.Detections<TextBlock> detections) {
    SparseArray<TextBlock> items = detections.getDetectedItems();
    for (int i = 0; i < items.size(); ++i) {
        TextBlock item = items.valueAt(i);
        if (item != null && item.getValue() != null) {
            Log.d("Processor", "Text detected! " + item.getValue());
        }
    }
}
 
開發者ID:zackszhu,項目名稱:hack_sjtu_2017,代碼行數:11,代碼來源:OCRActivity.java

示例10: Builder

import com.google.android.gms.vision.Detector; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:Jugendhackt,項目名稱:SocialPaka,代碼行數:16,代碼來源:CameraSource.java

示例11: receiveDetections

import com.google.android.gms.vision.Detector; //導入依賴的package包/類
/**
 * 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);
    }
}
 
開發者ID:DevipriyaSarkar,項目名稱:OCR-Reader,代碼行數:18,代碼來源:OcrDetectorProcessor.java

示例12: Builder

import com.google.android.gms.vision.Detector; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:EzequielAdrianM,項目名稱:Camera2Vision,代碼行數:17,代碼來源:CameraSource.java

示例13: receiveDetections

import com.google.android.gms.vision.Detector; //導入依賴的package包/類
/**
 * 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();
    final SparseArray<TextBlock> items = detections.getDetectedItems();
    for (int i = 0; i < items.size(); ++i) {
        TextBlock item = items.valueAt(i);
        if (item != null && item.getValue() != null) {
            Log.d("OcrDetectorProcessor", "Text detected! " + item.getValue());
        }
        OcrGraphic graphic = new OcrGraphic(mGraphicOverlay, item);
        mGraphicOverlay.add(graphic);
    }

}
 
開發者ID:OlayinkaPeter,項目名稱:Toodoo,代碼行數:22,代碼來源:OcrDetectorProcessor.java

示例14: onUpdate

import com.google.android.gms.vision.Detector; //導入依賴的package包/類
/**
 * 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);
}
 
開發者ID:Emrals,項目名稱:Fuse,代碼行數:10,代碼來源:BarcodeGraphicTracker.java

示例15: replaceBarcodeDetector

import com.google.android.gms.vision.Detector; //導入依賴的package包/類
@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);
        }
    }
}
 
開發者ID:ekreutz,項目名稱:react-native-barcode-scanner-google,代碼行數:12,代碼來源:CameraSourcePreview.java


注:本文中的com.google.android.gms.vision.Detector類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。