Effectively get bitmaps from TextureView

I am trying to get every frame from a TextureView , unfortunately trying:

 textureView.getBitmap(); 

Slow performance results are a faster way to get a bitmap. Is it better to use NDK?

Search for actual examples

+5
source share
2 answers

TextureView receives frames on a SurfaceTexture, which receives frames sent to its surface and converts them to a GLES texture. To get pixel data, the texture needs to be mapped to the framebuffer and then read out using glReadPixels() . Then, pixel data can be wrapped with a Bitmap object (which may or may not include copying pixel data).

Using NDK will not bring you much benefit, since all the code that needs to be run quickly is already implemented initially.

You can see some improvement by sending the data directly to SurfaceTexture and doing the GLES work yourself, but presumably you want to display the incoming frames in a TextureView, so all you could save is the Bitmap overhead (which may or may not be significant) .

This can help if you explain in your question where the personnel are coming from and what you want to do with them.

+3
source

One way to optimize is to run in the background in an asynchronous task as follows:

 private class AsyncTaskRunner extends AsyncTask<> { @Override protected void doInBackground() { // this is where you put long operations in background textureView.getBitmap(); } } 
-4
source

Source: https://habr.com/ru/post/1245872/


All Articles