当前位置:首页 » 安卓系统 » androidcamera对焦

androidcamera对焦

发布时间: 2024-06-08 04:12:59

1. 濡备綍瀹炵幇android镓嬫満鎽勫儚澶寸殑镄勮嚜锷ㄥ圭剑

鍙傝冧笅闱㈡柟娉

镙规嵁鐜版湁镄勮祫鏂欐湁濡备笅鍑犵嶏细
1 鏋佺浜虹墿镄勫仛娉曪细 浣跨敤涓涓瀹氭椂鍣锛岃惧畾瀹氭椂镞堕棿锛岀劧钖庝笉闂存柇镄勫圭剑銆
2 鏋佸浜虹墿镄勫仛娉曪细 闾e氨鏄鍒╃敤椹卞姩灞傚疄鐜帮纴浣嗘槸杩欎釜涓鑸浜鸿缮鏄绠椾简钖
3 灏辨湰浜鸿繖镙风殑瑙傚疗绯荤粺镄勫师鐢熺浉链哄缑鐭ワ纴杩欎笢涓滀篃娌$敤瀹氭椂鍣ㄥ晩锛岃矊浼间篃涓嶅彲鑳藉嶆潅鍒板叏鐢ㄩ┍锷ㄦ潵瀹炵幇锛屽嵆浣垮簳灞傜敤镄勬槸C 瀹炵幇锛屼絾鏄鐞呜轰笂璁诧纴google镶瀹氢细鎻愪緵杩欎釜灏佽呭ソ涓滀笢銆备簬鏄鏋沧柇镄勫幓镆ラ槄 DOC 涓鐪嬶纴鍙戠幇鏋灭劧链夎繖涓涓滀笢 锛 浠g爜濡备笅

[java] view plain print?
<strong><span style="font-size:18px">public class MainActivity extends Activity {

private SurfaceView surfaceView;
private SurfaceHolder surfaceHolder;
private boolean flag = false;
private String fileUrl="";
Camera camera;
Camera.Parameters parameters;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);
surfaceView = (SurfaceView) findViewById(R.id.surfaceView1);
Button button=(Button) findViewById(R.id.takepicture);
surfaceHolder = surfaceView.getHolder();
surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
surfaceHolder.setKeepScreenOn(true);
surfaceView.setFocusable(true);
surfaceView.setBackgroundColor(TRIM_MEMORY_BACKGROUND);
surfaceHolder.addCallback(new Callback() {
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
// TODO Auto-generated method stub
camera.stopPreview();
camera.release();
camera=null;

}

@Override
public void surfaceCreated(SurfaceHolder holder) {
// TODO Auto-generated method stub
if(null==camera){
camera=Camera.open();
try {
camera.setPreviewDisplay(surfaceHolder);
initCamera();
camera.startPreview();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

}

@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height){
//瀹炵幇镊锷ㄥ圭剑
camera.autoFocus(new AutoFocusCallback() {
@Override
public void onAutoFocus(boolean success, Camera camera) {
if(success){
initCamera();//瀹炵幇鐩告満镄勫弬鏁板埯濮嫔寲
camera.cancelAutoFocus();//鍙链夊姞涓娄简杩欎竴鍙ワ纴镓崭细镊锷ㄥ圭剑銆
}
}

});
}

});
}
//鐩告満鍙傛暟镄勫埯濮嫔寲璁剧疆
private void initCamera()
{
parameters=camera.getParameters();
parameters.setPictureFormat(PixelFormat.JPEG);
//parameters.setPictureSize(surfaceView.getWidth(), surfaceView.getHeight()); // 閮ㄥ垎瀹氩埗镓嬫満锛屾棤娉曟e父璇嗗埆璇ユ柟娉曘
parameters.setFlashMode(Parameters.FLASH_MODE_TORCH);
parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);//1杩炵画瀵圭剑
setDispaly(parameters,camera);
camera.setParameters(parameters);
camera.startPreview();
camera.cancelAutoFocus();// 2濡傛灉瑕佸疄鐜拌繛缁镄勮嚜锷ㄥ圭剑锛岃繖涓鍙ュ繀椤诲姞涓

}

//鎺у埗锲惧儚镄勬g‘鏄剧ず鏂瑰悜
private void setDispaly(Camera.Parameters parameters,Camera camera)
{
if (Integer.parseInt(Build.VERSION.SDK) >= 8){
setDisplayOrientation(camera,90);
}
else{
parameters.setRotation(90);
}

}

//瀹炵幇镄勫浘镀忕殑姝g‘鏄剧ず
private void setDisplayOrientation(Camera camera, int i) {
Method downPolymorphic;
try{
downPolymorphic=camera.getClass().getMethod("setDisplayOrientation", new Class[]{int.class});
if(downPolymorphic!=null) {
downPolymorphic.invoke(camera, new Object[]{i});
}
}
catch(Exception e){
Log.e("Came_e", "锲惧儚鍑洪敊");
}
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);

return true;
}

}</span></strong>

2. 安卓系统手机专业模式对焦有几种对焦方式有什么拍摄特点,适合拍什么画面

安卓系统手机专业模式有3种对焦方式。1全自动对如链焦其特点是对焦迅速,对焦准确性不高,适合拍突发事件抓拍。2半自动对焦皮缓,其特点人为确定对焦和测光点。适合拍风光,燃橡模人像。3手动对焦,其特点可突出主体,虚化背景,适会拍花卉,静物等。

热点内容
师资配置含哪些内容 发布:2025-01-18 07:17:35 浏览:705
江西脚本 发布:2025-01-18 07:14:38 浏览:391
php中i方法 发布:2025-01-18 07:13:19 浏览:368
FTP宝塔Linux面板 发布:2025-01-18 07:10:05 浏览:395
无线网卡怎么改密码 发布:2025-01-18 06:54:41 浏览:765
ava动态编译 发布:2025-01-18 06:54:39 浏览:764
中国学位论文全文数据库 发布:2025-01-18 06:43:49 浏览:688
全局变量存储类别 发布:2025-01-18 06:39:29 浏览:423
苹果平板的王者号如何转移到安卓 发布:2025-01-18 06:37:11 浏览:611
图片访问量 发布:2025-01-18 06:36:34 浏览:497