仿抖音短视频源码开启双目摄像头实时预览

  
 & lt; ? xml 版本=?.0“,编码=皍tf-8" ?比;
  & lt; LinearLayout  xmlns: android=癶ttp://schemas.android.com/apk/res/android"
  ,,,android:取向=皏ertical", android: layout_width=癿atch_parent"
  ,,,android: layout_height=癿atch_parent"比;
  ,,,& lt;按钮
  ,,,,,,,android: id=癅 + id/button2"
  ,,,,,,,android: layout_width=癿atch_parent"
  ,,,,,,,android: layout_height=皐rap_content"
  ,,,,,,,android: layout_weight=?”;
  ,,,,,,,android:文本=胺祷亍?/比;
  ,,,& lt; SurfaceView
  ,,,,,,,android: id=癅 + id/surfaceView1"
  ,,,,,,,android: layout_width=癿atch_parent"
  ,,,,,,,android: layout_height=?00 dp"
  ,,,,,,,android: layout_weight=?“,/比;
  ,,,& lt; SurfaceView
  ,,,,,,,android: id=癅 + id/surfaceView2"
  ,,,,,,,android: layout_width=癿atch_parent"
  ,,,,,,,android: layout_height=?00 dp"
  ,,,,,,,android: layout_weight=?“,/比;
  & lt;/LinearLayout> 
  

  

        <>以前public  class  CameraTestActivity  extends  Activity  implements , SurfaceHolder.Callback {   ,,,public  Button  mButton;   ,,,private  Camera  mCamera1, mCamera2;   ,,,private  SurfaceView  surfaceView1, surfaceView2;   ,,,private  SurfaceHolder  mSurfaceHolder, mSurfaceHolder2;   ,,,private  int  cameraId =, 1;   ,,@Override   ,,,protected  void  onCreate (Bundle  savedInstanceState), {   ,,,,,,,super.onCreate (savedInstanceState);   ,,,,,,,requestWindowFeature (Window.FEATURE_NO_TITLE);   ,,,,,,,setContentView (R.layout.activity_camera);   ,,,,,,,this.setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);   ,,,,,,,initView ();   ,,,,,,,initView2 ();   ,,,,,,,initButton ();   ,,,}   ,,,//视图初始化(摄像头1)   ,,,private  void  initView (), {   ,,,,,,,surfaceView1 =, findViewById (R.id.surfaceView1);//获得SurfaceView的实例   ,,,,,,,mSurfaceHolder =, surfaceView1.getHolder();//获得SurfaceView的保持者   ,,,,,,,mSurfaceHolder.addCallback(这);//设置持有人的回调   ,,,}   ,,,//视图初始化(摄像头2)   ,,,private  void  initView2 () {   ,,,,,,,surfaceView2 =, findViewById (R.id.surfaceView2);//获得SurfaceView的实例   ,,,,,,,mSurfaceHolder2 =, surfaceView2.getHolder();//获得SurfaceView的保持者   ,,,,,,,mSurfaceHolder2.addCallback(这);//设置持有人的回调   ,,,}   ,,,//打开照相机1   ,,,public  void  CameraOpen (), {   ,,,,,,,试一试   ,,,,,,,{   ,,,,,,,,,,,//打开摄像机1   ,,,,,,,,,,,mCamera1 =, Camera.open (cameraId);   ,,,,,,,,,,,mCamera1.setDisplayOrientation (270);   ,,,,,,,,,,,//绑定表面并开启预览   ,,,,,,,,,,,mCamera1.setPreviewDisplay (mSurfaceHolder);   ,,,,,,,,,,,mCamera1.startPreview ();   ,,,,,,,},catch  (IOException  e), {   ,,,,,,,,,,,mCamera1.release ();   ,,,,,,,,,,,mCamera1 =,空;   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null

仿抖音短视频源码开启双目摄像头实时预览