使用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 (将#修改为@)