本文整理匯總了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());
}
}
}
}
示例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;
}
示例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);
}
}
}
示例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);
}
}
示例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();
}
});*/
}
示例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();
}
}
});
}
}
示例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();
}
}
示例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;
}
}
示例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());
}
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
示例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);
}
}
}