-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Hello Snapchat Team,
I am currently developing an Android camera application using the Camera2 API. My implementation involves creating a SurfaceTexture and a CaptureSession as shown below:
@Override
public void onOpened(CameraDevice camera) {
SurfaceTexture surfaceTexture = new SurfaceTexture(10);
surfaceTexture.setDefaultBufferSize(width, height);
Surface surface = new Surface(surfaceTexture);
try {
camera.createCaptureSession(Arrays.asList(surface), new CaptureSessionCallback(), cameraThreadHandler);
} catch (CameraAccessException e) {
// Handle exception
}
}
I am looking to integrate this setup with the CameraKit SDK. According to the SDK documentation and sample code, I understand that I should first detach the SurfaceTexture from any GL context before using it as an input for CameraKit. The relevant SDK sample for creating a session input appears as follows:
val input = inputFrom(
surfaceTexture = inputSurfaceTexture,
width = inputTextureSize.width,
height = inputTextureSize.height,
facingFront = true,
rotationDegrees = 0,
horizontalFieldOfView = DEFAULT_IMAGE_INPUT_FIELD_OF_VIEW,
verticalFieldOfView = DEFAULT_IMAGE_INPUT_FIELD_OF_VIEW
)
The documentation notes the necessity of detaching the texture from any GL context to prevent conflicts:
// It is a must to always detach the texture from a GL context before connecting the texture as an input to CameraKit where the texture gets attached to an internal GL context.
For some reasons related to my application's design, I have my own GL context and need to ensure that CameraKit's outputs are compatible with it. Here are my questions:
How can I properly detach the GL context from the camera SurfaceTexture?
How can I either pass my own GL context as a sharedContext to CameraKit, or alternatively, obtain the CameraKit GL context to use as a sharedContext for managing this integration?
I appreciate any guidance or examples you could provide to help resolve this issue.
Thank you for your assistance.