I am working with the camera2 API in android and am trying to understand this code I am using. Part of the code goes like this:
previewReader = ImageReader.newInstance(previewSize.getWidth(), previewSize.getHeight(),
ImageFormat.YUV_420_888, 4);
previewReader.setOnImageAvailableListener(imageListener, backgroundHandler);
// This adds another output surface but not sure where this surface comes from..
previewRequestBuilder.addTarget(previewReader.getSurface());
imageListener
is an object from another class that implements android.media.ImageReader.OnImageAvailableListener
and backgroundHandler
is just a background thread. I am not including code for these two or previewRequestBuilder
as they do not seem to be important for understanding my question.
I have searched extensively but it just seems like some magic happens and previewReader
finds some surface somewhere, somehow. According to the documentation, what getSurface()
does is to:
Get a
Surface
that can be used to produceImage
for thisImageReader
Can anyone explain where it gets this?