人脸检测成功

This commit is contained in:
xsl
2025-09-17 10:28:47 +08:00
parent 541b610c87
commit 64ebe51ea4
2 changed files with 6 additions and 24 deletions
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.mediapipe.examples.facelandmarker
package com.khronos.vulkan_samples
import android.content.Context
import android.graphics.Bitmap
@@ -3,17 +3,8 @@ package com.khronos.vulkan_samples;
import android.Manifest;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.graphics.PixelFormat;
import android.graphics.SurfaceTexture;
import android.os.Bundle;
import android.util.Log;
import android.view.Surface;
import android.view.SurfaceView;
import android.view.TextureView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.Toast;
import androidx.annotation.NonNull;
@@ -21,15 +12,12 @@ import androidx.camera.core.AspectRatio;
import androidx.camera.core.CameraSelector;
import androidx.camera.core.ImageAnalysis;
import androidx.camera.core.ImageProxy;
import androidx.camera.core.Preview;
import androidx.camera.core.SurfaceRequest;
import androidx.camera.lifecycle.ProcessCameraProvider;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import com.google.androidgamesdk.GameActivity;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.mediapipe.examples.facelandmarker.FaceLandmarkerHelper;
import com.google.mediapipe.tasks.vision.core.RunningMode;
import org.jetbrains.annotations.NotNull;
@@ -51,15 +39,9 @@ public class MainActivity extends GameActivity implements FaceLandmarkerHelper.L
}
private void detectFace(ImageProxy imageProxy) {
backgroundExecutor.execute(new Runnable() {
@Override
public void run() {
faceLandmarkerHelper.detectLiveStream(
imageProxy,true
);
}
});
faceLandmarkerHelper.detectLiveStream(
imageProxy,true
);
}
@@ -142,10 +124,10 @@ public class MainActivity extends GameActivity implements FaceLandmarkerHelper.L
public void analyze(@NonNull ImageProxy image) {
try {
Log.d("Camera", "Received image: " + image.getWidth() + "x" + image.getHeight());
detectFace(image);
processImageForVulkan(image);
detectFace(image);
} finally {
image.close(); // 确保在这里关闭
//image.close(); // 确保在这里关闭
Log.d("Camera", "Image closed, ready for next frame");
}
}