Skip to content

Conversation

camsim99
Copy link
Contributor

@camsim99 camsim99 commented Sep 16, 2025

When NV21 image format is requested for streaming images, this PR ensures that:

  1. The NV-21 compatible (but actually YUV_420_888) three planes per image are converted to a single NV21 plane (Y + interleaved VU planes).
  2. The single CameraImagePlane created has overridden raw and camera image format NV21.*

This should make this package compatible with google_ml_kit_flutter 🤞 I tested this change with the Barcode scanner example. Fixes flutter/flutter#174923.

*The conversion will fail if the image is actually not NV21 compatible for some reason, so this should never be a false positive.

Pre-Review Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. 2 3

Copy link
Contributor Author

@camsim99 camsim99 Sep 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is directly inspired by this camera_android code that came from Google MLKit. I made some changes the methods to (1) take in the objects I want and (2) for planesToNV21, I worked off of yuv420ThreePlanesToNV21 but deleted lots of logic and added an exception. So, I'm not sure what to do here....

Should I also link to https://github.com/googlesamples/mlkit/blob/master/android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/BitmapUtils.java and call it a day or are there more license implications?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stuartmorgan-g Do you know what we should do in cases like this by chance?

@camsim99 camsim99 marked this pull request as ready for review September 17, 2025 21:06
@camsim99 camsim99 requested review from jesswrd and a team September 17, 2025 21:07
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.

[camera_android_camerax] Wrong ImageFormatGroup for nv21 causes ML Kit incompatibility
1 participant