當前位置:首頁 » 安卓系統 » 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手動對焦,其特點可突出主體,虛化背景,適會拍花卉,靜物等。

熱點內容
c語言乘積函數 發布:2024-11-26 17:43:23 瀏覽:186
unix與linux的關系 發布:2024-11-26 17:38:37 瀏覽:463
中恆牌密碼鎖初始管理密碼是多少 發布:2024-11-26 17:34:54 瀏覽:295
ios手機怎麼玩安卓游戲 發布:2024-11-26 17:08:23 瀏覽:395
sql記錄執行 發布:2024-11-26 17:08:15 瀏覽:8
deb反編譯 發布:2024-11-26 17:04:12 瀏覽:140
ftp站點如何設置 發布:2024-11-26 16:54:48 瀏覽:849
預設存儲器 發布:2024-11-26 16:47:38 瀏覽:14
如何打開雲伺服器的窗口 發布:2024-11-26 16:42:37 瀏覽:844
怎麼自學編程入門 發布:2024-11-26 16:40:58 瀏覽:760