当前位置: 首页>>代码示例>>Java>>正文


Java Face.getIsLeftEyeOpenProbability方法代码示例

本文整理汇总了Java中com.google.android.gms.vision.face.Face.getIsLeftEyeOpenProbability方法的典型用法代码示例。如果您正苦于以下问题:Java Face.getIsLeftEyeOpenProbability方法的具体用法?Java Face.getIsLeftEyeOpenProbability怎么用?Java Face.getIsLeftEyeOpenProbability使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.android.gms.vision.face.Face的用法示例。


在下文中一共展示了Face.getIsLeftEyeOpenProbability方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onUpdate

import com.google.android.gms.vision.face.Face; //导入方法依赖的package包/类
/**
 * Update the position/characteristics of the face within the overlay.
 */
@Override
public void onUpdate(FaceDetector.Detections<Face> detectionResults, Face face) {
    mOverlay.add(mFaceGraphic);
    boolean isSmiling = face.getIsSmilingProbability() > SMILING_THRESHOLD;
    if (isSmiling) {
        float leftEye = face.getIsLeftEyeOpenProbability();
        float rightEye = face.getIsRightEyeOpenProbability();
        if (Math.abs(leftEye - rightEye) >= WINK_THRESHOLD) {
            takeShot();
        }
    }

    mFaceGraphic.setIsReady(isSmiling);
    mFaceGraphic.updateFace(face);
}
 
开发者ID:nesterov-n,项目名称:Smiley,代码行数:19,代码来源:FaceTrackerActivity.java

示例2: onUpdate

import com.google.android.gms.vision.face.Face; //导入方法依赖的package包/类
/**
 * 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();
    }
}
 
开发者ID:kevalpatel2106,项目名称:UserAwareVideoView,代码行数:17,代码来源:FaceAnalyser.java

示例3: onUpdate

import com.google.android.gms.vision.face.Face; //导入方法依赖的package包/类
/**
 * 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();
    }
}
 
开发者ID:kevalpatel2106,项目名称:Prevent-Screen-Off,代码行数:18,代码来源:FaceAnalyser.java

示例4: onUpdate

import com.google.android.gms.vision.face.Face; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:googlesamples,项目名称:android-vision,代码行数:35,代码来源:GooglyFaceTracker.java

示例5: FaceDetectionObj

import com.google.android.gms.vision.face.Face; //导入方法依赖的package包/类
public FaceDetectionObj(Face face) {
    faceId = face.getId();
    xPosition = face.getPosition().x;
    yPosition = face.getPosition().y;
    height = face.getHeight();
    width = face.getWidth();
    leftEye = face.getIsLeftEyeOpenProbability();
    rightEye = face.getIsRightEyeOpenProbability();
    isSmile = face.getIsSmilingProbability();
}
 
开发者ID:Integreight,项目名称:1Sheeld-Android-App,代码行数:11,代码来源:CameraHeadService.java

示例6: whichEmoji

import com.google.android.gms.vision.face.Face; //导入方法依赖的package包/类
private static Emoji whichEmoji(Face face) {
    // Log all the probabilities
    Log.d(LOG_TAG, "whichEmoji: smilingProb = " + face.getIsSmilingProbability());
    Log.d(LOG_TAG, "whichEmoji: leftEyeOpenProb = "
            + face.getIsLeftEyeOpenProbability());
    Log.d(LOG_TAG, "whichEmoji: rightEyeOpenProb = "
            + face.getIsRightEyeOpenProbability());


    boolean smiling = face.getIsSmilingProbability() > SMILING_PROB_THRESHOLD;

    boolean leftEyeClosed = face.getIsLeftEyeOpenProbability() < EYE_OPEN_PROB_THRESHOLD;
    boolean rightEyeClosed = face.getIsRightEyeOpenProbability() < EYE_OPEN_PROB_THRESHOLD;


    // Determine and log the appropriate emoji
    Emoji emoji;
    if(smiling) {
        if (leftEyeClosed && !rightEyeClosed) {
            emoji = Emoji.LEFT_WINK;
        }  else if(rightEyeClosed && !leftEyeClosed){
            emoji = Emoji.RIGHT_WINK;
        } else if (leftEyeClosed){
            emoji = Emoji.CLOSED_EYE_SMILE;
        } else {
            emoji = Emoji.SMILE;
        }
    } else {
        if (leftEyeClosed && !rightEyeClosed) {
            emoji = Emoji.LEFT_WINK_FROWN;
        }  else if(rightEyeClosed && !leftEyeClosed){
            emoji = Emoji.RIGHT_WINK_FROWN;
        } else if (leftEyeClosed){
            emoji = Emoji.CLOSED_EYE_FROWN;
        } else {
            emoji = Emoji.FROWN;
        }
    }


    // Log the chosen Emoji
    Log.d(LOG_TAG, "whichEmoji: " + emoji.name());

    return emoji;
}
 
开发者ID:D-Cube,项目名称:Emoji-Fy,代码行数:46,代码来源:Emojifier.java

示例7: whichEmoji

import com.google.android.gms.vision.face.Face; //导入方法依赖的package包/类
public static Emoji whichEmoji(Face face){

        float smile = face.getIsSmilingProbability();
        float leftEyeC = face.getIsLeftEyeOpenProbability();
        float rightEyeC = face.getIsRightEyeOpenProbability();
        Log.v(LOG_TAG,"Smiling Probability - " + String.valueOf(smile));
        Log.v(LOG_TAG,"LeftEye open Probability - " + String.valueOf(leftEyeC));
        Log.v(LOG_TAG,"RightEye open Probability - " + String.valueOf(rightEyeC));

        smiling = smile > 0.3;
        leftEyeClosed = leftEyeC < 0.5;
        rightEyeClosed = rightEyeC < 0.5;


        // Determine and log the appropriate emoji
        Emoji emoji;
        if(smiling) {
            if (leftEyeClosed && !rightEyeClosed) {
                emoji = LEFT_WINK;
            }  else if(rightEyeClosed && !leftEyeClosed){
                emoji = RIGHT_WINK;
            } else if (leftEyeClosed){
                emoji = CLOSED_EYE_SMILE;
            } else {
                emoji = SMILE;
            }
        } else {
            if (leftEyeClosed && !rightEyeClosed) {
                emoji = LEFT_WINK_FROWN;
            }  else if(rightEyeClosed && !leftEyeClosed){
                emoji = RIGHT_WINK_FROWN;
            } else if (leftEyeClosed){
                emoji = CLOSED_EYE_FROWN;
            } else {
                emoji = FROWN;
            }
        }

        // Log the chosen Emoji
        Log.d(LOG_TAG, "whichEmoji: " + emoji.name());
        return emoji;
    }
 
开发者ID:Masquerade0097,项目名称:Face_Animate,代码行数:43,代码来源:Emojifier.java

示例8: draw

import com.google.android.gms.vision.face.Face; //导入方法依赖的package包/类
/**
 * Draws the face annotations for position on the supplied canvas.
 */
