0

I have been using the Android NDK Camera sample and with it one is able to read the frames with format AIMAGE_FORMAT_YUV_420_888 by using the yuvreader_ inside DrawFrame at 30 Hz. I validated that 30 Hz is achieved by recording the timestamp in each image and printing it. I am using a Samsung Galaxy S9.

I was now trying to obtain JPEG images instead of the YUV ones also at 30 Hz but have not yet succeed and was wondering if someone could help.

From what I understood, the capture session in this sample creates a request for both "preview" and a "still capture", where the yuv is used for preview and jpeg is used for the still capture. What I have done was to set the jpgReader_ as the preview one as well, and then I checked in the timestamp of the frames captured in the ImageCallback here (I commented out the step of writing to file, and just called AImage_delete(image) to clean the buffer instead). However, the result I get is frames with intervals of 33, 66, 99 and 133 ms, quite evenly distributed, so many frames often get skipped.

Any ideas of what the problem could be?

jaraujo
  • 372
  • 2
  • 10

1 Answers1

1

Many camera devices cannot produce 30 jpeg images per second. That's why the camera API explicitly sets YUV (or private) format for preview or video. Few devices are capable of creating 30 Jpegs per second. That's why typical video recording session involves h246 or vp8 encoders.

Alex Cohn
  • 56,089
  • 9
  • 113
  • 307
  • Forgot to mention I am using a Samsung Galaxy s9. I was trying to achiveve this since another user online mentioned that he had used the Android NDK to capture jpegs at 30 Hz on an S7, so I am believing it should be possible :) I should also clarify that I am not interested in previewing this image, but just capture it. I am thinking that there could be something in the capture session settings that is not well configured? One thing that puzzles me is the amount of frames being skipped, so I am most likely doing something wrong.. – jaraujo May 09 '19 at 05:40
  • You can try burst capture, at certain resolutions it can deliver 30 FPS, but usually for short session. – Alex Cohn May 09 '19 at 14:39