當前位置:首頁 » 安卓系統 » 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 04:16:19 瀏覽:7
安卓手機網路無法使用怎麼辦 發布:2025-01-18 04:12:55 瀏覽:363
摩斯密碼的杠是什麼 發布:2025-01-18 04:06:52 瀏覽:808
winsock搜伺服器ip 發布:2025-01-18 03:49:32 瀏覽:393
安卓手機藍牙默認地址在哪裡 發布:2025-01-18 03:47:57 瀏覽:906
shell腳本文件路徑 發布:2025-01-18 03:40:31 瀏覽:483
sql語句執行錯誤 發布:2025-01-18 03:21:49 瀏覽:651
資料庫雙引號 發布:2025-01-18 03:10:20 瀏覽:79
學java和php 發布:2025-01-18 03:01:03 瀏覽:452
怎麼開伺服器的埠 發布:2025-01-18 02:54:23 瀏覽:648