Hello I am new to android. I want to detect the coordinates of left and right eye along with hairs in an image. In this link it shows that what are the methods to detect eyes that but I am not able to implement these methods. Also I want to detect the hairs in the image so how can I do that.
Asked
Active
Viewed 6,375 times
2
-
You might try Google's mobile vision API. This will detect the left and right eyes, although it does not detect hair. See here: https://developers.google.com/vision/detect-faces-tutorial – pm0733464 Dec 12 '15 at 05:11
-
can you please tell me how can i use those left eye and right eye methods? – Divyesh Jindal Dec 12 '15 at 05:25
1 Answers
5
With the mobile vision API, left and right eyes can be detected as facial landmarks. See the tutorial for detecting landmarks here:
https://developers.google.com/vision/detect-faces-tutorial
and the API enumerating landmark types here:
https://developers.google.com/android/reference/com/google/android/gms/vision/face/Landmark
A slight modification to the code from the tutorial is all that is required to find the eyes specifically:
for (int i = 0; i < faces.size(); ++i) {
Face face = faces.valueAt(i);
for (Landmark landmark : face.getLandmarks()) {
switch (landmark.getType()) {
case Landmark.LEFT_EYE:
// use landmark.getPosition() as the left eye position

pm0733464
- 2,862
- 14
- 16
-
Thank you. but i am having a problem in this code FaceDetector detector = new FaceDetector.Builder(context) .setTrackingEnabled(false) .setLandmarkType(FaceDetector.ALL_LANDMARKS) .build(); android studio is not recognizing "Builder(context)", so what should i do for this. – Divyesh Jindal Dec 13 '15 at 12:06
-
See the answer for setting up Google Play Services: http://stackoverflow.com/questions/16624827/android-studio-with-google-play-services. The dependency to add to your build file is "compile 'com.google.android.gms:play-services:7.8.+'" – pm0733464 Dec 13 '15 at 19:02
-
Hello, i am still not able to use mobile vision. I installed : Android support repository, Google play services, Google repository. i added the latest dependency 'com.google.android.gms:play-services:8.3.0' still it is saying class not found on using "Builder" – Divyesh Jindal Dec 15 '15 at 05:00
-
Make sure that your import for the FaceDetector class is the correct one: "import com.google.android.gms.vision.face.FaceDetector;" – pm0733464 Dec 15 '15 at 16:02
-
that was the mistake!!. thanks a ton, it was driving me crazy from past 3 days... – Divyesh Jindal Dec 16 '15 at 04:24
-
It is still giving me errors :( Asset path '/system/framework/com.android.location.provider.jar' does not exist or contains no resources. Requesting download for vision face detector Native face detector not yet available. Reverting to no-op detection. creating new AssetManager and set to /data/app/com.google.android.gms-2/base.apk Asset path '/system/framework/com.android.media.remotedisplay.jar' does not exist or contains no resources. Face detector dependencies are not yet available. – Divyesh Jindal Dec 16 '15 at 07:22
-
-
i followed this answer of yours but could'nt solve my problem....please help me asap...stuck on this from past 4 days...:( http://stackoverflow.com/questions/32062803/facedetectorhandle-native-face-detector-not-yet-available-reverting-to-no-op-d – Divyesh Jindal Dec 16 '15 at 07:26