You do not need to use TangoCameraPreview to get frames in Java. Itβs really just a convenience class that helps you get videos on screen. It seems to be fully implemented in Java with calls to com.google.atap.tangoservice.Tango (i.e. there are no calls to the unpublished APIs). In fact, if you look at the Tango SDK jar file, you will see that someone accidentally included a version of the source file - it has some diff annotations and may not be relevant, but studying this is still instructive.
I prefer not to use TangoCameraPreview and instead call Tango.connectTextureId() and Tango.updateTexture() to load the frame pixels into the OpenGL texture, which I can then use, but I want. This is exactly what TangoCameraPreview does under the hood.
The best way to capture a frame in pure Java is to draw the texture in the exact size (1280x720) to the off-screen buffer and read it back. It also has the side effect of texture conversion from any YUV format it has in RGB (which may or may not be desirable). In OpenGL ES, you do this with framebuffer and renderbuffer .
Adding framebuffer / renderbuffer material to a program that can already display on the screen does not have much code - about the same level as saving the file, but it is difficult to do this when you do it for the first time. I created an application for Android Studio , which saves the texture of Tango as a PNG to a folder with pictures (when you click on the screen) in case it is useful for everyone.
source share