人脸检测成功
This commit is contained in:
@@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.google.mediapipe.examples.facelandmarker
|
package com.khronos.vulkan_samples
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
|
|||||||
@@ -3,17 +3,8 @@ package com.khronos.vulkan_samples;
|
|||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.graphics.Color;
|
|
||||||
import android.graphics.PixelFormat;
|
|
||||||
import android.graphics.SurfaceTexture;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
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 android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
@@ -21,15 +12,12 @@ import androidx.camera.core.AspectRatio;
|
|||||||
import androidx.camera.core.CameraSelector;
|
import androidx.camera.core.CameraSelector;
|
||||||
import androidx.camera.core.ImageAnalysis;
|
import androidx.camera.core.ImageAnalysis;
|
||||||
import androidx.camera.core.ImageProxy;
|
import androidx.camera.core.ImageProxy;
|
||||||
import androidx.camera.core.Preview;
|
|
||||||
import androidx.camera.core.SurfaceRequest;
|
|
||||||
import androidx.camera.lifecycle.ProcessCameraProvider;
|
import androidx.camera.lifecycle.ProcessCameraProvider;
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
import com.google.androidgamesdk.GameActivity;
|
import com.google.androidgamesdk.GameActivity;
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
import com.google.mediapipe.examples.facelandmarker.FaceLandmarkerHelper;
|
|
||||||
import com.google.mediapipe.tasks.vision.core.RunningMode;
|
import com.google.mediapipe.tasks.vision.core.RunningMode;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -51,15 +39,9 @@ public class MainActivity extends GameActivity implements FaceLandmarkerHelper.L
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void detectFace(ImageProxy imageProxy) {
|
private void detectFace(ImageProxy imageProxy) {
|
||||||
backgroundExecutor.execute(new Runnable() {
|
faceLandmarkerHelper.detectLiveStream(
|
||||||
@Override
|
imageProxy,true
|
||||||
public void run() {
|
);
|
||||||
faceLandmarkerHelper.detectLiveStream(
|
|
||||||
imageProxy,true
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -142,10 +124,10 @@ public class MainActivity extends GameActivity implements FaceLandmarkerHelper.L
|
|||||||
public void analyze(@NonNull ImageProxy image) {
|
public void analyze(@NonNull ImageProxy image) {
|
||||||
try {
|
try {
|
||||||
Log.d("Camera", "Received image: " + image.getWidth() + "x" + image.getHeight());
|
Log.d("Camera", "Received image: " + image.getWidth() + "x" + image.getHeight());
|
||||||
detectFace(image);
|
|
||||||
processImageForVulkan(image);
|
processImageForVulkan(image);
|
||||||
|
detectFace(image);
|
||||||
} finally {
|
} finally {
|
||||||
image.close(); // 确保在这里关闭
|
//image.close(); // 确保在这里关闭
|
||||||
Log.d("Camera", "Image closed, ready for next frame");
|
Log.d("Camera", "Image closed, ready for next frame");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user