• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Landmark类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.android.gms.vision.face.Landmark的典型用法代码示例。如果您正苦于以下问题:Java Landmark类的具体用法?Java Landmark怎么用?Java Landmark使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Landmark类属于com.google.android.gms.vision.face包,在下文中一共展示了Landmark类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getLandmarkKey

import com.google.android.gms.vision.face.Landmark; //导入依赖的package包/类
private String getLandmarkKey( int landmarkType ) {
	switch( landmarkType ) {
		case Landmark.BOTTOM_MOUTH: return "mouth";
		case Landmark.LEFT_EYE: return "leftEye";
		case Landmark.RIGHT_EYE: return "rightEye";
		case Landmark.LEFT_EAR: return "leftEar";
		case Landmark.LEFT_EAR_TIP: return "leftEarTip";
		case Landmark.LEFT_CHEEK: return "leftCheek";
		case Landmark.LEFT_MOUTH: return "leftMouth";
		case Landmark.RIGHT_EAR: return "rightEar";
		case Landmark.RIGHT_EAR_TIP: return "rightEarTip";
		case Landmark.RIGHT_CHEEK: return "rightCheek";
		case Landmark.RIGHT_MOUTH: return "rightMouth";
		case Landmark.NOSE_BASE: return "noseBase";
		default: return null;
	}
}
 
开发者ID:marpies,项目名称:face-detection-ane,代码行数:18,代码来源:DetectFacesFunction.java


示例2: drawFaceAnnotations

import com.google.android.gms.vision.face.Landmark; //导入依赖的package包/类
/**
 * 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);
        }
    }
}
 
开发者ID:ashishsurana,项目名称:qrcode-reader,代码行数:24,代码来源:FaceView.java


示例3: getLandmarkPosition

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


示例4: updateFace

import com.google.android.gms.vision.face.Landmark; //导入依赖的package包/类
@Override public void updateFace(Face face) {
  for (Landmark landmark : face.getLandmarks()) {
    switch (landmark.getType()) {
      case Landmark.LEFT_EYE:
        leftEye = landmark.getPosition();
        break;
      case Landmark.RIGHT_EYE:
        rightEye = landmark.getPosition();
        break;
    }
  }
  this.face = face;
}
 
开发者ID:square,项目名称:kind-photo-bot,代码行数:14,代码来源:OreoGraphic.java


示例5: getFaceJSON

import com.google.android.gms.vision.face.Landmark; //导入依赖的package包/类
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();
}
 
开发者ID:marpies,项目名称:face-detection-ane,代码行数:21,代码来源:DetectFacesFunction.java


示例6: addLandmark

import com.google.android.gms.vision.face.Landmark; //导入依赖的package包/类
private void addLandmark( Landmark landmark, JSONObject json ) throws JSONException {
	/* Mouth position */
	int landmarkType = landmark.getType();
	String landmarkKey = getLandmarkKey( landmarkType );
	if( landmarkKey != null ) {
		json.put( landmarkKey + "X", landmark.getPosition().x );
		json.put( landmarkKey + "Y", landmark.getPosition().y );
	}
}
 
开发者ID:marpies,项目名称:face-detection-ane,代码行数:10,代码来源:DetectFacesFunction.java


示例7: isCentered

import com.google.android.gms.vision.face.Landmark; //导入依赖的package包/类
public static boolean isCentered(List<Landmark> landmarkList){
        boolean isItCentered = false;
        float averageX, averageY;
        int totalXObjects, totalYObjects;
        if(MiscUtilities.isListNullOrEmpty(landmarkList)){
            isItCentered = false;
        }
        for(Landmark landmark : landmarkList){
            int x = landmark.getType();
//https://developers.google.com/android/reference/com/google/android/gms/vision/face/Landmark.html#getPosition()
        }

        return false;
    }
 
开发者ID:PGMacDesign,项目名称:PGMacTips,代码行数:15,代码来源:GoogleVisionFaceUtilities.java


示例8: onUpdate

import com.google.android.gms.vision.face.Landmark; //导入依赖的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


示例9: updatePreviousProportions

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


示例10: locateEyes

import com.google.android.gms.vision.face.Landmark; //导入依赖的package包/类
private void locateEyes() {
    for (Landmark landmark : face.getLandmarks()) {
        switch (landmark.getType()) {
            case Landmark.LEFT_EYE:
                leftEye = landmark;
                break;
            case Landmark.RIGHT_EYE:
                rightEye = landmark;
                break;
            default: break;
        }
    }
}
 
开发者ID:raptox,项目名称:TheGesichtGedicht-Android,代码行数:14,代码来源:FaceAndPoemService.java


示例11: PhotoFace

