Я пытаюсь запустить свой проект из Android Studio, но я получаю ошибку java.lang.RuntimeException
при выполнении doInBackground()
, и приложение остановлено. Я видел много вопросов по этому поводу, но он не работал.
Вот мой код:
import...
public class LicensePlateProcessorAsync extends AsyncTask < LicensePlateProcessorParameter, String, Object > {
private static final String TAG = "LPRWorker";
private LicensePlateProcessorCallback listener;
private Object HandlerThread;
private Object LicensePlateProcessorParameter;
private Object String;
private java.lang.Object Object;
public LicensePlateProcessorAsync(LicensePlateProcessorCallback listener) {
this.listener = listener;
}
protected Object doInBackground(LicensePlateProcessorParameter...params) {
LicensePlateProcessorParameter param = params[0];
String path = param.getPath();
float fResizeRatio = param.getResizeRatio();
PreviewMode previewMode = param.getPreviewMode();
int iMedianBlurKernelSize = param.getMedianBlurKernelSize();
int iLineLength = param.getLineLength();
publishProgress("Loading file");
Mat mImage = null;
try {
ExifInterface exif = new ExifInterface(path);
int rotationCode = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
int rotationDegrees = 0;
if (rotationCode == ExifInterface.ORIENTATION_ROTATE_90) {
rotationDegrees = 90;
} else if (rotationCode == ExifInterface.ORIENTATION_ROTATE_180) {
rotationDegrees = 180;
} else if (rotationCode == ExifInterface.ORIENTATION_ROTATE_270) {
rotationDegrees = 270;
}
Matrix matrix = new Matrix();
if (rotationDegrees != 0) {
matrix.preRotate(rotationDegrees);
}
BitmapFactory.Options bmOptions = new BitmapFactory.Options();
bmOptions.inJustDecodeBounds = false;
Bitmap bitmapTmp = BitmapFactory.decodeFile(path, bmOptions);
Bitmap bitmap;
bitmap = Bitmap.createBitmap(
bitmapTmp, 0, 0,
bitmapTmp.getWidth(),
bitmapTmp.getHeight(),
matrix,
true);
mImage = new Mat();
Utils.bitmapToMat(bitmap, mImage);
bitmap.recycle();
} catch (IOException e) {
e.printStackTrace();
}
И ошибка:
java.lang.RuntimeException: An error occured
while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java: 299)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java: 352)
at java.util.concurrent.FutureTask.setException(FutureTask.java: 219)
at java.util.concurrent.FutureTask.run(FutureTask.java: 239)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java: 230)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java: 1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java: 573)
at java.lang.Thread.run(Thread.java: 856)
Caused by: java.lang.NullPointerException
at com.mhd_deeb.lprsvu.lpr_sit.LicensePlateProcessorAsync.doInBackground(LicensePlateProcessorAsync.java: 73)
at com.mhd_deeb.lprsvu.lpr_sit.LicensePlateProcessorAsync.doInBackground(LicensePlateProcessorAsync.java: 29)