android5.1双摄像头
各位 有谁弄过双usb摄像头的我在应用getNumberOfCameras()可以得到数目为2 但是就是不能同时使用 是不是HAL层不支持,应该修改哪里,麻烦知道的指点一下 {:4_137:} 附上 应用代码{
private Camera mBackCamera;
private Camera mFrontCamera;
private BackCameraPreview mBackCamPreview;
private FrontCameraPreview mFrontCamPreview;
public static String TAG = "DualCamActivity";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dual_cam);
Log.i(TAG, "Number of cameras: " + Camera.getNumberOfCameras());
// Create an instance of Camera
mBackCamera = getCameraInstance(0);
// Create back camera Preview view and set it as the content of our activity.
mBackCamPreview = new BackCameraPreview(this, mBackCamera);
FrameLayout backPreview = (FrameLayout) findViewById(R.id.back_camera_preview);
backPreview.addView(mBackCamPreview);
mFrontCamera = getCameraInstance(1);
mFrontCamPreview = new FrontCameraPreview(this, mFrontCamera);
FrameLayout frontPreview = (FrameLayout) findViewById(R.id.front_camera_preview);
frontPreview.addView(mFrontCamPreview);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.dual_cam, menu);
return true;
}
public static Camera getCameraInstance(int cameraId){
Camera c = null;
try {
c = Camera.open(cameraId); // attempt to get a Camera instance
}
catch (Exception e){
// Camera is not available (in use or does not exist)
Log.e(TAG,"Camera " + cameraId + " not available! " + e.toString() );
}
return c; // returns null if camera is unavailable
}
} 好牛啊求指导 确实需要改HAL层,我们公司有个改了,就可以两路同时预览。 charein 发表于 2017-6-15 10:47
确实需要改HAL层,我们公司有个改了,就可以两路同时预览。
你们的应用demo 可否参考下{:4_89:} carter123456 发表于 2017-6-5 14:56
好牛啊求指导
没有你想的复杂 请教楼主怎么获取到两个相机的?我的一个内置,一个usb,只能返回内置的相机,但是在dev目录下有video1; 期待共享 {:5_250:} charein 发表于 2017-6-15 10:47
确实需要改HAL层,我们公司有个改了,就可以两路同时预览。
能否参考下 要看看报的错误信息,3288 USB带宽受限。修改了支持了2个camera后,要确保2个camera在不同的USB host上,才能实现双USB camera同时预览
页:
[1]
2