本文整理匯總了Java中com.google.android.gms.vision.Detector.Detections方法的典型用法代碼示例。如果您正苦於以下問題:Java Detector.Detections方法的具體用法?Java Detector.Detections怎麽用?Java Detector.Detections使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.android.gms.vision.Detector
的用法示例。
在下文中一共展示了Detector.Detections方法的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: 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());
}
}
}
示例8: 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);
}
}
示例9: 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);
}
}
示例10: 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);
}
示例11: receiveDetections
import com.google.android.gms.vision.Detector; //導入方法依賴的package包/類
@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);
}
}
示例12: onUpdate
import com.google.android.gms.vision.Detector; //導入方法依賴的package包/類
@Override
public void onUpdate(Detector.Detections<Face> detectionResults, Face face) {
//Add the face
if (face != null) {
mOverlay.add(mFaceGraphic);
mFaceGraphic.updateFace(face);
}
//Check num faces
int x = detectionResults.getDetectedItems().size();
updateFaces(x);
}
示例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();
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: receiveDetections
import com.google.android.gms.vision.Detector; //導入方法依賴的package包/類
@Override
public void receiveDetections(Detector.Detections<Barcode> detections) {
SparseArray<Barcode> barcodes = detections.getDetectedItems();
if (barcodes.size() > 0) {
//return first barcode
Intent data = new Intent();
data.putExtra(BarcodeObject, barcodes.valueAt(0));
setResult(CommonStatusCodes.SUCCESS, data);
finish();
}
}
示例15: 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 (mListener != null) {
mListener.onCodeScanned(item.rawValue);
}
}