新聞中心

EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 獲取Android設(shè)備上的詳細(xì)的攝像頭信息

獲取Android設(shè)備上的詳細(xì)的攝像頭信息

作者: 時(shí)間:2016-10-08 來源:網(wǎng)絡(luò) 收藏

本文引用地址:http://www.2s4d.com/article/201610/305681.htm

package=wjh.android.takepicture

android:versionCode=1

android:versionName=1.0>

package=wjh.android.takepicture

android:versionCode=1

android:versionName=1.0>

** main.xml

view plaincopy to clipboardprint?

android:orientation=vertical

android:layout_width=fill_parent

android:layout_height=fill_parent

>

android:layout_width=fill_parent

android:layout_height=fill_parent

/>

android:orientation=vertical

android:layout_width=fill_parent

android:layout_height=fill_parent

>

android:layout_width=fill_parent

android:layout_height=fill_parent

/>

** MainActicity

view plaincopy to clipboardprint?

public class MainActicity extends Activity {

private Camera camera;

private boolean preview = false ;

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

/*

*設(shè)置窗口屬性:一定要在 setContentView(R.layout.main) 之前

*/

// 窗口標(biāo)題

requestWindowFeature(Window.FEATURE_NO_TITLE);

// 全屏

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

setContentView(R.layout.main);

SurfaceView surfaceView = (SurfaceView) findViewById(R.id.surfaceView);

surfaceView.getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

surfaceView.getHolder().setFixedSize(176, 164);

surfaceView.getHolder().addCallback(new SurfaceViewCallback());

}

private final class SurfaceViewCallback implements Callback {

/**

* surfaceView 被創(chuàng)建成功后調(diào)用此方法

*/

@Override

public void surfaceCreated(SurfaceHolder holder) {

/*

* 在SurfaceView創(chuàng)建好之后 打開攝像頭

* 注意是 android.hardware.Camera

*/

camera = Camera.open();

Camera.Parameters parameters = camera.getParameters();



關(guān)鍵詞:

評(píng)論


相關(guān)推薦

技術(shù)專區(qū)

關(guān)閉