Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Update frame buffer size for VisionCamera example #4105

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mrousavy
Copy link
Contributor

@mrousavy mrousavy commented May 6, 2024

Just a tiny detail, it doesn't really matter much but I thought I wanted to clarify this a bit.

There's two formats in video processing; YUV and RGB.
RGB is always BGRA (4 bytes), and YUV is a bi-planar format with a Y plane of 1 byte per pixel, and UV plane of half the size of the image.

For 4k buffers, let's calculate the size of one frame:

  • YUV = Y(3840 × 2160) + UV(3840 × 2160 / 2) = 12 MB
  • RGB = (3840 × 2160 × 4) = 33 MB

While VisionCamera implements optimizations to trim the buffers and uses YUV or even compressed YUV whenever possible, almost 90% of the times people need to use RGB because the ML models just work in RGB.

So the exact number would be 33.177.600 bytes for a Frame, which is 1.990.656.000 bytes per second (or ~2 GB per second) of data flowing through the Frame Processor.

Thank to JSI it does not matter how big the data is, because we only pass references without making any copies or serialization - this is the part that should be highlighted here.

Just a tiny detail, it doesn't really matter much but I thought I wanted to clarify this a bit.

There's two formats in video processing; YUV and RGB.

For 4k buffers, let's calculate the size of one frame:

- YUV = Y(3840 × 2160) + UV(3840 × 2160 / 2) = 12 MB
- RGB = (3840 × 2160 × 4) = 33 MB

RGB is always BGRA (4 bytes), and YUV is a bi-planar format with a Y plane of 1 byte per pixel, and UV plane of half the size of the image.

While VisionCamera implements optimizations to trim the buffers and uses YUV or even compressed YUV whenever possible, almost 90% of the times people need to use RGB because the ML models just work in RGB.

So the exact number would be 33.177.600 bytes for a Frame, which is 1.990.656.000 bytes per second (or ~2 GB per second) of data flowing through the Frame Processor.

Thank to JSI it does not matter how big the data is, because we only pass references without making any copies - this is the part that should be highlighted here.
Copy link

netlify bot commented May 6, 2024

Deploy Preview for react-native ready!

Name Link
🔨 Latest commit 57c1430
🔍 Latest deploy log https://app.netlify.com/sites/react-native/deploys/6638ba18f6701a0008c58747
😎 Deploy Preview https://deploy-preview-4105--react-native.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants