com.google.android.gms.vision.face.Face Java Examples
The following examples show how to use
com.google.android.gms.vision.face.Face.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FaceGraphic.java From Android-face-filters with Apache License 2.0 | 6 votes |
/** * Draws the face annotations for position on the supplied canvas. */ @Override public void draw(Canvas canvas) { Face face = mFace; if(face == null) return; // Draws a circle at the position of the detected face, with the face's track id below. float x = translateX(face.getPosition().x + face.getWidth() / 2); float y = translateY(face.getPosition().y + face.getHeight() / 2); /* canvas.drawCircle(x, y, FACE_POSITION_RADIUS, mFacePositionPaint); canvas.drawText("id: " + mFaceId, x + ID_X_OFFSET, y + ID_Y_OFFSET, mIdPaint); canvas.drawText("happiness: " + String.format("%.2f", face.getIsSmilingProbability()), x - ID_X_OFFSET, y - ID_Y_OFFSET, mIdPaint); canvas.drawText("right eye: " + String.format("%.2f", face.getIsRightEyeOpenProbability()), x + ID_X_OFFSET * 2, y + ID_Y_OFFSET * 2, mIdPaint); canvas.drawText("left eye: " + String.format("%.2f", face.getIsLeftEyeOpenProbability()), x - ID_X_OFFSET*2, y - ID_Y_OFFSET*2, mIdPaint); */ float xOffset = scaleX(face.getWidth() / 2.0f); float yOffset = scaleY(face.getHeight() / 2.0f); float left = x - xOffset; float top = y - yOffset; //float right = x + xOffset; //float bottom = y + yOffset; //canvas.drawRect(left, top, right, bottom, mBoxPaint); canvas.drawBitmap(op, left, top, new Paint()); }
Example #2
Source File: FaceOverlayView.java From Eye-blink-detector with MIT License | 6 votes |
private void drawFaceLandmarks( Canvas canvas, double scale ) { Paint paint = new Paint(); paint.setColor( Color.GREEN ); paint.setStyle( Paint.Style.STROKE ); paint.setStrokeWidth( 5 ); for( int i = 0; i < mFaces.size(); i++ ) { Face face = mFaces.valueAt(i); for ( Landmark landmark : face.getLandmarks() ) { int cx = (int) ( landmark.getPosition().x * scale ); int cy = (int) ( landmark.getPosition().y * scale ); canvas.drawCircle( cx, cy, 10, paint ); } } }
Example #3
Source File: FaceOverlayView.java From Eye-blink-detector with MIT License | 6 votes |
private void logFaceData() { float smilingProbability; float leftEyeOpenProbability; float rightEyeOpenProbability; float eulerY; float eulerZ; for( int i = 0; i < mFaces.size(); i++ ) { Face face = mFaces.valueAt(i); smilingProbability = face.getIsSmilingProbability(); leftEyeOpenProbability = face.getIsLeftEyeOpenProbability(); rightEyeOpenProbability = face.getIsRightEyeOpenProbability(); eulerY = face.getEulerY(); eulerZ = face.getEulerZ(); Log.e( "Tuts+ Face Detection", "Smiling: " + smilingProbability ); Log.d( "Tuts+ Face Detection", "Left eye open: " + leftEyeOpenProbability ); Log.d( "Tuts+ Face Detection", "Right eye open: " + rightEyeOpenProbability ); Log.e( "Tuts+ Face Detection", "Euler Y: " + eulerY ); Log.e( "Tuts+ Face Detection", "Euler Z: " + eulerZ ); } }
Example #4
Source File: ARFilterActivity.java From Machine-Learning-Projects-for-Mobile-Applications with MIT License | 6 votes |
/** Given a face and a facial landmark position, * return the coordinates of the landmark if known, * or approximated coordinates (based on prior data) if not. */ private PointF getLandmarkPosition(Face face, int landmarkId) { for (Landmark landmark : face.getLandmarks()) { if (landmark.getType() == landmarkId) { return landmark.getPosition(); } } PointF landmarkPosition = mPreviousLandmarkPositions.get(landmarkId); if (landmarkPosition == null) { return null; } float x = face.getPosition().x + (landmarkPosition.x * face.getWidth()); float y = face.getPosition().y + (landmarkPosition.y * face.getHeight()); return new PointF(x, y); }
Example #5
Source File: FaceOverlayView.java From Eye-blink-detector with MIT License | 6 votes |
private void drawFaceBox(Canvas canvas, double scale) { //This should be defined as a member variable rather than //being created on each onDraw request, but left here for //emphasis. Paint paint = new Paint(); paint.setColor(Color.GREEN); paint.setStyle(Paint.Style.STROKE); paint.setStrokeWidth(5); float left = 0; float top = 0; float right = 0; float bottom = 0; for( int i = 0; i < mFaces.size(); i++ ) { Face face = mFaces.valueAt(i); left = (float) ( face.getPosition().x * scale ); top = (float) ( face.getPosition().y * scale ); right = (float) scale * ( face.getPosition().x + face.getWidth() ); bottom = (float) scale * ( face.getPosition().y + face.getHeight() ); canvas.drawRect( left, top, right, bottom, paint ); } }
Example #6
Source File: FaceGraphic.java From FaceFilter with MIT License | 6 votes |
/** * Draws the face annotations for position on the supplied canvas. */ @Override public void draw(Canvas canvas) { Face face = mFace; if (face == null) { return; } // Draws a circle at the position of the detected face, with the face's track id below. float x = translateX(face.getPosition().x + face.getWidth() / 2); float y = translateY(face.getPosition().y + face.getHeight() / 2); float xOffset = scaleX(face.getWidth() / 2.0f); float yOffset = scaleY(face.getHeight() / 2.0f); float left = x - xOffset; float top = y - yOffset; float right = x + xOffset; float bottom = y + yOffset; canvas.drawRect(left, top, right, bottom, mBoxPaint); canvas.drawBitmap(op, left, top, new Paint()); }
Example #7
Source File: FaceOverlayView.java From Eye-blink-detector with MIT License | 6 votes |
private boolean isEyeBlinked(){ if(mFaces.size()==0) return false; Face face = mFaces.valueAt(0); float currentLeftEyeOpenProbability = face.getIsLeftEyeOpenProbability(); float currentRightEyeOpenProbability = face.getIsRightEyeOpenProbability(); if(currentLeftEyeOpenProbability== -1.0 || currentRightEyeOpenProbability == -1.0){ return false; } if(leftEyeOpenProbability>0.9 || rightEyeOpenProbability > 0.9){ boolean blinked = false; if(currentLeftEyeOpenProbability<0.6 || rightEyeOpenProbability< 0.6){ blinked = true; } leftEyeOpenProbability = currentLeftEyeOpenProbability; rightEyeOpenProbability = currentRightEyeOpenProbability; return blinked; }else{ leftEyeOpenProbability = currentLeftEyeOpenProbability; rightEyeOpenProbability = currentRightEyeOpenProbability; return false; } }
Example #8
Source File: FaceRecognition.java From MagicalCamera with Apache License 2.0 | 6 votes |
/** * Method to drawing on faces */ private Bitmap drawOnFace(SparseArray<Face> faceArray, Bitmap photo, int stroke, int color){ Bitmap outBitmap = Bitmap.createBitmap(photo.getWidth(), photo.getHeight(), Bitmap.Config.RGB_565); Canvas canvas = new Canvas(outBitmap); canvas.drawBitmap(photo, 0, 0, null); for(int i=0; i < faceArray.size(); i++){ int key = faceArray.keyAt(i); // get the object by the key. Face face = faceArray.get(key); //Drawing rectangle on each face drawRectangle(canvas, face.getPosition(), face.getWidth(), face.getHeight(),stroke,color); this.faceRecognitionInformation.setListLandMarkPhoto(face.getLandmarks()); } return outBitmap; }
Example #9
Source File: DetectFacesFunction.java From face-detection-ane with Apache License 2.0 | 6 votes |
private String getFaceJSON( Face face ) { JSONObject json = new JSONObject(); try { json.put( "faceX", face.getPosition().x ); json.put( "faceY", face.getPosition().y ); json.put( "faceWidth", face.getWidth() ); json.put( "faceHeight", face.getHeight() ); json.put( "leftEyeOpenProbability", face.getIsLeftEyeOpenProbability() ); json.put( "rightEyeOpenProbability", face.getIsRightEyeOpenProbability() ); json.put( "isSmilingProbability", face.getIsSmilingProbability() ); List<Landmark> landmarks = face.getLandmarks(); for( Landmark landmark : landmarks ) { addLandmark( landmark, json ); } } catch( JSONException e ) { e.printStackTrace(); return null; } return json.toString(); }
Example #10
Source File: GooglyFaceTracker.java From android-vision with Apache License 2.0 | 6 votes |
/** * Finds a specific landmark position, or approximates the position based on past observations * if it is not present. */ private PointF getLandmarkPosition(Face face, int landmarkId) { for (Landmark landmark : face.getLandmarks()) { if (landmark.getType() == landmarkId) { return landmark.getPosition(); } } PointF prop = mPreviousProportions.get(landmarkId); if (prop == null) { return null; } float x = face.getPosition().x + (prop.x * face.getWidth()); float y = face.getPosition().y + (prop.y * face.getHeight()); return new PointF(x, y); }
Example #11
Source File: FaceView.java From android-vision with Apache License 2.0 | 6 votes |
/** * Draws a small circle for each detected landmark, centered at the detected landmark position. * <p> * * Note that eye landmarks are defined to be the midpoint between the detected eye corner * positions, which tends to place the eye landmarks at the lower eyelid rather than at the * pupil position. */ private void drawFaceAnnotations(Canvas canvas, double scale) { Paint paint = new Paint(); paint.setColor(Color.GREEN); paint.setStyle(Paint.Style.STROKE); paint.setStrokeWidth(5); for (int i = 0; i < mFaces.size(); ++i) { Face face = mFaces.valueAt(i); for (Landmark landmark : face.getLandmarks()) { int cx = (int) (landmark.getPosition().x * scale); int cy = (int) (landmark.getPosition().y * scale); canvas.drawCircle(cx, cy, 10, paint); } } }
Example #12
Source File: FaceTrackerFactory.java From android-vision with Apache License 2.0 | 6 votes |
/** * Draws the face annotations for position, size, and ID on the supplied canvas. */ @Override public void draw(Canvas canvas) { Face face = mFace; if (face == null) { return; } // Draws a circle at the position of the detected face, with the face's track id below. float cx = translateX(face.getPosition().x + face.getWidth() / 2); float cy = translateY(face.getPosition().y + face.getHeight() / 2); canvas.drawCircle(cx, cy, FACE_POSITION_RADIUS, mFacePositionPaint); canvas.drawText("id: " + getId(), cx + ID_X_OFFSET, cy + ID_Y_OFFSET, mIdPaint); // Draws an oval around the face. float xOffset = scaleX(face.getWidth() / 2.0f); float yOffset = scaleY(face.getHeight() / 2.0f); float left = cx - xOffset; float top = cy - yOffset; float right = cx + xOffset; float bottom = cy + yOffset; canvas.drawOval(left, top, right, bottom, mBoxPaint); }
Example #13
Source File: FaceGraphic.java From android-vision with Apache License 2.0 | 6 votes |
/** * Draws the face annotations for position on the supplied canvas. */ @Override public void draw(Canvas canvas) { Face face = mFace; if (face == null) { return; } // Draws a circle at the position of the detected face, with the face's track id below. float x = translateX(face.getPosition().x + face.getWidth() / 2); float y = translateY(face.getPosition().y + face.getHeight() / 2); canvas.drawCircle(x, y, FACE_POSITION_RADIUS, mFacePositionPaint); canvas.drawText("id: " + mFaceId, x + ID_X_OFFSET, y + ID_Y_OFFSET, mIdPaint); canvas.drawText("happiness: " + String.format("%.2f", face.getIsSmilingProbability()), x - ID_X_OFFSET, y - ID_Y_OFFSET, mIdPaint); canvas.drawText("right eye: " + String.format("%.2f", face.getIsRightEyeOpenProbability()), x + ID_X_OFFSET * 2, y + ID_Y_OFFSET * 2, mIdPaint); canvas.drawText("left eye: " + String.format("%.2f", face.getIsLeftEyeOpenProbability()), x - ID_X_OFFSET*2, y - ID_Y_OFFSET*2, mIdPaint); // Draws a bounding box around the face. float xOffset = scaleX(face.getWidth() / 2.0f); float yOffset = scaleY(face.getHeight() / 2.0f); float left = x - xOffset; float top = y - yOffset; float right = x + xOffset; float bottom = y + yOffset; canvas.drawRect(left, top, right, bottom, mBoxPaint); }
Example #14
Source File: FaceGraphic.java From flutter_mobile_vision with MIT License | 6 votes |
@Override public RectF getBoundingBox() { Face face = this.face; if (face == null) { return null; } float x = translateX(face.getPosition().x + face.getWidth() / 2); float y = translateY(face.getPosition().y + face.getHeight() / 2); float xOffset = scaleX(face.getWidth() / 2.0f); float yOffset = scaleY(face.getHeight() / 2.0f); float left = x - xOffset; float top = y - yOffset; float right = x + xOffset; float bottom = y + yOffset; return new RectF(left, top, right, bottom); }
Example #15
Source File: FaceOverlayView.java From AndroidDemoProjects with Apache License 2.0 | 6 votes |
private void drawFaceBox(Canvas canvas, double scale) { //This should be defined as a member variable rather than //being created on each onDraw request, but left here for //emphasis. Paint paint = new Paint(); paint.setColor(Color.GREEN); paint.setStyle(Paint.Style.STROKE); paint.setStrokeWidth(5); float left = 0; float top = 0; float right = 0; float bottom = 0; for( int i = 0; i < mFaces.size(); i++ ) { Face face = mFaces.valueAt(i); left = (float) ( face.getPosition().x * scale ); top = (float) ( face.getPosition().y * scale ); right = (float) scale * ( face.getPosition().x + face.getWidth() ); bottom = (float) scale * ( face.getPosition().y + face.getHeight() ); canvas.drawRect( left, top, right, bottom, paint ); } }
Example #16
Source File: FaceOverlayView.java From AndroidDemoProjects with Apache License 2.0 | 6 votes |
private void drawFaceLandmarks( Canvas canvas, double scale ) { Paint paint = new Paint(); paint.setColor( Color.GREEN ); paint.setStyle( Paint.Style.STROKE ); paint.setStrokeWidth( 5 ); for( int i = 0; i < mFaces.size(); i++ ) { Face face = mFaces.valueAt(i); for ( Landmark landmark : face.getLandmarks() ) { int cx = (int) ( landmark.getPosition().x * scale ); int cy = (int) ( landmark.getPosition().y * scale ); canvas.drawCircle( cx, cy, 10, paint ); } } }
Example #17
Source File: FaceOverlayView.java From AndroidDemoProjects with Apache License 2.0 | 6 votes |
private void logFaceData() { float smilingProbability; float leftEyeOpenProbability; float rightEyeOpenProbability; float eulerY; float eulerZ; for( int i = 0; i < mFaces.size(); i++ ) { Face face = mFaces.valueAt(i); smilingProbability = face.getIsSmilingProbability(); leftEyeOpenProbability = face.getIsLeftEyeOpenProbability(); rightEyeOpenProbability = face.getIsRightEyeOpenProbability(); eulerY = face.getEulerY(); eulerZ = face.getEulerZ(); Log.e( "Tuts+ Face Detection", "Smiling: " + smilingProbability ); Log.e( "Tuts+ Face Detection", "Left eye open: " + leftEyeOpenProbability ); Log.e( "Tuts+ Face Detection", "Right eye open: " + rightEyeOpenProbability ); Log.e( "Tuts+ Face Detection", "Euler Y: " + eulerY ); Log.e( "Tuts+ Face Detection", "Euler Z: " + eulerZ ); } }
Example #18
Source File: MyFace.java From flutter_mobile_vision with MIT License | 5 votes |
public MyFace(Face face) { this.id = face.getId(); this.x = face.getPosition().x; this.y = face.getPosition().y; this.width = face.getWidth(); this.height = face.getHeight(); this.eulerY = face.getEulerY(); this.eulerZ = face.getEulerZ(); this.leftEyeOpenProbability = face.getIsLeftEyeOpenProbability(); this.rightEyeOpenProbability = face.getIsRightEyeOpenProbability(); this.smilingProbability = face.getIsSmilingProbability(); }
Example #19
Source File: FaceTrackerFactory.java From flutter_mobile_vision with MIT License | 5 votes |
@Override public Tracker<Face> create(Face face) { FaceGraphic graphic = new FaceGraphic(graphicOverlay, showText); try { return new FaceGraphicTracker(graphicOverlay, graphic); } catch (Exception ex) { Log.d("FaceTrackerFactory", ex.getMessage(), ex); } return null; }
Example #20
Source File: FaceOverlayView.java From Eye-blink-detector with MIT License | 5 votes |
private boolean isEyeToggled() { if (mFaces.size() == 0) return false; Face face = mFaces.valueAt(0); float currentLeftEyeOpenProbability = face.getIsLeftEyeOpenProbability(); float currentRightEyeOpenProbability = face.getIsRightEyeOpenProbability(); if (currentLeftEyeOpenProbability == -1.0 || currentRightEyeOpenProbability == -1.0) { return false; } double currentLeftOpenRatio = currentLeftEyeOpenProbability / currentRightEyeOpenProbability; if (currentLeftOpenRatio > 3) currentLeftOpenRatio = 3; if (currentLeftOpenRatio < 0.33) currentLeftOpenRatio = 0.33; Log.d("probs",currentLeftOpenRatio+" "+leftopenRatio ); if(currentLeftOpenRatio==0.33|| currentLeftOpenRatio ==3.0){ if(leftopenRatio==1){ leftopenRatio = currentLeftOpenRatio; } if(leftopenRatio*currentLeftOpenRatio==0.99){ leftopenRatio = currentLeftOpenRatio; return true; } } return false; }
Example #21
Source File: FaceGraphic.java From flutter_mobile_vision with MIT License | 5 votes |
/** * Draws the face annotations for position on the supplied canvas. */ @Override public void draw(Canvas canvas) { Face face = this.face; if (face == null) { return; } // Draws a circle at the position of the detected face, with the face's track id below. float x = translateX(face.getPosition().x + face.getWidth() / 2); float y = translateY(face.getPosition().y + face.getHeight() / 2); if (showText) { canvas.drawCircle(x, y, FACE_POSITION_RADIUS, facePositionPaint); canvas.drawText("id: " + getId(), x + ID_X_OFFSET, y + ID_Y_OFFSET, idPaint); canvas.drawText("happiness: " + String.format("%.2f", face.getIsSmilingProbability()), x - ID_X_OFFSET, y - ID_Y_OFFSET, idPaint); canvas.drawText("right eye: " + String.format("%.2f", face.getIsRightEyeOpenProbability()), x + ID_X_OFFSET * 2, y + ID_Y_OFFSET * 2, idPaint); canvas.drawText("left eye: " + String.format("%.2f", face.getIsLeftEyeOpenProbability()), x - ID_X_OFFSET * 2, y - ID_Y_OFFSET * 2, idPaint); } // Draws a bounding box around the face. canvas.drawRect(getBoundingBox(), boxPaint); }
Example #22
Source File: FaceGraphic.java From Android-face-filters with Apache License 2.0 | 5 votes |
/** * Updates the face instance from the detection of the most recent frame. Invalidates the * relevant portions of the overlay to trigger a redraw. */ void updateFace(Face face,int c) { mFace = face; bitmap = BitmapFactory.decodeResource(getOverlay().getContext().getResources(), MASK[c]); op = bitmap; op = Bitmap.createScaledBitmap(op, (int) scaleX(face.getWidth()), (int) scaleY(((bitmap.getHeight() * face.getWidth()) / bitmap.getWidth())), false); postInvalidate(); }
Example #23
Source File: ARFilterActivity.java From Machine-Learning-Projects-for-Mobile-Applications with MIT License | 5 votes |
private void updatePreviousLandmarkPositions(Face face) { for (Landmark landmark : face.getLandmarks()) { PointF position = landmark.getPosition(); float xProp = (position.x - face.getPosition().x) / face.getWidth(); float yProp = (position.y - face.getPosition().y) / face.getHeight(); mPreviousLandmarkPositions.put(landmark.getType(), new PointF(xProp, yProp)); } }
Example #24
Source File: FaceGraphic.java From FaceFilter with MIT License | 5 votes |
/** * Updates the face instance from the detection of the most recent frame. Invalidates the * relevant portions of the overlay to trigger a redraw. */ void updateFace(Face face) { mFace = face; op = Bitmap.createScaledBitmap(bitmap, (int) scaleX(face.getWidth()), (int) scaleY(((bitmap.getHeight() * face.getWidth()) / bitmap.getWidth())), false); postInvalidate(); }
Example #25
Source File: FaceRecognition.java From MagicalCamera with Apache License 2.0 | 5 votes |
/*** * This method realize the face detection, and this call in another methods * for automatice the process * @param stroke the bold of line to show around the face * @param color the color of rectangle to recognizer the face * @param activity the currect activity * @param photo your photo * @return */ private Bitmap faceDetection(int stroke, int color, Activity activity, Bitmap photo){ this.detector = new FaceDetector.Builder(activity) .setMode(FaceDetector.ACCURATE_MODE) .setLandmarkType(FaceDetector.ALL_LANDMARKS) .setClassificationType(FaceDetector.ALL_CLASSIFICATIONS) .setTrackingEnabled(false) .build(); try { if (false == this.detector.isOperational()) { return null; } //Add the image on a Frame object Frame frame = new Frame.Builder() .setBitmap(photo) .build(); //Detect all faces from Frame object SparseArray<Face> faceArray = detector.detect(frame); //Do some drawing on faces Bitmap outBitmap = drawOnFace(faceArray, photo, stroke, color); //Releasing the detector object this.detector.release(); return (outBitmap != null) ? outBitmap : photo; }catch(Exception ev){ return null; } }
Example #26
Source File: DetectFacesFunction.java From face-detection-ane with Apache License 2.0 | 5 votes |
private JSONArray getFacesJSONArray( SparseArray<Face> faces ) { int numFaces = faces.size(); JSONArray facesResult = new JSONArray(); for( int i = 0; i < numFaces; i++ ) { Face face = faces.valueAt( i ); String faceJSON = getFaceJSON( face ); if( faceJSON != null ) { facesResult.put( faceJSON ); } else { AIR.log( "Error making JSON out of Face object" ); } } AIR.log( "Parsed " + facesResult.length() + " faces" ); return facesResult; }
Example #27
Source File: FaceAnalyser.java From UserAwareVideoView with Apache License 2.0 | 5 votes |
/** * When new frame analysed. */ @Override public void onUpdate(FaceDetector.Detections<Face> detectionResults, Face face) { Log.d("FaceTracker", "onUpdate" + face.getIsLeftEyeOpenProbability()); //if left and right eyes are open. (Probability more than 10%) if (face.getIsLeftEyeOpenProbability() > 0.10 && face.getIsRightEyeOpenProbability() > 0.10) { isEyesClosedCount = 0; mUserAwareVideoView.onUserAttentionAvailable(); } else { isEyesClosedCount++; if (isEyesClosedCount > 2) mUserAwareVideoView.onUserAttentionGone(); } }
Example #28
Source File: FaceAnalyser.java From Prevent-Screen-Off with Apache License 2.0 | 5 votes |
/** * Update the position/characteristics of the face within the overlay. */ @Override public void onUpdate(FaceDetector.Detections<Face> detectionResults, Face face) { Log.d(getClass().getSimpleName(), "onUpdate" + face.getIsLeftEyeOpenProbability()); if (face.getIsLeftEyeOpenProbability() > 0.10 && face.getIsRightEyeOpenProbability() > 0.10) { isEyesClosedCount = 0; mWakelockManager.acquireWakelock(); } else { isEyesClosedCount++; if (isEyesClosedCount > 2) mWakelockManager.releaseWakelock(); } }
Example #29
Source File: GooglyFaceTracker.java From android-vision with Apache License 2.0 | 5 votes |
/** * Updates the positions and state of eyes to the underlying graphic, according to the most * recent face detection results. The graphic will render the eyes and simulate the motion of * the iris based upon these changes over time. */ @Override public void onUpdate(FaceDetector.Detections<Face> detectionResults, Face face) { mOverlay.add(mEyesGraphic); updatePreviousProportions(face); PointF leftPosition = getLandmarkPosition(face, Landmark.LEFT_EYE); PointF rightPosition = getLandmarkPosition(face, Landmark.RIGHT_EYE); float leftOpenScore = face.getIsLeftEyeOpenProbability(); boolean isLeftOpen; if (leftOpenScore == Face.UNCOMPUTED_PROBABILITY) { isLeftOpen = mPreviousIsLeftOpen; } else { isLeftOpen = (leftOpenScore > EYE_CLOSED_THRESHOLD); mPreviousIsLeftOpen = isLeftOpen; } float rightOpenScore = face.getIsRightEyeOpenProbability(); boolean isRightOpen; if (rightOpenScore == Face.UNCOMPUTED_PROBABILITY) { isRightOpen = mPreviousIsRightOpen; } else { isRightOpen = (rightOpenScore > EYE_CLOSED_THRESHOLD); mPreviousIsRightOpen = isRightOpen; } mEyesGraphic.updateEyes(leftPosition, isLeftOpen, rightPosition, isRightOpen); }
Example #30
Source File: GooglyFaceTracker.java From android-vision with Apache License 2.0 | 5 votes |
private void updatePreviousProportions(Face face) { for (Landmark landmark : face.getLandmarks()) { PointF position = landmark.getPosition(); float xProp = (position.x - face.getPosition().x) / face.getWidth(); float yProp = (position.y - face.getPosition().y) / face.getHeight(); mPreviousProportions.put(landmark.getType(), new PointF(xProp, yProp)); } }