@Override
public void draw(Canvas canvas) {
    L.m("Face Graphic = " + 82);
    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);

    float smilingProbability = face.getIsSmilingProbability();
    float rightEyeOpenProbability = face.getIsRightEyeOpenProbability();
    float leftEyeOpenProbability = face.getIsLeftEyeOpenProbability();

    /*
    if(smilingProbability >= 0.85F){
        canvas.drawText("You Are Smiling!", x - ID_X_OFFSET, y - ID_Y_OFFSET, mIdPaint);
    } else {
        canvas.drawText("happiness: " + String.format("%.2f", face.getIsSmilingProbability()), x - ID_X_OFFSET, y - ID_Y_OFFSET, mIdPaint);
    }
    if(rightEyeOpenProbability >= 0.50F){
        canvas.drawText("Right Eye is open!", x + ID_X_OFFSET * 2, y + ID_Y_OFFSET * 2, mIdPaint);
    } else {
        canvas.drawText("right eye: " + String.format("%.2f", face.getIsRightEyeOpenProbability()), x + ID_X_OFFSET * 2, y + ID_Y_OFFSET * 2, mIdPaint);
    }
    if(leftEyeOpenProbability >= 0.50F){
        canvas.drawText("Left eye is open!", x - ID_X_OFFSET*2, y - ID_Y_OFFSET*2, mIdPaint);
    } else {
        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() / 1.5f);
    float yOffset = scaleY(face.getHeight() / 1.5f);
    float left = x - xOffset;
    float top = y - yOffset;
    float right = x + xOffset;
    float bottom = y + yOffset;
    //canvas.drawRect(left, top, right, bottom, mBoxPaint);
    if(SystemUtilities.userHasLollipopOrHigher()){
        canvas.drawOval(left, top, right, bottom, mBoxPaint);
    } else {
        canvas.drawCircle(x, y, 500F, mBoxPaint);
    }


}
 
开发者ID:PGMacDesign,项目名称:PGMacTips,代码行数:56,代码来源:FaceGraphic.java

示例9: onUpdate

import com.google.android.gms.vision.face.Face; //导入方法依赖的package包/类
public void onUpdate(Detector.Detections<Face> detections, Face face) {


            //Is the left Eye open?
            LeftEye = face.getIsLeftEyeOpenProbability() > 0.75;
            // Log.i(TAG, "LeftEye Open is " + LeftEye);

            //Is the Right Eye open?
            RightEye = face.getIsRightEyeOpenProbability() > 0.75;
            //  Log.i(TAG, "RightEye Open is " + RightEye);

            //Is the face smiling?
            Smile = face.getIsSmilingProbability() > 0.75;
            if (canspeak) {  //don't speak if it's not setup, otherwise force close...
                //  Log.i(TAG, "Smile is " + Smile);
                //mLogger.setText("Smile: " + Smile + " Left: " + LeftEye + " Right:" +RightEye);
                if (!mTts.isSpeaking()) {  //If not speaking.
                    if (!LeftEye) {  //checking left eye first.
                        if (!AskLeft) { //have I already asked?
                            Speech("Please Open your Left Eye");
                            AskLeft = true;
                            AskRight = false;
                            AskSmile = false;
                        }
                    } else if (!RightEye) {
                        if (!AskRight) {
                            Speech("Please Open your Right Eye");
                            AskLeft = false;
                            AskRight = true;
                            AskSmile = false;
                        }
                    } else if (!Smile) {
                        if (!AskSmile)
                            Speech("Please Smile");
                        AskLeft = false;
                        AskRight = false;
                        AskSmile = true;
                    } else if (AskSmile) {
                        AskLeft = false;
                        AskRight = false;
                        AskSmile = false;
                        Speech("Perfect!");
                    }
                }
            }
            sendmessage("Smile: " + Smile + " Left: " + LeftEye + " Right:" + RightEye);


        }
 
开发者ID:JimSeker,项目名称:googleplayAPI,代码行数:50,代码来源:MainActivity.java

示例10: draw

import com.google.android.gms.vision.face.Face; //导入方法依赖的package包/类
/**
     * Draws the face annotations for position on the supplied canvas.
     */
    @Override
    public void draw(Canvas canvas) {
        Face face = mFace;
        if (face == null) {
            return;
        }
        //send it back via a handler
//        Log.v(TAG, "Left eye is " + face.getIsLeftEyeOpenProbability());
//        Log.v(TAG, "Right eye is " + face.getIsRightEyeOpenProbability());
//        Log.v(TAG, "simle is " + face.getIsSmilingProbability());
        sendmessage("Smile: " + face.getIsSmilingProbability() +
                " Left: " + face.getIsLeftEyeOpenProbability() +
                " Right:" + face.getIsRightEyeOpenProbability());
        // Draws a circle at the position of the detected face, with the face's track id below.

        int xl = 10;  //how big the x is.
        //first get all the landmarks, we want the eyes and mounth, but there are more
        //https://developers.google.com/android/reference/com/google/android/gms/vision/face/Landmark
        List<Landmark> myLandmark = mFace.getLandmarks();
        float cx, cy;
        float lx = 0f, ly = 0f, mx = 0, my = 0, rx = 0, ry = 0;
        //loop through the list to find each one.  Note, they may not all be listed either.
        for (Landmark landmark : myLandmark) {

            if (landmark.getType() == Landmark.LEFT_EYE) {
                cx = translateX(landmark.getPosition().x);
                cy = translateY(landmark.getPosition().y);
                if (face.getIsLeftEyeOpenProbability() > .75) {  //open, so show circle
                    canvas.drawCircle(cx, cy, 10, GreenPaint);
                } else { //closed, so show x.
                    canvas.drawLine(cx - xl, cy - xl, cx + xl, cy + xl, RedPaint);
                    canvas.drawLine(cx - xl, cy + xl, cx + xl, cy - xl, RedPaint);
                }
            } else if (landmark.getType() == Landmark.RIGHT_EYE) {
                cx = translateX(landmark.getPosition().x);
                cy = translateY(landmark.getPosition().y);
                if (face.getIsRightEyeOpenProbability() > .75) {  //open, so show circle
                    canvas.drawCircle(cx, cy, 10, GreenPaint);
                } else { //closed, so show x.
                    canvas.drawLine(cx - xl, cy - xl, cx + xl, cy + xl, RedPaint);
                    canvas.drawLine(cx - xl, cy + xl, cx + xl, cy - xl, RedPaint);
                }
            } else if (landmark.getType() == Landmark.LEFT_MOUTH) {
                lx = translateX(landmark.getPosition().x);
                ly = translateY(landmark.getPosition().y);
                //canvas.drawCircle(lx, ly, 10, paint);
            } else if (landmark.getType() == Landmark.RIGHT_MOUTH) {
                rx = translateX(landmark.getPosition().x);
                ry = translateY(landmark.getPosition().y);
                //canvas.drawCircle(rx, ry, 10, paint);
            } else if (landmark.getType() == Landmark.BOTTOM_MOUTH) {
                mx = translateX(landmark.getPosition().x);
                my = translateY(landmark.getPosition().y);
                //canvas.drawCircle(mx, my, 10, paint);
            }
        }
        //now draw the mouth.   First check if all points exists
        if (lx > 0.0f && rx > 0.0f && mx > 0.0f) {
            //so first if one side of the mouth is higher, use that one.
            Log.v(TAG, "Drawing mouth");
            if (ly < ry)  //left side is higher
                ry = ly;
            else
                ly = ry;
            //okay, the points exist, so lets draw
            if (face.getIsSmilingProbability() > .75) { //smiling draw rec
                canvas.drawRect(lx, ly, rx, my, GreenPaint);
            } else {  //no smiling draw x
                canvas.drawLine(lx, ly, rx, my, RedPaint);
                canvas.drawLine(lx, my, rx, ry, RedPaint);
            }
        }

    }
 
