Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/179.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android ObjectDetectorTask:对象检测器管道已重置:MLKIT_Android_Firebase Mlkit - Fatal编程技术网

Android ObjectDetectorTask:对象检测器管道已重置:MLKIT

Android ObjectDetectorTask:对象检测器管道已重置:MLKIT,android,firebase-mlkit,Android,Firebase Mlkit,我在android应用程序中使用Mlkit对象检测API实时检测对象。这是我的密码 private AtomicBoolean flag = new AtomicBoolean(false); private void startDetection(){ final FirebaseVisionObjectDetectorOptions options = new FirebaseVisionObjectDetectorOptions.Builder() .se

我在android应用程序中使用Mlkit对象检测API实时检测对象。这是我的密码

private AtomicBoolean flag = new AtomicBoolean(false);

private void startDetection(){
    final FirebaseVisionObjectDetectorOptions options = new FirebaseVisionObjectDetectorOptions.Builder()
            .setDetectorMode(FirebaseVisionObjectDetectorOptions.STREAM_MODE)
            .enableClassification()
            .build();
    final FirebaseVisionObjectDetector objectDetector =
            FirebaseVision.getInstance().getOnDeviceObjectDetector(options);

    timer = new Timer();
    timer.schedule(new TimerTask() {
        @SuppressLint("SetTextI18n")
        @Override
        public void run() {
            try {
                if(flag.compareAndSet(false, true)) {
                    status.setText("Processing");
                    result.setText("Starting");
                    FirebaseVisionImage image = FirebaseVisionImage.fromBitmap(textureView.getBitmap());
                    objectDetector.processImage(image)
                            .addOnSuccessListener(
                                    new OnSuccessListener<List<FirebaseVisionObject>>() {
                                        @Override
                                        public void onSuccess(List<FirebaseVisionObject> detectedObjects) {
                                            /*StringBuilder wew = new StringBuilder();

                                            for (FirebaseVisionObject obj : detectedObjects) {
                                                Integer id = obj.getTrackingId();
                                                Rect bounds = obj.getBoundingBox();

                                                // If classification was enabled:
                                                int category = obj.getClassificationCategory();
                                                Float confidence = obj.getClassificationConfidence();
                                                wew.append(category);
                                            }
                                            result.setText(wew.toString());*/
                                            result.setText(Integer.toString(detectedObjects.size()));
                                            flag.set(false);
                                        }
                                    })
                            .addOnFailureListener(
                                    new OnFailureListener() {
                                        @Override
                                        public void onFailure(@NonNull Exception e) {
                                            result.setText(e.getMessage());
                                        }
                                    });
                }
            } catch (NullPointerException e) {
                e.printStackTrace();
                result.setText(e.getMessage());
            }
        }
    },0,2000);
}
private AtomicBoolean标志=新的AtomicBoolean(false);
私有void startDetection(){
最终FirebaseVisionObjectDetectorOptions=新的FirebaseVisionObjectDetectorOptions.Builder()
.setDetectorMode(FirebaseVisionObjectDetectorOptions.STREAM_模式)
.enableClassification()
.build();
最终FirebaseVisionObjectDetector对象检测器=
FirebaseVision.getInstance().getOnDeviceObjectDetector(选项);
定时器=新定时器();
timer.schedule(新TimerTask(){
@SuppressLint(“SetTextI18n”)
@凌驾
公开募捐{
试一试{
if(flag.compareAndSet(false,true)){
status.setText(“处理”);
result.setText(“开始”);
FirebaseVisionImage=FirebaseVisionImage.fromBitmap(textureView.getBitmap());
objectDetector.processImage(图像)
.addOnSuccessListener(
新OnSuccessListener(){
@凌驾
成功时公共无效(列出检测到的对象){
/*StringBuilder wew=新的StringBuilder();
用于(FirebaseVisionObject对象:检测到的对象){
整数id=obj.getTrackingId();
Rect bounds=obj.getBoundingBox();
//如果启用了分类:
int category=obj.getClassificationCategory();
Float confidence=obj.getClassificationConfidence();
附加(类别);
}
result.setText(wew.toString())*/
result.setText(Integer.toString(detectedObjects.size());
flag.set(false);
}
})
.addOnFailureListener(
新的OnFailureListener(){
@凌驾
public void onFailure(@NonNull异常e){
result.setText(例如getMessage());
}
});
}
}捕获(NullPointerException e){
e、 printStackTrace();
result.setText(例如getMessage());
}
}
},0,2000);
}
目标检测列表是0,我从logcat得到了这个

ObjectDetectorTask:对象检测器管道已重置


为什么会发生这种情况?

对于有关android studio IDE本身的问题,请仅使用
android studio
标记。对于一般的Android编程问题,请使用
Android
标记。对于Android studio IDE本身的问题,请仅使用
Android studio
标记。有关Android编程的一般问题,请使用
Android
标记。