1

In class, Camera was a method like

public abstract void onPreviewFrame (byte[] data,  Camera camera)

where I can to receivebyte[] data and change picture but Camera is depreciated at this moment

Is there a method in Camera 2 like onPreviewFrame, which returns data I want to impose a filter on a picture in TextureView from Camera

Jasurbek
  • 2,946
  • 3
  • 20
  • 37

1 Answers1

0

In camera2 API has been changed completely. You can grab frames inside OnImageAvailableListener

Here I post my part of working code to grab the frames.

readerListener = new ImageReader.OnImageAvailableListener() {
                @Override
                public void onImageAvailable(ImageReader reader) {

                  image = reader.acquireLatestImage();
                if(image == null){
                    //System.out.println("it is null image"); // image reader did not get new image
                    return;
                }
                Image.Plane[] planes = image.getPlanes();
                  if(planes[0].getBuffer() == null){ // here 0 indicates first target I set in outputSurfaces list
                      System.out.println("it is null object reference of planes");
                    return;
                  }
                 //.... do whatever you want here

                //After you are done with an image then close it 
               image.close(); 

               }
}

For more info, you can have a look to Google samples

Jasurbek
  • 2,946
  • 3
  • 20
  • 37