问题
Current my device Raspberry pi model 3 on Android Things (Oreo 8.1)
first I try camera device open, and clicked capture button, get camera preview jpg file.
my source
private CameraDevice mCameraDevice;
private CameraCaptureSession mCaptureSession;
private ImageReader mImageReader;
private CaptureRequest.Builder captureBuilder;
private final TextureView.SurfaceTextureListener mSurfaceTextureListener = new TextureView.SurfaceTextureListener() {
   @Override 
   public void onSurfaceTextureAvailable(SurfaceTexture texture, int width, int height) {
        openCamera(width, height);
    }
   ...
}
private void openCamera(int width, int height) {
    //camera open ...
    CameraManager manager = (CameraManager) activity.getSystemService(Context.CAMERA_SERVICE);
    mImageReader = ImageReader.newInstance(320, 240, ImageFormat.JPEG, 1);
    manager.openCamera(cameraId, mStateCallback, mBackgroundHandler);
}
//Camera preview check
private final CameraDevice.StateCallback mStateCallback = new CameraDevice.StateCallback() {
    @Override
    public void onOpened(CameraDevice cameraDevice) {
        mCameraDevice = cameraDevice;
        createCameraPreviewSession();
    }
    ...
};
//create a new CameraCaptureSession for camera preview
private void createCameraPreviewSession() {
   try {
       SurfaceTexture texture = mTextureView.getSurfaceTexture();
       assert texture != null;
       // We configure the size of default buffer to be the size of camera preview we want.
        texture.setDefaultBufferSize(mPreviewSize.getWidth(), mPreviewSize.getHeight());
        // This is the output Surface we need to start preview.
        Surface surface = new Surface(texture);
        // We set up a CaptureRequest.Builder with the output Surface.
        mPreviewRequestBuilder
                = mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
        mPreviewRequestBuilder.addTarget(surface);
        mCameraDevice.createCaptureSession(Arrays.asList(surface, mImageReader.getSurface()), new CameraCaptureSession.StateCallback() {
             @Override
             public void onConfigured(CameraCaptureSession cameraCaptureSession) {
                 mCaptureSession = cameraCaptureSesssion;
                 updatePreview();
             }
             @Override
             public void onConfiguredFailed(CameraCaptureSession cameraCaptureSession) {
             }
          }, null);
     } catch (CameraAccessException e) {
     }
 }
this source is success camera preview and camera capture on SamSung galaxy 8 device.
but raspberry pi 3 not open camera preview and fail capture.
raspberry pi always call onConfigureFailed on createCameraPreviewSession.
log
 W/CameraDevice-JV-0: Stream configuration failed due to: endConfigure:372: Camera 0: Unsupported set of inputs/outputs provided
 E/CameraCaptureSession: Session 0: Failed to create capture session; configuration failed
so I changed this part
mCameraDevice.createCaptureSession(Arrays.asList(surface, mImageReader.getSurface()), new CameraCaptureSession.StateCallback() {
--> change
mCameraDevice.createCaptureSession(Arrays.asList(surface), new CameraCaptureSession.StateCallback() {
this source is camera open on raspberry pi. but not work capture.
How to camera preview capture on raspberry pi 3 android things?
if you know please advice me
thanks.
来源:https://stackoverflow.com/questions/51300315/fail-configuration-when-use-camera2-createcapturesession-on-raspberry-pi-3-and