Camera.Size size = mtCamera.getParameters().getPreviewSize(); YuvImage yuvImage = new YuvImage(mData, ImageFormat.NV21, size.width, size.height, null); yuvImage.compressToJpeg(new Rect(0, 0, size.width, size.height), 100, mBitmapOutput); options.inPreferredConfig = Bitmap.Config.RGB_565; bitmap = BitmapFactory.decodeByteArray(mBitmapOutput.toByteArray(), 0, mBitmapOutput.toByteArray().length, options); mBitmapOutput.reset(); bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), mMatrix, false);
detector = new FaceDetector(source.getWidth(),source.getHeight(), maxFaceNum); Face[] faces = new Face[maxFaceNum]; detector.findFaces(source, faces);
public void setCameraDisplayOrientation (Activity activity, int cameraId, android.hardware.Camera camera) {
android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo();
android.hardware.Camera.getCameraInfo (cameraId , info);
int rotation = activity.getWindowManager ().getDefaultDisplay ().getRotation ();
int degrees = 0;
switch (rotation) {
case Surface.ROTATION_0:
degrees = 0;
break;
case Surface.ROTATION_90:
degrees = 90;
break;
case Surface.ROTATION_180:
degrees = 180;
break;
case Surface.ROTATION_270:
degrees = 270;
break;
}
int result;
if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
result = (info.orientation + degrees) % 360;
result = (360 - result) % 360; // compensate the mirror
} else {
// back-facing
result = ( info.orientation - degrees + 360) % 360;
}
mOrienta = result;//该值有其它用途
camera.setDisplayOrientation (result);
}
//mOrienta来源于setCameraDisplayOrientation
mMatrix = new Matrix();
switch (mOrienta){
case 90:
mMatrix.postRotate(270);
break;
case 270:
mMatrix.postRotate(90);
break;
default:
mMatrix.postRotate(mOrienta);
break;
}
BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize =2; options.inPreferredConfig = Bitmap.Config.RGB_565; bitmap = BitmapFactory.decodeByteArray(mBitmapOutput.toByteArray(), 0, mBitmapOutput.toByteArray().length, options);
Camera.Parameters parameters = mCamera.getParameters(); parameters.setPreviewFrameRate(3);//设置每秒3帧,没有效果
public void onPreviewFrame(byte[] data, Camera camera) {
Logger.i(TAG+"收到相机回调:onpreviewframe()"+index);
if(data!=null&&data.length>0&&System.currentTimeMillis()-time>200){
time=System.currentTimeMillis();
mFaceHandle.post(new FaceThread(data,camera,(++index)));
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有