微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用CameraX保存图像时出现“错误的偏移量可能导致无限循环”错误

如何解决使用CameraX保存图像时出现“错误的偏移量可能导致无限循环”错误

有人可以帮我解决这些错误。我试图在捕获图像后保存图像,但是它不起作用,并不断给我这些关于标签为ULONG的错误,并且错误的偏移量可能会导致无限循环。我不确定错误在哪里,我使用File类错了吗?还是getExternalDirectory部分?

2020-09-22 13:52:36.684 9910-9964/com.example.cameraxapp D/CaptureSession: opening capture session.
2020-09-22 13:52:36.757 9910-9964/com.example.cameraxapp D/CaptureSession: Attempting to send capture request onConfigured
2020-09-22 13:52:36.757 9910-9964/com.example.cameraxapp D/CaptureSession: Issuing request for session.
2020-09-22 13:52:36.769 9910-9964/com.example.cameraxapp D/CaptureSession: CameraCaptureSession.onConfigured() mState=OPENED
2020-09-22 13:52:36.769 9910-9964/com.example.cameraxapp D/CaptureSession: CameraCaptureSession.onReady() OPENED
2020-09-22 13:52:37.318 9910-9963/com.example.cameraxapp D/StreamStateObserver: Update Preview stream state to STREAMING
2020-09-22 13:52:38.546 9910-9910/com.example.cameraxapp D/ImageCapture: Send image capture request [current,pending] = [0,1]
2020-09-22 13:52:38.555 9910-9963/com.example.cameraxapp D/CaptureSession: Issuing capture request.
2020-09-22 13:52:38.612 9910-9939/com.example.cameraxapp W/Gralloc3: allocator 3.x is not supported
2020-09-22 13:52:38.852 9910-9910/com.example.cameraxapp W/ExifInterface: Stop reading file since a wrong offset may cause an infinite loop: 0
2020-09-22 13:52:38.852 9910-9910/com.example.cameraxapp W/ExifInterface: Skip the tag entry since data format (ULONG) is unexpected for tag: GPSAltitudeRef
2020-09-22 13:52:38.853 9910-9910/com.example.cameraxapp W/ExifInterface: Stop reading file since a wrong offset may cause an infinite loop: 0
2020-09-22 13:52:38.853 9910-9910/com.example.cameraxapp W/ExifInterface: Stop reading file since a wrong offset may cause an infinite loop: 0
2020-09-22 13:52:38.927 9910-9946/com.example.cameraxapp D/EGL_emulation: eglMakeCurrent: 0xd380e800: ver 3 1 (tinfo 0xd3842250)

我认为它来自此函数,因为它是处理文件的地方。

//take photo function
private void takePhoto() {

    // Create time-stamped output file to hold the image
    File photoFile;
    photoFile = new File(Environment.getExternalStorageDirectory(),"IMG_${System.currentTimeMillis()}.jpg");

    // Create output options object which contains file + Metadata
    ImageCapture.OutputFileOptions outputoptions = new ImageCapture.OutputFileOptions.Builder(photoFile).build();


    imageCapture.takePicture(outputoptions,ContextCompat.getMainExecutor(this),new ImageCapture.OnImageSavedCallback () {
        @Override
        public void onImageSaved(@NonNull ImageCapture.OutputFileResults outputFileResults) {
            Toast.makeText(MainActivity.this,"Photo Capture Succeeded: "+ outputFileResults,Toast.LENGTH_SHORT).show();
        }
        @Override
        public void onError(@NonNull ImageCaptureException error) {
            Toast.makeText(MainActivity.this,"Photo capture Failed: "+ error,Toast.LENGTH_SHORT).show();
        }
    });
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。