79 lines
3.7 KiB
Java
79 lines
3.7 KiB
Java
|
package com.google.android.gms.vision.face;
|
||
|
|
||
|
import android.content.Context;
|
||
|
import android.os.RemoteException;
|
||
|
import android.os.SystemClock;
|
||
|
import com.google.android.gms.dynamic.IObjectWrapper;
|
||
|
import com.google.android.gms.dynamic.ObjectWrapper;
|
||
|
import com.google.android.gms.internal.vision.zzl;
|
||
|
import com.google.android.gms.internal.vision.zzn;
|
||
|
import com.google.android.gms.vision.clearcut.DynamiteClearcutLogger;
|
||
|
import com.google.android.gms.vision.face.internal.client.FaceParcel;
|
||
|
import com.google.android.gms.vision.face.internal.client.zze;
|
||
|
import com.google.android.gms.vision.face.internal.client.zzh;
|
||
|
import java.io.File;
|
||
|
import java.nio.ByteBuffer;
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
public class NativeFaceDetectorImpl extends zzh {
|
||
|
private final Context mContext;
|
||
|
private final ByteBuffer zzcq;
|
||
|
private final DynamiteClearcutLogger zzcr;
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public NativeFaceDetectorImpl(Context context, DynamiteClearcutLogger dynamiteClearcutLogger, File file, zze zzeVar) {
|
||
|
this.zzcq = initDetectorJni(NativeFaceSettings.zzc(zzeVar), new File(file, "models").toString());
|
||
|
this.mContext = context;
|
||
|
this.zzcr = dynamiteClearcutLogger;
|
||
|
}
|
||
|
|
||
|
private static native FaceParcel[] detectFacesJni(ByteBuffer byteBuffer, ByteBuffer byteBuffer2, int i, int i2, int i3);
|
||
|
|
||
|
private static native FaceParcel[] detectFacesJni(ByteBuffer byteBuffer, byte[] bArr, int i, int i2, int i3);
|
||
|
|
||
|
private static native void finalizeDetectorJni(ByteBuffer byteBuffer);
|
||
|
|
||
|
private static native ByteBuffer initDetectorJni(NativeFaceSettings nativeFaceSettings, String str);
|
||
|
|
||
|
private static native boolean trackSingleFaceJni(ByteBuffer byteBuffer, int i);
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public static native boolean validateModelFilesJni(NativeFaceSettings nativeFaceSettings, String str);
|
||
|
|
||
|
@Override // com.google.android.gms.vision.face.internal.client.zzg
|
||
|
public final void zzn() throws RemoteException {
|
||
|
finalizeDetectorJni(this.zzcq);
|
||
|
}
|
||
|
|
||
|
@Override // com.google.android.gms.vision.face.internal.client.zzg
|
||
|
public final FaceParcel[] zzc(IObjectWrapper iObjectWrapper, zzn zznVar) throws RemoteException {
|
||
|
FaceParcel[] detectFacesJni;
|
||
|
long elapsedRealtime = SystemClock.elapsedRealtime();
|
||
|
try {
|
||
|
ByteBuffer byteBuffer = (ByteBuffer) ObjectWrapper.unwrap(iObjectWrapper);
|
||
|
if (byteBuffer.isDirect()) {
|
||
|
detectFacesJni = detectFacesJni(this.zzcq, byteBuffer, zznVar.width, zznVar.height, zznVar.rotation);
|
||
|
} else if (byteBuffer.hasArray() && byteBuffer.arrayOffset() == 0) {
|
||
|
detectFacesJni = detectFacesJni(this.zzcq, byteBuffer.array(), zznVar.width, zznVar.height, zznVar.rotation);
|
||
|
} else {
|
||
|
byte[] bArr = new byte[zznVar.width * zznVar.height];
|
||
|
byteBuffer.get(bArr);
|
||
|
detectFacesJni = detectFacesJni(this.zzcq, bArr, zznVar.width, zznVar.height, zznVar.rotation);
|
||
|
}
|
||
|
DynamiteClearcutLogger dynamiteClearcutLogger = this.zzcr;
|
||
|
long elapsedRealtime2 = SystemClock.elapsedRealtime();
|
||
|
if (zznVar.id <= 2 || detectFacesJni.length != 0) {
|
||
|
dynamiteClearcutLogger.zza(3, zzl.zza(zznVar, detectFacesJni, null, elapsedRealtime2 - elapsedRealtime));
|
||
|
}
|
||
|
return detectFacesJni;
|
||
|
} catch (Exception unused) {
|
||
|
return new FaceParcel[0];
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // com.google.android.gms.vision.face.internal.client.zzg
|
||
|
public final boolean zzd(int i) throws RemoteException {
|
||
|
return trackSingleFaceJni(this.zzcq, i);
|
||
|
}
|
||
|
}
|