gpt4 book ai didi

Android Face Detection API - 存储的视频文件

转载 作者:太空宇宙 更新时间:2023-11-03 13:47:51 25 4
gpt4 key购买 nike

我想使用 Android Vision FaceDetector API 对视频文件(例如用户图库中的 MP4)执行人脸检测/跟踪。我可以看到很多关于使用 CameraSource 的例子类对直接来自相机的流执行面部跟踪(例如 on the android-vision github ),但不对视频文件执行任何操作。

我尝试通过 Android Studio 查看 CameraSource 的源代码,但它被混淆了,我无法在网上看到原始代码。我想在使用相机和使用文件之间有很多共同点。大概我只是在 Surface 上播放视频文件,然后将其传递给管道。

或者,我可以看到 Frame.Builder 具有函数 setImageDatasetTimestampMillis。如果我能够以 ByteBuffer 的形式读取视频,我该如何将其传递给 FaceDetector API?我猜 this question类似,但没有答案。同样,将视频解码为 Bitmap 帧并将其传递给 setBitmap

理想情况下,我不想将视频渲染到屏幕上,处理速度应该与 FaceDetector API 的能力一样快。

最佳答案

Alternatively I can see that Frame.Builder has functions setImageData and setTimestampMillis. If I was able to read in the video as ByteBuffer, how would I pass that to the FaceDetector API?

只需调用 SparseArray<Face> faces = detector.detect(frame);其中 detector必须这样创建:

FaceDetector detector = new FaceDetector.Builder(context)
.setProminentFaceOnly(true)
.build();

关于Android Face Detection API - 存储的视频文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39019899/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com