Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Draft: [camera_android] Add support for NV21 image format on android (part 3/3) #7023

Closed
wants to merge 28 commits into from

Conversation

acoutts
Copy link
Contributor

@acoutts acoutts commented Jan 25, 2023

This PR adds NV21 as an image stream format for android devices. This is the format required for things like MLKit. Unfortunately a lot of people tend to implement the yuv->nv21 conversion incorrectly in dart, which results in countless issues of users saying the image stream doesn't work, or that mlkit doesn't work.

See the linked issue below which links to a multitude of issues which claim the image stream doesn't work but are almost surely because of incorrect conversion of YUV to NV21.

By allowing the plugin to send NV21 to dart, this will greatly simplify the workflow to consume the image stream and should reduce the number of issues falsely claiming the image stream is broken or corrupted.

Highlights:

  • Added an abstraction around ImageReader called ImageStreamReader and moved the image stream logic into this class to clean up the Camera class. This allows us to test the image stream handler in isolation.
  • Added tests for ImageStreamReader.
  • Added a new utility class called ImageStreamReaderUtils which contains the logic for trimming padding and converting YUV to NV21.
  • Added tests for ImageStreamReaderUtils.

Note: we need #7021 to be merged and published first.

List which issues are fixed by this PR. You must list at least one issue.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/plugins repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.
  • I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

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

@acoutts
Copy link
Contributor Author

acoutts commented Jan 25, 2023

Note: still working on updating tests for this one.

@acoutts
Copy link
Contributor Author

acoutts commented Jan 25, 2023

cc @camsim99

@stuartmorgan-g
Copy link
Contributor

Marking as draft until #6985 is reviewed.

@stuartmorgan-g stuartmorgan-g marked this pull request as draft February 14, 2023 21:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants