本文整理匯總了Java中android.hardware.Camera.Face方法的典型用法代碼示例。如果您正苦於以下問題:Java Camera.Face方法的具體用法?Java Camera.Face怎麽用?Java Camera.Face使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.hardware.Camera
的用法示例。
在下文中一共展示了Camera.Face方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getFace
import android.hardware.Camera; //導入方法依賴的package包/類
public static Bitmap getFace(Bitmap bitmap, Camera.Face face){
RectF rectF = FaceUtil.transform(face.rect,bitmap.getWidth(),bitmap.getHeight());
//Log.i("s",rectF.left+" "+rectF.top+" "+rectF.right+" "+rectF.bottom+" "+(rectF.right-rectF.left)+" "+(rectF.bottom-rectF.top)+" "+bitmap.getHeight()+" "+bitmap.getWidth());
rectF = checkInBound(rectF,bitmap.getWidth(),bitmap.getHeight());
bitmap = Bitmap.createBitmap(
bitmap,
Math.round(rectF.left),
Math.round(rectF.top),
Math.round(rectF.right)-Math.round(rectF.left),
Math.round(rectF.bottom)-Math.round(rectF.top)
);
return bitmap;
}
示例2: calculate
import android.hardware.Camera; //導入方法依賴的package包/類
public void calculate(Camera.Face face, boolean mirror)
{
conversionMatrix.postRotate(mirror ? 90 : 0);
rect.top = face.rect.top;
rect.left = face.rect.left;
rect.right = face.rect.right;
rect.bottom = face.rect.bottom;
conversionMatrix.mapRect(rect);
if (face.leftEye != null)
{
leftEye[0] = face.leftEye.x;
leftEye[1] = face.leftEye.y;
conversionMatrix.mapPoints(leftEye);
}
if (face.rightEye != null)
{
rightEye[0] = face.rightEye.x;
rightEye[1] = face.rightEye.y;
conversionMatrix.mapPoints(rightEye);
}
if (face.mouth != null)
{
mouth[0] = face.mouth.x;
mouth[1] = face.mouth.y;
conversionMatrix.mapPoints(mouth);
}
}
示例3: onFaceDetection
import android.hardware.Camera; //導入方法依賴的package包/類
@Override
public void onFaceDetection(Camera.Face[] faces, Camera camera) {
if (faces.length > 0) {
Matrix matrix = new Matrix();
boolean frontCamera = (getCameraType() == RCTCameraModule.RCT_CAMERA_TYPE_FRONT);
int height = getHeight();
int width = getWidth();
matrix.setScale(frontCamera ? -1 : 1, 1);
matrix.postRotate(RCTCamera.getInstance().getOrientation());
matrix.postScale(width / 2000f, height / 2000f);
matrix.postTranslate(width / 2f, height / 2f);
double pixelDensity = getPixelDensity();
for (Camera.Face face : faces) {
RectF faceRect = new RectF(face.rect);
matrix.mapRect(faceRect);
WritableMap faceEvent;
faceEvent = Arguments.createMap();
faceEvent.putInt("faceID", face.id);
faceEvent.putBoolean("isFrontCamera", frontCamera);
faceEvent.putDouble("x", faceRect.left / pixelDensity);
faceEvent.putDouble("y", faceRect.top / pixelDensity);
faceEvent.putDouble("h", faceRect.height() / pixelDensity);
faceEvent.putDouble("w", faceRect.width() / pixelDensity);
((ReactContext) getContext()).getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
.emit("CameraFaceDetected", faceEvent);
}
}
}
示例4: getFace
import android.hardware.Camera; //導入方法依賴的package包/類
public Camera.Face getFace(){
return face;
}