Google Mobile Vision: Poor FaceDetector performance without CameraSource

别等时光非礼了梦想. 提交于 2019-12-01 12:31:05

Having detection take 2-3 seconds isn't typical. Using CameraSource isn't necessary to get the best performance What hardware are you using? Can you provide more specifics?

Some aspects of face detection are speed vs. accuracy trade-offs.

Speed:

  1. Try using lower resolution images, if possible. Face detection should work fine at 640x480, for example. The face detector code does downsample large images before running detection, although this take additional time in comparison to receiving a lower resolution original.

  2. Using ByteBuffers rather than Bitmaps will be a bit faster. The first portion of this should be just a grayscale image (no color info).

  3. As you noted above, disabling landmarks and classification will make it faster.

  4. In a future release, there will be a "min face size" option. Setting the min size higher makes the face detection faster (at the accuracy trade-off of not detecting smaller faces).

  5. Setting the mode to "fast" will make it faster (at the accuracy trade-off of not detecting non-frontal faces).

  6. Using the "prominent face only" option will be faster, but it only detects a single large face (at least 35% the width of the image).

Accuracy:

  1. Enabling landmarks will allow the pose angles to be computed more accurately.

  2. Setting the mode to "accurate" will detect faces at a wider range of angles (e.g., faces in profile). However, this takes more time.

  3. Lacking the "min face size" option mentioned above, only faces larger than 10% the width of the image are detected by default. Smaller faces will not be detected. Changing this setting in the future will help to detect smaller faces. However, note that detecting smaller faces takes longer.

  4. Using a higher resolution image will be more accurate than a lower resolution image. For example, some faces in a 320x240 image might be missed that would have been detected if the image were 640x480. The lower the "min face size" you set, the higher the resolution you need to detect faces of that size.

  5. Make sure that you have the rotation right. The face won't be detected if it is upside down, for example. You should call the face detector again with a rotated image if you want to detect upside down faces.

Also, garbage collection time can be a factor if you're creating a lot of Bitmaps. An advantage of using ByteBuffer is that you can reuse the same buffer repeatedly without incurring per-image GC overhead that you would have encountered if you had used a Bitmap per image. CameraSource has this advantage, since it uses only a few buffers.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!