package com.kofax.mobile.sdk.t; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.os.Environment; import com.kofax.android.abc.document.Document; import com.kofax.android.abc.vrs.VrsImage; import com.kofax.mobile.commonextractionengine.LogConfig; import com.kofax.mobile.commonextractionengine.recognition.TextRecognizer; import com.kofax.mobile.sdk._internal.extraction.id.i; import java.io.File; import java.io.IOException; import o.C15191gjl; /* loaded from: classes3.dex */ class c extends com.kofax.mobile.sdk._internal.impl.extraction.onDevice.e { private final d NC; private final a NE; private e NF; /* JADX INFO: Access modifiers changed from: package-private */ public c(Context context, com.kofax.mobile.sdk.b.c cVar, i iVar, d dVar, e eVar) { super(context, cVar, iVar); this.NE = new a(); this.NC = dVar; this.NF = eVar; } @Override // com.kofax.mobile.sdk._internal.impl.extraction.onDevice.e public Document a(TextRecognizer textRecognizer, VrsImage vrsImage) { this.NE.os(); com.kofax.mobile.sdk.am.b bVar = new com.kofax.mobile.sdk.am.b(); try { Document f = bVar.f(super.a(textRecognizer, vrsImage)); if (this.NE.av("evrs_ops_phase1.txt")) { this.NC.B(this.NE.aw("evrs_ops_phase1.txt"), "p1_evrs_operations"); Bitmap o2 = bVar.o(this.NE.ax("evrs_image_phase1.jpg")); this.NC.a(o2, "p1_evrs_result"); String aw = this.NE.aw("evrs_results_phase1.txt"); this.NC.e(aw, "p1_evrs_metadata", "json"); this.NC.a(bVar.o(this.NF.b(o2, aw)), "p1_evrs_words"); this.NC.a(bVar.o(this.NF.b(o2, f.getFields())), "p1_evrs_fields"); } if (this.NE.av("tesseract_image_phase1.jpg")) { Bitmap o3 = bVar.o(this.NE.ax("tesseract_image_phase1.jpg")); this.NC.a(o3, "p1_tess_result"); this.NC.a(bVar.o(this.NF.a(o3, f.getElements())), "p1_tess_words"); this.NC.a(bVar.o(this.NF.c(o3, f.getElements())), "p1_tess_values"); } return (Document) bVar.f((com.kofax.mobile.sdk.am.b) f); } finally { bVar.dispose(); } } @Override // com.kofax.mobile.sdk._internal.impl.extraction.onDevice.e public Document a(TextRecognizer textRecognizer, VrsImage vrsImage, Document document) { com.kofax.mobile.sdk.am.b bVar = new com.kofax.mobile.sdk.am.b(); try { if (this.NE.av("tesseract_image_phase1.jpg")) { Bitmap o2 = bVar.o(this.NE.ax("tesseract_image_phase1.jpg")); this.NC.a(bVar.o(this.NF.b(o2, document.getFields())), "p1_tess_fields"); this.NC.a(bVar.o(this.NF.d(o2, document.getFields())), "p1_tess_values"); } Document f = bVar.f(super.a(textRecognizer, vrsImage, document)); if (this.NE.av("evrs_ops_phase2.txt")) { this.NC.B(this.NE.aw("evrs_ops_phase2.txt"), "p2_evrs_operations"); Bitmap o3 = bVar.o(this.NE.ax("evrs_image_phase2.jpg")); this.NC.a(o3, "p2_evrs_result"); String aw = this.NE.aw("evrs_results_phase2.txt"); this.NC.e(aw, "p2_evrs_metadata", "json"); this.NC.a(bVar.o(this.NF.b(o3, aw)), "p2_evrs_words"); this.NC.a(bVar.o(this.NF.b(o3, f.getFields())), "p2_evrs_fields"); this.NC.a(bVar.o(this.NF.d(o3, f.getFields())), "p2_evrs_values"); } if (this.NE.av("tesseract_image_phase2.jpg")) { Bitmap o4 = bVar.o(this.NE.ax("tesseract_image_phase2.jpg")); this.NC.a(o4, "p2_tess_result"); this.NC.a(bVar.o(this.NF.b(o4, f.getFields())), "p2_tess_fields"); this.NC.a(bVar.o(this.NF.d(o4, f.getFields())), "p2_tess_values"); } return (Document) bVar.f((com.kofax.mobile.sdk.am.b) f); } finally { bVar.dispose(); } } /* loaded from: classes3.dex */ static class a { private static final File NG = new File(Environment.getExternalStorageDirectory(), "com.kofax.mobile.sdk/cee/dump"); a() { LogConfig.setLogEnabled(true); File file = NG; if (file.exists() || file.mkdirs()) { LogConfig.setDumpDir(file.getPath()); LogConfig.setEvrsDumpEnabled(true); LogConfig.setTesseractDumpEnabled(true); } else { StringBuilder sb = new StringBuilder("Unable to create directory '"); sb.append(file); sb.append("'"); throw new RuntimeException(new IOException(sb.toString())); } } boolean av(String str) { return ay(str).exists(); } String aw(String str) { try { return C15191gjl.b(ay(str), "UTF-8"); } catch (IOException e) { throw new RuntimeException(e); } } Bitmap ax(String str) { return BitmapFactory.decodeFile(ay(str).getAbsolutePath()); } File ay(String str) { return new File(NG, str); } void os() { try { C15191gjl.a(NG); } catch (IOException e) { throw new RuntimeException(e); } } } }