-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Stretched camera image 🐛 #2364
Comments
Same here! |
As a workaround, you can set the width and height to x2 and change them to the required values after the camera is initialized ( Example: const device = useCameraDevice(isInitialized || isIOS ? props.position : 'front'); This is a very nasty bug, but if you need to use this version, you can do as I indicated above |
Same issue + sometimes onInitialized callback does not trigger :( |
|
Share your latest code here |
Well, that explains my problem. I'm trying to set isActive inside onInitialized, that's what makes sense for me. Ty Igor! |
This didn't work for me. The image is still opening stretched. |
Did you try to change width and height after initialization? |
Fixed in a8b85a3 |
Works for me! It's not the ideal fix for the problem, but resolves my problem right now, thank you! |
I'm experiencing strange behavior; it's also stretched horizontally for me. I'm trying to adjust the styles in onInitialized. If I set the width and height like this:
It remains stretched, but if, for example, I do it like this:
Then it looks normal, but obviously, this is not a solution. |
I'm using flex: 0 and flex: 1. Works fine |
Try to use a larger value before initialization. Your solution works because you gave a smaller value of height after initialization |
Hey! After 8 hours of debugging, I finally found the culprit! I fixed the preview stretching issue in this PR: #2377 If you appreciate my dedication and free support, please consider 💖 sponsoring me on GitHub 💖 so I can keep providing fixes and building out new features for my open-source libraries in my free time. |
hey @mrousavy ! Thank you so much for everything you do and your fast responses. I've tried the version |
I tried the new version 3.7.1 with the fix but the issue still on OnePus 5T and Xiaomi Mi 9 L |
Still happening on v3.7.1, i'm using RN 0.72.4, Android 12, Redmi Note 5 Pro |
Same issue for me. If I set isActive to true only when camera is initialized then it works for the first time I open the camera. Then it has the same issue when I unmount the camera and remount later in the app. Only workaround that worked is to set isActive true->false->true forcing a rerender on the camera preview fixes the stretch. |
Still see the error on 3.7.1, it seems to work when the code scanner is being used but we also use another camera where it is not being used and it doesnt. |
That's weird. Can you try to move this line here up two lines: react-native-vision-camera/package/android/src/main/java/com/mrousavy/camera/core/PreviewView.kt Line 23 in d747933
(so outside of the UiThreadUtil thingy) and see if that fixes anything? |
Try to set aspectRatio 4/3 for example and set width and height of camera based on aspect ratio |
@mrousavy I tried your fix with holder, but unfortunately it did not solve the issue |
I’ve also experienced that setting the width and height to match camera format ratio (4:3) the preview is zoomed in compared to the photo taken. EDIT: it's forcing the preview content to be device screen ratio instead of format ratio @mrousavy |
Are y'all using a |
I do. const format = useCameraFormat(device, [
{ photoAspectRatio: 4 / 3 },
{ photoResolution: { width: 1280, height: 960 } },
{ photoHdr: true }
]); |
I wasn’t, just setting the back camera. I was noticing the issue more when in portrait but would work
…________________________________
From: Richard Petercsak ***@***.***>
Sent: Monday, January 15, 2024 9:16:34 AM
To: mrousavy/react-native-vision-camera ***@***.***>
Cc: James Parsons ***@***.***>; Comment ***@***.***>
Subject: Re: [mrousavy/react-native-vision-camera] Stretched camera image 🐛 (Issue #2364)
Are y'all using a format?
I do.
const format = useCameraFormat(device, [
{ photoAspectRatio: 4 / 3 },
{ photoResolution: { width: 1280, height: 960 } },
{ photoHdr: true }
]);
—
Reply to this email directly, view it on GitHub<#2364 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AEEFT4ZECL72DPEYCQPQLBLYOTXXFAVCNFSM6AAAAABBTAPOOSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOJRGY2DGNJYGY>.
You are receiving this because you commented.Message ID: ***@***.***>
|
It wasn’t just limited to orientation as the issue was in portrait, I just noticed it worked in landscape and thought it may help. The main one for me would be turning on code scanner would also make it work.
Thanks
James Parsons
Founder
[signatureImage]
T: 020 3693 3769
M: 07969363020
W: parsonsgreenmedia.com<https://parsonsgreenmedia.com/>
[A black and white logo Description automatically generated]<https://www.crowncommercial.gov.uk/agreements/RM1043.8>
…________________________________
From: Marc Rousavy ***@***.***>
Sent: Monday, January 15, 2024 9:34:37 AM
To: mrousavy/react-native-vision-camera ***@***.***>
Cc: James Parsons ***@***.***>; Comment ***@***.***>
Subject: Re: [mrousavy/react-native-vision-camera] Stretched camera image 🐛 (Issue #2364)
Again, landscape (or orientation in general) is not yet supported. It's the top number one pinned issue in the repo.
As for the stretched preview in portrait @r1cs1<https://github.com/r1cs1> - I don't know, I cannot reproduce it. Please create a new issue with adb logcat logs and screenshots, otherwise I can't help
—
Reply to this email directly, view it on GitHub<#2364 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AEEFT47Q6NTIXQ3TYBSNIELYOTZ23AVCNFSM6AAAAABBTAPOOSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOJRGY4DSMJUGA>.
You are receiving this because you commented.Message ID: ***@***.***>
|
@mrousavy Thanks for your great work on this plugin. I can reproduce this in the example app just by commenting out the video and frameProcessor props in
On a Pixel 7a running Android 14, when I open the example app from cold after making these changes, the preview is distorted, similar to the screenshot at the top of this issue. Here's a short screencap showing the issue. It's probably not as clear from the video as it is in person, but you can see that the iPhone image on the react-native-vision-camera website is skewed and very narrow. vision-camera.mp4These are all the logs shown in
These are the adb logs for the example app: com.mrousavy.camera.example adb logs
If you need me to do any specific debugging, or would prefer I open a new issue, do let me know. Thanks! |
Thanks, will try to investigate this! |
Hi ! I have reproduced "stretched camera image" on Android on version 3.7.1.
"stretched camera image" is just on the screen, and when I take a photo, the output was normal (no stretch on the output photo) On iOS, all thing is Ok. this is my instance (I use Back Camera).
Hope it will help you to investigate |
I'd need the |
Hi @mrousavy here is a part of logcat. |
This behavior is also reproduced on Android with the latest 3.8.0 release. But when I switch to front camera then back to Back camera, the image looks good. |
Hey - orientation is not yet supported. See #1891 |
I was using version 2.16.7, which was functioning well in all orientations. However, with the new version, I am encountering issues. Is there an estimate of how long it will take to resolve this issue and make it work again? |
Read the discussion in #1891, that'll answer your questions. |
Same here. Also there's another workaround:
|
Fyi for anyone else following this, it seems this might be a duplicate of #2142. There's some more discussion there, including some potential workarounds. |
yup 👍 |
Created a PR to fix this issue once and for all: #2519 💪🚀 Try the PR and see if it works (by checking out that branch and running the example app) |
Hi @mrousavy . I downloaded version 3.9.1 and the problem persists |
I confirm the problem. |
I am reporting from version 3.8.2, samsung galaxy a70, the problem continues, the latest versions crash the application for a reason I do not understand. |
I think i have a temporary solution to this. Make a state called const [isInitialized, setIsInitialized] = useState<boolean>(false); Put this prop to <Camera
onInitialized={() => {
setIsInitialized(true);
}}
{...yourProps}
/> Now, we need to update style prop whenever isInitialized changes. <Camera
style={
isInitialized
? {
position: "absolute",
top: 0,
left: 0,
right: 0,
bottom: 0,
}
: {
width: 0,
height: 0,
}
}
{...yourProps}
/> Spent my 4 hours debugging this so you dont have to. Dont forget, it is temporary solution and this needs to be fixed. |
Thank you for your solution, it really solve it temporarily, but when you try to open the camera with fast login on slow devices or in unexpected situations, the preview still stretched. Even if I tried a little with the module codes, I saw that it was solved in the latest version. I recommend you to use the 4.0.0-beta.5 version. |
My camera doesn't open at all on version 4.0.0-beta.5
|
V4 is not meant for the public yet, that's why it's a beta and not even merged to main. |
So is the camera stretching issue on Android fixed in 4.x ? I am using 4.0.1 and still see the same issue? Thanks |
…ion `4.3.1` (#6216) ## Short description This PR upgrades the `react-native-vision-camera` version to the v.`4.3.1` that fixes two of the bugs that are also reported in their issues. 1. [IOBP-879] The Camera is working fine on most devices. However, there are a few on which it just won't work. The camera will simply try to load and stay black. (mrousavy/react-native-vision-camera#2716) 2. [IOBP-880] On some devices the camera image appears horizontally stretched (mrousavy/react-native-vision-camera#2364) ## How to test - Please test this PR on a real device to check that the camera is working correctly from the Scan section tab bar. [IOBP-879]: https://pagopa.atlassian.net/browse/IOBP-879?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [IOBP-880]: https://pagopa.atlassian.net/browse/IOBP-880?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ --------- Co-authored-by: Fabio Bombardi <[email protected]>
I resolve this issue on Android devices using a specific combination of approaches. I'm unsure if it will work for you, but I have confirmed it on two different projects. for React Native 0.71.0 and also make sure this
Initialize the camera devices
set the format of the video or pitcher
|
What's happening?
I am experiencing an issue with the camera view in my React Native app where the camera image appears horizontally stretched. I am using version 3.7.0 of the react-native-vision-camera library.
However, in development, when I make some changes inside the style and save, it updates the application and corrects the stretching issue. However, I can't track down the error.
Reproduceable Code
Relevant log output
Camera Device
Device
Samsung galaxy A10
VisionCamera Version
3.7.0
Can you reproduce this issue in the VisionCamera Example app?
No, I cannot reproduce the issue in the Example app
Additional information
The text was updated successfully, but these errors were encountered: