'face detecting'에 해당되는 글 1건

  1. 2015.10.14 android face detecting ( FaceDetector vs google-play-vision )

android face detecting ( FaceDetector vs google-play-vision )

android 2015. 10. 14. 15:02

336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

 

먼저 혼동하기 쉬운 얼굴인식과 얼굴검출에 대해서 간단하게 짚고 넘어가면..

얼굴검출(face detect)은 이미지에서 얼굴이 어느 영역에 있는지 찾는 것이고

얼굴인식(face recognize)A라는 얼굴과 B라는 얼굴이 유사한지 또는 같은 사람인지 판별하는 것이다.

 

안드로이드에서 face dectect을 하기 위해서는 2가지 방식이 있다.

첫번째는 , Image 소스에서 얼굴을 검출(dectect)하는 android.media.FaceDetector 를 이용하는 방법

두번째는, live stream 소스에서 얼굴을 검출하는 Camera.FaceDetectionListener 를 이용하는 방법

 

Android 에서 얼굴검출을 위해서 3rd party library를 사용하지 않는다면 어쩔수 없이 사용하는 FaceDetector API level 1 부터 사용가능하데, 그래서 그런지 결과나 성능에서 상당히 떨어진다. 그리고 FaceDetector를 사용할때는 한가지 주의 할점이 입력 Bitmap RGB_565 타입을 넘겨야 한다. 대략적인 코드는 아래와 같다.

 

android.media.FaceDetector.Face[] scaledFaces = new android.media.FaceDetector.Face[1]; // 얼굴 1개만 인식
Bitmap inputBitmap = buildScaledFace565Bitmap(imageBitmap);
android.media.FaceDetector faceDetector = new android.media.FaceDetector(inputBitmap.getWidth(), inputBitmap.getHeight(), 1);
faceDetector.findFaces(inputBitmap, scaledFaces);

 

그리고 입력 bitmap의 크기가 커질수로 수행시간이 기하급수적으로 늘어난다. 그리고 detecting된 정보도 두 눈사이의 중점 Point, 중점 Point에서 눈사이의 거리 정보만 준다. 즉 얼굴영역(Rect)는 알려주지 않는다.

 

그래서 2015 8월에 google에서 google-play-vision library를 발표했는데, 무척이나 좋다.

간단하게 media.FaceDetector와 비교해본 테스트 성능은 아래와 같다.

 

갤럭시 S4단말

사진크기

FaceDetector 시간

Vision 시간

460 * 560

224ms

154ms

960 * 960

705ms

305ms

1920 * 1200

2380ms

350ms

 

성능도 좋지만 결과 품질도 상당히 좋다. 주요한 장점을 설명하면 아래와 같다.

 

1.     얼굴영역(left/right 정보, width, height)를 알려준다.

 

·                     getPosition() - Returns the top left coordinates of the area where a face was detected

·                     getWidth() - Returns the width of the area where a face was detected

·                     getHeight() - Returns the height of the area where a face was detected

 

 

2.     얼굴이 기울어저 있어도 검출된다.



위그림처럼 y축 기준으로 60도 회전된 얼굴과, xy평면을 기준으로 45도 회전된 얼굴까지 검출이가능하다. 기존 android.media.FaceDetector에 비하면 비약적인 발전으로 보인다. ^^;

 

3.     얼굴의 다양한 특징 포인트를 알려준다.

얼굴의 특징 포인트를 Landmark로 부르는데, 코드에 아래처럼 정의 되어 있다.

public static final int BOTTOM_MOUTH = 0;
public static final int
LEFT_CHEEK = 1;
public static final int
LEFT_EAR_TIP = 2;
public static final int
LEFT_EAR = 3;
public static final int
LEFT_EYE = 4;
public static final int
LEFT_MOUTH = 5;
public static final int
NOSE_BASE = 6;
public static final int
RIGHT_CHEEK = 7;
public static final int
RIGHT_EAR_TIP = 8;
public static final int
RIGHT_EAR = 9;
public static final int
RIGHT_EYE = 10;
public static final int
RIGHT_MOUTH = 11;

 

두눈위치, 입위치, 볼위치, 코위치, 귀위치 등 얼굴에 대해서 상세한 정보를 줄 수 있는데, 물로 검출에 성공한 경우에만 Landmark 위치를 알 수 있다. 실제로 테스트 해보면 귀위치는 잘 안나온다.

 


Image에서 얼굴검출할 때 사용하면 상당히 유용할 듯 한다. 추가로 FaceTracking(live로 얼굴을 검출하고 얼굴이 이동하면 따라가면서 계속 검출하는)도 가능하다. 하지만 FaceTrackinginput 크기가 클 경우 FPS가 잘 안나온다.

 

[관련자료]

https://developers.google.com/vision/face-detection-concepts

http://android-developers.blogspot.kr/2015/08/google-play-services-78-lets-see-whats.html

https://github.com/googlesamples/android-vision


 

 


 

 

 



: