Solution 1 :
It is the true, the image size is not a hard limitation, that is why we put the comment in the java doc.
“This is not a hard limit on face size; the detector may find faces slightly smaller than specified.“
You could increase the minFaceSize if you only have interests in larger faces. Or you could do a filtering for the size in your end. By increasing the minFaceSize, the performance will be improved.
Problem :
Currently i am using ML Kit to detect face in my application.
It’s working but has one problem. I want to set minimum face size on it but it seems to have no effect. It always detects a face no matter what size is it.
Here is my code:
private fun setupCamera(cameraProviderFuture: ListenableFuture<ProcessCameraProvider>, mainView: MainView) {
val cameraProvider = cameraProviderFuture.get()
preview = Preview.Builder().build()
val cameraSelector = CameraSelector.Builder().requireLensFacing(CameraSelector.LENS_FACING_FRONT).build()
val realTimeOpts = FaceDetectorOptions.Builder()
.setPerformanceMode(FaceDetectorOptions.PERFORMANCE_MODE_FAST)
.setMinFaceSize(0.5f)
.enableTracking()
.build()
detector = FaceDetection.getClient(realTimeOpts)
val imageAnalysis = ImageAnalysis.Builder()
.setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
.build()
.apply { setAnalyzer(Executors.newSingleThreadExecutor(), FaceDetectAnalyzer(detector!!, mainView))}
try {
cameraProvider.unbindAll()
camera = cameraProvider.bindToLifecycle(this as LifecycleOwner, cameraSelector, imageAnalysis, preview)
preview?.setSurfaceProvider(binding.pvCameraPreview.createSurfaceProvider())
} catch (e: Exception) {
Log.e(TAG, "Use case binding failed", e)
}
}
Could someone point me any clues or suggestions? Thank you.
Comments
Comment posted by Selmeny
Do you mean it’s only related with performance? Because i tried to set it to max (1.0f) and it’s still not working. It always detects face no matter how small is it.
Comment posted by Shiyu
Yes, right now it is mainly for performance boosts. We use it to decide the block size when scanning the image. It can not be used directly to filter out face sizes, which we could improve. If you do want to filter out small faces, you may need to filter out in the app size with the return bounding box size.
Comment posted by Selmeny
I see. So for now, i can filter it by using width of the bounding box size. Thank you.
Comment posted by Devansh Maurya
@Shiyu why can’t this explanation be there in the docs that it can not be used to filter out faces by sizes?