Code Monkey home page Code Monkey logo

Comments (10)

inssein avatar inssein commented on June 21, 2024

I tried scanning through the codebase and there doesn't seem to be any resizing happening - was this just a feature of 2.x that is no longer carried over?

from react-native-vision-camera.

zzz08900 avatar zzz08900 commented on June 21, 2024

Would mind clarify what is actually happening (and what is wrong there)?
Is the photo rotated by 90 degrees or?

Are you sure you are selecting the right format for your desired output, not just resizing the camera preview?

from react-native-vision-camera.

mrousavy avatar mrousavy commented on June 21, 2024

Hey-

  1. There's no log output here, which is exactly what I need for these kinds of issues. I don't know how else to explain it than to give Xcode/Android Studio run instructions.
    image
  2. You didn't try in the example app.

Are you using useCameraFormat? That's what selects a format for you.

from react-native-vision-camera.

inssein avatar inssein commented on June 21, 2024

@mrousavy: I added logs via editing, you may have been looking at the email. That said, I'm not quite sure it's the logs you want. You are right about the example app, I can give it a shot later today.

I also haven't tried useCameraFormat yet, because I wasn't sure that was the problem.

If I had to re-describe the problem: I set up the camera with a 4:3 aspect ratio "preview", but when I take the photo, I get something as if the preview was my whole camera screen.

Here is what the preview looks like:
preview

Here is what the photo ends up looking like:
photo

You can see that in the preview, my webcam was not there, but the photo contains my webcam.

from react-native-vision-camera.

mrousavy avatar mrousavy commented on June 21, 2024

Those are not native logs - I need the native logs (from Xcode or Android Studio) - those will tell me what format actually gets selected.

But yes I can answer that question right away then;

I also haven't tried useCameraFormat yet, because I wasn't sure that was the problem.

If I had to re-describe the problem: I set up the camera with a 4:3 aspect ratio "preview", but when I take the photo, I get something as if the preview was my whole camera screen.

The preview view has nothing to do with the photo output - previously in V2 it might have had something to do with it, but now this is fully decoupled (preview can even be disabled with preview={false}). So you want to use useCameraFormat(...) to select a format that has the photo resolution you desire.

Maybe try something like:

const format = useCameraFormat(device, [
  { photoAspectRatio: 4 / 3 }, // or 3 / 4, can't remember which way, sorry
  { photoResolution: 'max' }
])

from react-native-vision-camera.

mrousavy avatar mrousavy commented on June 21, 2024

btw nice mic, is that the blue jeti? I have the same

from react-native-vision-camera.

inssein avatar inssein commented on June 21, 2024

Ah okay, in V2 the preview is exactly what you got when you took the photo, so those two being disconnected concepts is exactly the issue. I tried your tip with the photoAspectRatio, and while it's pretty close, I seem to be getting extra content on all 4 sides (compared to the preview).

Any thoughts on how I'd go about ensuring that the bounds of the preview are exactly the same as the photo I take?

And yeah, that's a Blue Yeti. We had some in the office before the pandemic and I was able to take one home. I hate wearing headphones all day, and the mic does a surprising job of not picking up the speaker output to cancel out echo.

from react-native-vision-camera.

mrousavy avatar mrousavy commented on June 21, 2024

ensuring that the bounds of the preview are exactly the same as the photo I take?

Well yea, make sure your preview is exactly the same aspect ratio as one of the photo sizes.

The photoWidth/photoHeight (or photoSize) values are fixed and given by the Camera hardware. It cannot be flexed/changed on the fly - so you always shoot in those specific formats. V2 wasn't exactly the same as the preview, it might've been a good coincidence that the aspect ratio exactly matched though.

But what you wanna do is figure out which format you want to use, then resize your preview accordingly. or just account for slight aspect ratio mismatches, which is what pretty much every camera app does.

from react-native-vision-camera.

Zoxive avatar Zoxive commented on June 21, 2024

I have a similar issue after upgrading to v4 from v3.

I have my format set to "photoHeight": 1512, "photoWidth": 2688, making it 16:9.

I have a react native view set with its aspect ratio of 9 / 16 for the Preview.

But my preview (set with resizeMode='contain') has blackbars in v4, and when the photo is taken i see extra padding just like what @inssein is noticing.

(This on a pixel 6 pro, "react-native-vision-camera": "^4.0.3")

from react-native-vision-camera.

mrousavy avatar mrousavy commented on June 21, 2024

Preview uses a video stream. So video resolution is what counts.

from react-native-vision-camera.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.