150 lines
5.7 KiB
Java
150 lines
5.7 KiB
Java
|
package com.kofax.kmc.ken.engines;
|
||
|
|
||
|
import android.graphics.Point;
|
||
|
import android.graphics.Rect;
|
||
|
import com.kofax.kmc.ken.engines.data.BoundingTetragon;
|
||
|
import com.kofax.kmc.ken.engines.data.DetectionSettings;
|
||
|
import com.kofax.kmc.ken.engines.data.HorizontalGuidance;
|
||
|
import com.kofax.kmc.ken.engines.data.TurnGuidance;
|
||
|
import com.kofax.kmc.ken.engines.data.VerticalGuidance;
|
||
|
import com.kofax.kmc.ken.engines.data.ZoomGuidance;
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* loaded from: classes3.dex */
|
||
|
public class b implements g {
|
||
|
private static final float F = 0.01f;
|
||
|
private static final String TAG = "b";
|
||
|
private final INativeGuidance G;
|
||
|
private final DetectionSettings H;
|
||
|
private final Rect I;
|
||
|
private final BoundingTetragon J;
|
||
|
private final boolean K;
|
||
|
private ZoomGuidance L;
|
||
|
private TurnGuidance M;
|
||
|
private HorizontalGuidance N;
|
||
|
private VerticalGuidance O;
|
||
|
private final int _height;
|
||
|
private final int _width;
|
||
|
|
||
|
public b(INativeGuidance iNativeGuidance, DetectionSettings detectionSettings, Rect rect) {
|
||
|
this(iNativeGuidance, detectionSettings, rect, 0, 0, null, false);
|
||
|
}
|
||
|
|
||
|
public b(INativeGuidance iNativeGuidance, DetectionSettings detectionSettings, Rect rect, int i, int i2, BoundingTetragon boundingTetragon, boolean z) {
|
||
|
this.G = iNativeGuidance;
|
||
|
this.H = detectionSettings;
|
||
|
this.I = rect;
|
||
|
this.L = g();
|
||
|
this.M = h();
|
||
|
this.N = i();
|
||
|
this.O = j();
|
||
|
this._width = i;
|
||
|
this._height = i2;
|
||
|
this.J = boundingTetragon;
|
||
|
this.K = z;
|
||
|
}
|
||
|
|
||
|
public ZoomGuidance e() {
|
||
|
ZoomGuidance zoomGuidance = this.L;
|
||
|
if (zoomGuidance != ZoomGuidance.ZOOM_OK || this.N != HorizontalGuidance.HORIZONTAL_MOVE_OK || this.O != VerticalGuidance.VERTICAL_MOVE_OK) {
|
||
|
return zoomGuidance;
|
||
|
}
|
||
|
if (this.K && !f()) {
|
||
|
return zoomGuidance;
|
||
|
}
|
||
|
com.kofax.mobile.sdk._internal.k.a(TAG, "ZOOM_OUT guidance: not all edges of document are within image");
|
||
|
return ZoomGuidance.ZOOM_OUT;
|
||
|
}
|
||
|
|
||
|
private boolean f() {
|
||
|
float min = Math.min(this._width * F, this._height * F);
|
||
|
float f = this._width - min;
|
||
|
float f2 = this._height - min;
|
||
|
Point bottomLeft = this.J.getBottomLeft();
|
||
|
Point topLeft = this.J.getTopLeft();
|
||
|
Point topRight = this.J.getTopRight();
|
||
|
Point bottomRight = this.J.getBottomRight();
|
||
|
return ((float) bottomLeft.x) < min || ((float) bottomLeft.x) > f || ((float) bottomLeft.y) < min || ((float) bottomLeft.y) > f2 || ((float) topLeft.x) < min || ((float) topLeft.x) > f || ((float) topLeft.y) < min || ((float) topLeft.y) > f2 || ((float) topRight.x) < min || ((float) topRight.x) > f || ((float) topRight.y) < min || ((float) topRight.y) > f2 || ((float) bottomRight.x) < min || ((float) bottomRight.x) > f || ((float) bottomRight.y) < min || ((float) bottomRight.y) > f2;
|
||
|
}
|
||
|
|
||
|
private ZoomGuidance g() {
|
||
|
INativeGuidance iNativeGuidance = this.G;
|
||
|
if (iNativeGuidance != null) {
|
||
|
double zoomGuidance = iNativeGuidance.getZoomGuidance(this.I, this.H.getMinFillFraction(), this.H.getMaxFillFraction());
|
||
|
if (zoomGuidance < 0.0d) {
|
||
|
this.L = ZoomGuidance.ZOOM_IN;
|
||
|
} else if (zoomGuidance > 0.0d) {
|
||
|
this.L = ZoomGuidance.ZOOM_OUT;
|
||
|
} else {
|
||
|
this.L = ZoomGuidance.ZOOM_OK;
|
||
|
}
|
||
|
}
|
||
|
return this.L;
|
||
|
}
|
||
|
|
||
|
private TurnGuidance h() {
|
||
|
INativeGuidance iNativeGuidance = this.G;
|
||
|
if (iNativeGuidance != null) {
|
||
|
double turnGuidance = iNativeGuidance.getTurnGuidance(this.H.getMaxSkewAngle());
|
||
|
if (turnGuidance < 0.0d) {
|
||
|
this.M = TurnGuidance.TURN_CLOCKWISE;
|
||
|
} else if (turnGuidance > 0.0d) {
|
||
|
this.M = TurnGuidance.TURN_COUNTER_CLOCKWISE;
|
||
|
} else {
|
||
|
this.M = TurnGuidance.TURN_OK;
|
||
|
}
|
||
|
}
|
||
|
return this.M;
|
||
|
}
|
||
|
|
||
|
private HorizontalGuidance i() {
|
||
|
INativeGuidance iNativeGuidance = this.G;
|
||
|
if (iNativeGuidance != null) {
|
||
|
double horizontalMovementGuidance = iNativeGuidance.getHorizontalMovementGuidance(this.I, this.H.getToleranceFraction());
|
||
|
if (horizontalMovementGuidance < 0.0d) {
|
||
|
this.N = HorizontalGuidance.HORIZONTAL_MOVE_LEFT;
|
||
|
} else if (horizontalMovementGuidance > 0.0d) {
|
||
|
this.N = HorizontalGuidance.HORIZONTAL_MOVE_RIGHT;
|
||
|
} else {
|
||
|
this.N = HorizontalGuidance.HORIZONTAL_MOVE_OK;
|
||
|
}
|
||
|
}
|
||
|
return this.N;
|
||
|
}
|
||
|
|
||
|
private VerticalGuidance j() {
|
||
|
INativeGuidance iNativeGuidance = this.G;
|
||
|
if (iNativeGuidance != null) {
|
||
|
double verticalMovementGuidance = iNativeGuidance.getVerticalMovementGuidance(this.I, this.H.getToleranceFraction());
|
||
|
if (verticalMovementGuidance < 0.0d) {
|
||
|
this.O = VerticalGuidance.VERTICAL_MOVE_UP;
|
||
|
} else if (verticalMovementGuidance > 0.0d) {
|
||
|
this.O = VerticalGuidance.VERTICAL_MOVE_DOWN;
|
||
|
} else {
|
||
|
this.O = VerticalGuidance.VERTICAL_MOVE_OK;
|
||
|
}
|
||
|
}
|
||
|
return this.O;
|
||
|
}
|
||
|
|
||
|
@Override // com.kofax.kmc.ken.engines.g
|
||
|
public ZoomGuidance getZoomGuidance() {
|
||
|
return this.L;
|
||
|
}
|
||
|
|
||
|
@Override // com.kofax.kmc.ken.engines.g
|
||
|
public VerticalGuidance getVerticalMovementGuidance() {
|
||
|
return this.O;
|
||
|
}
|
||
|
|
||
|
@Override // com.kofax.kmc.ken.engines.g
|
||
|
public TurnGuidance getTurnGuidance() {
|
||
|
return this.M;
|
||
|
}
|
||
|
|
||
|
@Override // com.kofax.kmc.ken.engines.g
|
||
|
public HorizontalGuidance getHorizontalMovementGuidance() {
|
||
|
return this.N;
|
||
|
}
|
||
|
}
|