开发者ID:JimSeker,项目名称:googleplayAPI,代码行数:78,代码来源:FaceGraphic.java

示例11: draw

import com.google.android.gms.vision.face.Face; //导入方法依赖的package包/类
/**
 * Draws the face annotations for position on the supplied canvas.
 */
@Override
public void draw(Canvas canvas) {
    Face face = mFace;
    if (face == null) {
        return;
    }

    Log.v(TAG, "Left eye is " + face.getIsLeftEyeOpenProbability());
    Log.v(TAG, "Right eye is " + face.getIsRightEyeOpenProbability());
    Log.v(TAG, "simle is " + face.getIsSmilingProbability());
    // Draws a circle at the position of the detected face, with the face's track id below.

    int xl = 10;  //how big the x is.
    //first get all the landmarks, we want the eyes and mounth, but there are more
    //https://developers.google.com/android/reference/com/google/android/gms/vision/face/Landmark
    List<Landmark> myLandmark = mFace.getLandmarks();
    float cx, cy;
    float lx = 0f, ly = 0f, mx = 0, my = 0, rx = 0, ry = 0;
    //loop through the list to find each one.  Note, they may not all be listed either.
    for (Landmark landmark : myLandmark) {

        if (landmark.getType() == Landmark.LEFT_EYE) {
            cx = translateX(landmark.getPosition().x);
            cy = translateY(landmark.getPosition().y);
            if (face.getIsLeftEyeOpenProbability() > .75) {  //open, so show circle
                canvas.drawCircle(cx, cy, 10, GreenPaint);
            } else { //closed, so show x.
                canvas.drawLine(cx - xl, cy - xl, cx + xl, cy + xl, RedPaint);
                canvas.drawLine(cx - xl, cy + xl, cx + xl, cy - xl, RedPaint);
            }
        } else if (landmark.getType() == Landmark.RIGHT_EYE) {
            cx = translateX(landmark.getPosition().x);
            cy = translateY(landmark.getPosition().y);
            if (face.getIsRightEyeOpenProbability() > .75) {  //open, so show circle
                canvas.drawCircle(cx, cy, 10, GreenPaint);
            } else { //closed, so show x.
                canvas.drawLine(cx - xl, cy - xl, cx + xl, cy + xl, RedPaint);
                canvas.drawLine(cx - xl, cy + xl, cx + xl, cy - xl, RedPaint);
            }
        } else if (landmark.getType() == Landmark.LEFT_MOUTH) {
            lx = translateX(landmark.getPosition().x);
            ly = translateY(landmark.getPosition().y);
            //canvas.drawCircle(lx, ly, 10, paint);
        } else if (landmark.getType() == Landmark.RIGHT_MOUTH) {
            rx = translateX(landmark.getPosition().x);
            ry = translateY(landmark.getPosition().y);
            //canvas.drawCircle(rx, ry, 10, paint);
        } else if (landmark.getType() == Landmark.BOTTOM_MOUTH) {
            mx = translateX(landmark.getPosition().x);
            my = translateY(landmark.getPosition().y);
            //canvas.drawCircle(mx, my, 10, paint);
        }
    }
    //now draw the mouth.   First check if all points exists
    if (lx > 0.0f && rx > 0.0f && mx > 0.0f) {
        //so first if one side of the mouth is higher, use that one.
        Log.v(TAG, "Drawing mouth");
        if (ly < ry)  //left side is higher
            ry = ly;
        else
            ly = ry;
        //okay, the points exist, so lets draw
        if (face.getIsSmilingProbability() > .75) { //smiling draw rec
            canvas.drawRect(lx, ly, rx, my, GreenPaint);
        } else {  //no smiling draw x
            canvas.drawLine(lx, ly, rx, my, RedPaint);
            canvas.drawLine(lx, my, rx, ry, RedPaint);
        }
    }

}
 
开发者ID:JimSeker,项目名称:googleplayAPI,代码行数:75,代码来源:FaceGraphic.java


注:本文中的com.google.android.gms.vision.face.Face.getIsLeftEyeOpenProbability方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。