import com.google.android.gms.vision.face.Landmark; //导入依赖的package包/类
public PhotoFace(Face face, Bitmap sourceBitmap, Size targetSize, boolean sideward) {
    List<Landmark> landmarks = face.getLandmarks();

    Point leftEyePoint = null;
    Point rightEyePoint = null;

    Point leftMouthPoint = null;
    Point rightMouthPoint = null;

    for (Landmark landmark : landmarks) {
        PointF point = landmark.getPosition();

        switch (landmark.getType()) {
            case Landmark.LEFT_EYE: {
                leftEyePoint = transposePoint(point, sourceBitmap, targetSize, sideward);
            }
            break;

            case Landmark.RIGHT_EYE: {
                rightEyePoint = transposePoint(point, sourceBitmap, targetSize, sideward);
            }
            break;

            case Landmark.LEFT_MOUTH: {
                leftMouthPoint = transposePoint(point, sourceBitmap, targetSize, sideward);
            }
            break;

            case Landmark.RIGHT_MOUTH: {
                rightMouthPoint = transposePoint(point, sourceBitmap, targetSize, sideward);
            }
            break;
        }
    }

    if (leftEyePoint != null && rightEyePoint != null) {
        eyesCenterPoint = new Point(0.5f * leftEyePoint.x + 0.5f * rightEyePoint.x,
                0.5f * leftEyePoint.y + 0.5f * rightEyePoint.y);
        eyesDistance = (float)Math.hypot(rightEyePoint.x - leftEyePoint.x, rightEyePoint.y - leftEyePoint.y);
        angle = (float)Math.toDegrees(Math.PI + Math.atan2(rightEyePoint.y - leftEyePoint.y, rightEyePoint.x - leftEyePoint.x));

        width = eyesDistance * 2.35f;

        float foreheadHeight = 0.8f * eyesDistance;
        float upAngle = (float)Math.toRadians(angle - 90);
        foreheadPoint = new Point(eyesCenterPoint.x + foreheadHeight * (float)Math.cos(upAngle),
                eyesCenterPoint.y + foreheadHeight * (float)Math.sin(upAngle));
    }

    if (leftMouthPoint != null && rightMouthPoint != null) {
        mouthPoint = new Point(0.5f * leftMouthPoint.x + 0.5f * rightMouthPoint.x,
                0.5f * leftMouthPoint.y + 0.5f * rightMouthPoint.y);

        float chinDepth = 0.7f * eyesDistance;
        float downAngle = (float)Math.toRadians(angle + 90);
        chinPoint = new Point(mouthPoint.x + chinDepth * (float)Math.cos(downAngle),
                mouthPoint.y + chinDepth * (float)Math.sin(downAngle));
    }
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:60,代码来源:PhotoFace.java


示例12: scanFaces

import com.google.android.gms.vision.face.Landmark; //导入依赖的package包/类
private void scanFaces() throws Exception {
    Bitmap bitmap = decodeBitmapUri(this, imageUri);
    if (detector.isOperational() && bitmap != null) {
        editedBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap
                .getHeight(), bitmap.getConfig());
        float scale = getResources().getDisplayMetrics().density;
        Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
        paint.setColor(Color.rgb(255, 61, 61));
        paint.setTextSize((int) (14 * scale));
        paint.setShadowLayer(1f, 0f, 1f, Color.WHITE);
        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeWidth(3f);
        Canvas canvas = new Canvas(editedBitmap);
        canvas.drawBitmap(bitmap, 0, 0, paint);
        Frame frame = new Frame.Builder().setBitmap(editedBitmap).build();
        SparseArray<Face> faces = detector.detect(frame);
        scanResults.setText(null);
        for (int index = 0; index < faces.size(); ++index) {
            Face face = faces.valueAt(index);
            canvas.drawRect(
                    face.getPosition().x,
                    face.getPosition().y,
                    face.getPosition().x + face.getWidth(),
                    face.getPosition().y + face.getHeight(), paint);
            scanResults.setText(scanResults.getText() + "Face " + (index + 1) + "\n");
            scanResults.setText(scanResults.getText() + "Smile probability:" + "\n");
            scanResults.setText(scanResults.getText() + String.valueOf(face.getIsSmilingProbability()) + "\n");
            scanResults.setText(scanResults.getText() + "Left Eye Open Probability: " + "\n");
            scanResults.setText(scanResults.getText() + String.valueOf(face.getIsLeftEyeOpenProbability()) + "\n");
            scanResults.setText(scanResults.getText() + "Right Eye Open Probability: " + "\n");
            scanResults.setText(scanResults.getText() + String.valueOf(face.getIsRightEyeOpenProbability()) + "\n");
            scanResults.setText(scanResults.getText() + "---------" + "\n");

            for (Landmark landmark : face.getLandmarks()) {
                int cx = (int) (landmark.getPosition().x);
                int cy = (int) (landmark.getPosition().y);
                canvas.drawCircle(cx, cy, 5, paint);
            }
        }

        if (faces.size() == 0) {
            scanResults.setText("Scan Failed: Found nothing to scan");
        } else {
            imageView.setImageBitmap(editedBitmap);
            scanResults.setText(scanResults.getText() + "No of Faces Detected: " + "\n");
            scanResults.setText(scanResults.getText() + String.valueOf(faces.size()) + "\n");
            scanResults.setText(scanResults.getText() + "---------" + "\n");
        }
    } else {
        scanResults.setText("Could not set up the detector!");
    }
}
 
