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

[react-native] Add "rotation" property to TensorCamera to allow users to rotate camera view and internal texture #5804

Merged
merged 5 commits into from
Nov 3, 2021

Conversation

jinjingforever
Copy link
Collaborator

@jinjingforever jinjingforever commented Nov 1, 2021

This is needed to support orientation change on iOS. The idea is to add a rotation property to TensorCamera. Once it is set, TensorCamera will rotate the internal texture and the preview image for the given degrees. Thanks @nicholasio for the original fix.

For Android, users can ignore this property because Android will automatically rotate the camera texture within the system.

Will send another PR in tfjs-examples that demonstrates how this is used.

Fixes #3041 #2987

To see the logs from the Cloud Build CI, please join either our discussion or announcement mailing list.


This change is Reviewable

Copy link
Collaborator

@pyu10055 pyu10055 left a comment

Choose a reason for hiding this comment

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

thanks, couple small comments, feel free to merge after addressing those.

Reviewable status: :shipit: complete! 1 of 1 approvals obtained (waiting on @jinjingforever)


tfjs-react-native/src/camera/camera.ts, line 197 at r1 (raw file):

  tf.util.assert(
      [0, 90, 180, 270, 360, -90, -180, -270].includes(rotation),

0 and 360 would not have any effect on the texture of the camera?


tfjs-react-native/src/camera/camera_stream.tsx, line 105 at r1 (raw file):

 *   control on when rendering happens.
 * - __rotation__: number — the degrees that the internal camera texture and
 *   preview will be rotated.

add the allowed value list to the doc?

Copy link
Collaborator Author

@jinjingforever jinjingforever left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 1 of 1 approvals obtained (waiting on @pyu10055)


tfjs-react-native/src/camera/camera.ts, line 197 at r1 (raw file):

Previously, pyu10055 (Ping Yu) wrote…

0 and 360 would not have any effect on the texture of the camera?

Correct. The rotation done in the shader would be a no-op.


tfjs-react-native/src/camera/camera_stream.tsx, line 105 at r1 (raw file):

Previously, pyu10055 (Ping Yu) wrote…

add the allowed value list to the doc?

Done.

@jinjingforever jinjingforever merged commit d89b7ed into master Nov 3, 2021
@jinjingforever jinjingforever deleted the fixrnorientation branch November 3, 2021 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants