FacePlusPlus / MegviiFacepp-Android-SDK

An android wrapper of MegviiFacepp SDK (the mobile SDK).
Apache License 2.0
234 stars 75 forks source link

单张图片检查一直没法检测到人脸, 什么原因呢? #17

Closed zaykl closed 7 years ago

zaykl commented 7 years ago
byte[] imageData = BitmapUtils.getBytesFromBitmap(image);
final Facepp.Face[] faces = facepp.detect(imageData, image.getWidth(), image.getHeight(), Facepp.IMAGEMODE_RGB);
Chaoba commented 7 years ago

facepp进行过init和config吗?

zaykl commented 7 years ago

试了下, 暂时这种方式是可行的, bitmap还要经过一些处理, 建议你们加个示例吧. 昨天我也在qq群反馈了

 BitmapFactory.Options OPTION_RGBA8888 = new BitmapFactory.Options();
        OPTION_RGBA8888.inPreferredConfig = Bitmap.Config.ARGB_8888;
        OPTION_RGBA8888.inDither = false;
        OPTION_RGBA8888.inMutable = true;
        OPTION_RGBA8888.inPremultiplied = false;

Bitmap bitmap = BitmapFactory.decodeFile(pathName, OPTION_RGBA8888);
byte[] imageData1 = ConUtil.getGrayscale(bitmap);

Facepp.Face[] faces = facepp.detect(imageData1, bitmap.getWidth(), bitmap.getHeight(), Facepp.IMAGEMODE_GRAY);
jionkang commented 7 years ago

图片处理的demo后面会有的,注意下传入检测图片的数据要和设置的图片模式要吻合