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

🐛 Camera formats are not working consistently on Android #1064

Closed
3 of 4 tasks
bekatd opened this issue May 27, 2022 · 5 comments · Fixed by #1466
Closed
3 of 4 tasks

🐛 Camera formats are not working consistently on Android #1064

bekatd opened this issue May 27, 2022 · 5 comments · Fixed by #1466
Labels
🐛 bug Something isn't working

Comments

@bekatd
Copy link

bekatd commented May 27, 2022

What were you trying to do?

I want to adjust coordinates returned from frame processor plugin to draw points on screen correctly

Reproduceable Code

No response

What happened instead?

Camera formats and everything related to it are completely wrong and broken.

  • width and heights are swapped,
  • unable to set desired formats,
  • also photoWidth and photoHeight of useCameraFormat hook are totally wrong, since the width and height of frame in frameprocessor plugin is for example 640x640 while current cameraformat is 2000x4000 :|
  • also camera feed strangely zooms on different formats
  • also if you log all available formats and look at the format returned by default, you will discover that it can't be found in the available formats :|
  • also on every different device everything works differently and wrongly :|

and #910 should be open too

how all of this is even possible :|

Relevant log output

No response

Device

Android devices

VisionCamera Version

2.13.0

Additional information

@bekatd bekatd added the 🐛 bug Something isn't working label May 27, 2022
@mrousavy
Copy link
Owner

how all of this is even possible :|

Because no code is perfect and I am providing this software without warranty. I built all of it in my free time.

I know that formats on Android are broken, this is because the native CameraX library just sucks. It provides minimal configuration options, and sometimes doesn't work - yet Android docs mention that you should use it and it will be the future of Camera libs on Android, when in reality Camera2 is much more powerful.

I'll gladly work on this issue to refactor the entire API and make it work consistently on both iOS and Android if someone pays me for it, but I won't work hundreds of non-paid hours just because some people complain on GitHub yet offer no actual help/PRs :)

@mrousavy mrousavy changed the title 🐛 Camera formats are totally wrong and broken 🐛 Camera formats are not working consistently on Android May 31, 2022
@bekatd
Copy link
Author

bekatd commented May 31, 2022

You are absolutely right and sorry for my sort-of harsh expression. I would be working on this too, but I doubt my knowledge of native code will be sufficient for anything :(

@garmoshka-mo
Copy link

garmoshka-mo commented Apr 7, 2023

Photo & video sizes not configurable neither with presets nor with format props. (With format you can actually change size - but it will be random on android, not even close to width/height of specified format).

I had to hardcode desired resolution with patch: #868 (comment)

@mrousavy
Copy link
Owner

mrousavy commented Apr 7, 2023

Hey @garmoshka-mo! That patch on iOS is not safe and might crash on a few devices.

On Android; yes, I left a few comments in the codebase warning that this is not accurate on Android due to CameraX's design. I will rewrite the android part to Camera2 in the V3 PR, sponsor me on GitHub to support this effort. I need a lot of free time to do that.

@mrousavy
Copy link
Owner

Hey! I've rewritten the entire Android codebase of VisionCamera from CameraX to Camera2 in the efforts of ✨ VisionCamera V3.

I just now completed the Camera2 rewrite and I believe the core structure is running, but there might be some edge cases to iron out. Can you try and test the PR #1674 for me to see if you can still reproduce this issue here?

Here's an instruction on how you can test that: #1674 (comment)

If the issue cannot be reproduced with that version/PR anymore, then hoorayy, I fixed it! 🎉
Otherwise please let me know and I'll keep this issue open to keep track of it.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants