核心图像人脸检测可提供零张人脸-xamarin.ios

时间:2020-10-17 07:12:49

标签: xamarin xamarin.forms xamarin.ios

我有一个使用Core Image face detection Doc的xamarin.iOS应用。我有一个自定义的相机视图,当我们拍摄照片时,如果图像中包含任何面孔,我会采取一些措施。人脸检测可在大多数iPhone上使用。当我在使用iOs 10.3.4的旧iPad上进行测试时,即使我捕捉人脸,人脸检测方法也可以将人脸计数设为零。

人脸检测实现

private async Task FaceDetectionCheking(UIImage photo)
        {           
                try
                {
                    var imageFile = photo;                  
                    var context = new CIContext();
                    var detector = CIDetector.CreateFaceDetector(context, true);
                    var ciImage = CIImage.FromCGImage(imageFile.CGImage);
                    var features = detector.FeaturesInImage(ciImage);                   
                            
                    if (features.Length == 0)
                    {
                       // No face detected.
                    }
                    else if(features.Length == 1)
                    {
                        // Single face detected
                    }
                    else if(features.Length > 1)
                    {
                        // Multiple face detected !
                    }
                
                }

                catch (Exception ex)
                {

                }
        }

设备是否有可能不支持此面部检测API?如果是这种情况,我如何检查它是否支持?任何帮助都可以申请。

修改

听起来可能很有趣。如果我们捕获互联网照片的面部,则面部检测会起作用。不是我的。 :D但是可以在所有其他设备上使用。

0 个答案:

没有答案