开发者ID:Truiton,项目名称:MobileVisionAPI,代码行数:53,代码来源:MainActivity.java


示例13: getListLandMarkPhoto

import com.google.android.gms.vision.face.Landmark; //导入依赖的package包/类
public List<Landmark> getListLandMarkPhoto() {
    return listLandMarkPhoto;
}
 
开发者ID:fabian7593,项目名称:MagicalCamera,代码行数:4,代码来源:FaceRecognitionObject.java


示例14: setListLandMarkPhoto

import com.google.android.gms.vision.face.Landmark; //导入依赖的package包/类
public void setListLandMarkPhoto(List<Landmark> listLandMarkPhoto) {
    this.listLandMarkPhoto = listLandMarkPhoto;
}
 
开发者ID:fabian7593,项目名称:MagicalCamera,代码行数:4,代码来源:FaceRecognitionObject.java


示例15: draw

import com.google.android.gms.vision.face.Landmark; //导入依赖的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


示例16: draw

import com.google.android.gms.vision.face.Landmark; //导入依赖的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


示例17: detect

import com.google.android.gms.vision.face.Landmark; //导入依赖的package包/类
@Override
public void detect(
        SharedBufferHandle frameData, int width, int height, DetectResponse callback) {
    // The vision library will be downloaded the first time the API is used
    // on the device; this happens "fast", but it might have not completed,
    // bail in this case.
    if (!mFaceDetector.isOperational()) {
        Log.e(TAG, "FaceDetector is not operational");

        // Fallback to Android's FaceDetectionImpl.
        FaceDetectorOptions options = new FaceDetectorOptions();
        options.fastMode = mFastMode;
        options.maxDetectedFaces = mMaxFaces;
        FaceDetectionImpl detector = new FaceDetectionImpl(options);
        detector.detect(frameData, width, height, callback);
        return;
    }

    Frame frame = SharedBufferUtils.convertToFrame(frameData, width, height);
    if (frame == null) {
        Log.e(TAG, "Error converting SharedMemory to Frame");
        callback.call(new FaceDetectionResult[0]);
        return;
    }

    final SparseArray<Face> faces = mFaceDetector.detect(frame);

    FaceDetectionResult[] faceArray = new FaceDetectionResult[faces.size()];
    for (int i = 0; i < faces.size(); i++) {
        faceArray[i] = new FaceDetectionResult();
        final Face face = faces.valueAt(i);

        final PointF corner = face.getPosition();
        faceArray[i].boundingBox = new RectF();
        faceArray[i].boundingBox.x = corner.x;
        faceArray[i].boundingBox.y = corner.y;
        faceArray[i].boundingBox.width = face.getWidth();
        faceArray[i].boundingBox.height = face.getHeight();

        final List<Landmark> landmarks = face.getLandmarks();
        ArrayList<org.chromium.shape_detection.mojom.Landmark> mojoLandmarks =
                new ArrayList<org.chromium.shape_detection.mojom.Landmark>(landmarks.size());

        for (int j = 0; j < landmarks.size(); j++) {
            final Landmark landmark = landmarks.get(j);
            final int landmarkType = landmark.getType();
            if (landmarkType == Landmark.LEFT_EYE || landmarkType == Landmark.RIGHT_EYE
                    || landmarkType == Landmark.BOTTOM_MOUTH) {
                org.chromium.shape_detection.mojom.Landmark mojoLandmark =
                        new org.chromium.shape_detection.mojom.Landmark();
                mojoLandmark.location = new org.chromium.gfx.mojom.PointF();
                mojoLandmark.location.x = landmark.getPosition().x;
                mojoLandmark.location.y = landmark.getPosition().y;
                mojoLandmark.type = landmarkType == Landmark.BOTTOM_MOUTH ? LandmarkType.MOUTH
                                                                          : LandmarkType.EYE;
                mojoLandmarks.add(mojoLandmark);
            }
        }
        faceArray[i].landmarks = mojoLandmarks.toArray(
                new org.chromium.shape_detection.mojom.Landmark[mojoLandmarks.size()]);
    }
    callback.call(faceArray);
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:64,代码来源:FaceDetectionImplGmsCore.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Object2ObjectOpenHashMap类代码示例发布时间:2022-05-21
下一篇:
Java IHAListener类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap