what-the-bank/sources/com/kofax/kmc/ken/engines/GpuDocumentDetector.java

71 lines
3.3 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.kofax.kmc.ken.engines;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Point;
import com.kofax.kmc.ken.engines.data.DocumentDetectionResult;
import com.kofax.kmc.ken.engines.data.DocumentDetectionSettings;
import com.kofax.kmc.ken.engines.gpu.BitmapGPUFrame;
import com.kofax.kmc.ken.engines.gpu.CaptureGuidance;
import com.kofax.kmc.ken.engines.gpu.DataGPUFrame;
import com.kofax.kmc.ken.engines.gpu.GPUFrame;
import com.kofax.kmc.ken.engines.gpu.GPUStrategyEdgeDetection;
import com.kofax.kmc.ken.engines.gpu.OpenGLESContextManager;
import com.kofax.kmc.kut.utilities.RectUtil;
import com.kofax.kmc.kut.utilities.error.ErrorInfo;
import com.kofax.kmc.kut.utilities.error.KmcRuntimeException;
import com.kofax.mobile.sdk._internal.impl.detection.Frame;
import java.util.Arrays;
import o.InterfaceC13390fZB;
import o.InterfaceC13391fZD;
/* loaded from: classes3.dex */
public class GpuDocumentDetector implements IDocumentDetector<DocumentDetectionSettings, DocumentDetectionResult> {
private final IBoundingRectCalculator T;
private final IOrientationGuidanceCalculator ae;
private final GPUStrategyEdgeDetection af;
@InterfaceC13391fZD
public GpuDocumentDetector(Context context, @InterfaceC13390fZB(a = "COMBINED_STRATEGY") GPUStrategyEdgeDetection gPUStrategyEdgeDetection) {
a aVar = new a();
this.T = aVar;
this.ae = new l(aVar);
if (context == null) {
throw new KmcRuntimeException(ErrorInfo.KMC_GN_BAD_APPLICATION_CONTEXT);
}
this.af = gPUStrategyEdgeDetection;
}
@Override // com.kofax.kmc.ken.engines.IDocumentDetector
public void destroy() {
this.af.destroy();
}
@Override // com.kofax.kmc.ken.engines.IDocumentDetector
public DocumentDetectionResult detect(DocumentDetectionSettings documentDetectionSettings, Bitmap bitmap) {
return a(documentDetectionSettings, new BitmapGPUFrame(bitmap));
}
@Override // com.kofax.kmc.ken.engines.IDocumentDetector
public DocumentDetectionResult detect(DocumentDetectionSettings documentDetectionSettings, byte[] bArr, int i, int i2) {
return a(documentDetectionSettings, new DataGPUFrame(bArr, 17, i, i2));
}
private c a(DocumentDetectionSettings documentDetectionSettings, GPUFrame gPUFrame) {
gPUFrame.setMaxTextureSize(OpenGLESContextManager.getMaxTextureSize());
float[] passTo = gPUFrame.passTo(documentDetectionSettings, this.af);
if (passTo != null) {
return a(documentDetectionSettings, passTo, gPUFrame);
}
return null;
}
private c a(DocumentDetectionSettings documentDetectionSettings, float[] fArr, Frame frame) {
return new c(RectUtil.createTargetRect(documentDetectionSettings.getTargetFramePaddingPercent(), documentDetectionSettings.getTargetFrameAspectRatio(), documentDetectionSettings.getCenterPoint(), frame.getWidth(), frame.getHeight()), Arrays.asList(new Point((int) fArr[0], (int) fArr[1]), new Point((int) fArr[2], (int) fArr[3]), new Point((int) fArr[4], (int) fArr[5]), new Point((int) fArr[6], (int) fArr[7])), frame, new f(new CaptureGuidance(fArr)), documentDetectionSettings, this.T, this.ae);
}
public Bitmap getBitmap(int i) {
return this.af.getBitmap(i);
}
}