get JPEG buffer from camera view

apologise in advance if I ask in wrong category

Does expo have a ready to use camera view feature to get single frame buffer as jpeg byte array (without taking photo) ? I asked few times in a react native fb group, and tried googling, but no useful answer.

any help is greatly appreciated !

Hi. I’ve moved your post to the Expo SDK category. I think it fits better there :slight_smile:

I think what you’re asking for is basically as follows:

You want the camera to capture a shot/frame, but instead of saving it to a file you want to get access to that (e.g. as a string).

My understanding of how React Native (and therefore Expo) works is that the camera hardware would be controlled by native code and for this data to be sent back to your JavaScript code it would need to be copied over the “bridge”. Copying large amounts of data over the bridge is slow, so that needs to be avoided as far as possible.

e.g. if an app needs to take a photograph and upload it to a server it’s better to get the native code to take a photo, save it to a file and return just the URL of the file to the JavaScript code. Then the JavaScript code can call into some more native code to upload that file. That way the actual file contents don’t need to be copied over the bridge.

In your case it seems that the actual data would need to be copied over the bridge. But if you give us more information about what you’re trying to accomplish, maybe there’s a way to avoid this.

Unfortunately I don’t believe Expo currently has a way to take the photo and somehow store/return it as a string/blob instead of saving it to a file.

Expo used to have some experimental AR functionality. Maybe something like that could be used for what you’re trying to do? If I were you I’d do some searching for info on “react native AR”.

hey thanks for the help.
my old code, I was using delphi. The cameraview like you mentioned, is indeed “copied” to the bridge before I was able to grab a stills. It would be then sent to Azure/AWS facial recognition api to do it’s thing.

I’ll check out that AR. thanks very much for the response !

Evan Bacon has just posted the following example of using Tensorflow with Expo. It seems like it might be similar to what you’re trying to do. Also, Expo has face detection built in.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.