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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Square ratio preview has low quality #2855

Closed
4 of 5 tasks
ppanwin10 opened this issue May 7, 2024 · 6 comments
Closed
4 of 5 tasks

馃悰 Square ratio preview has low quality #2855

ppanwin10 opened this issue May 7, 2024 · 6 comments
Labels
馃悰 bug Something isn't working

Comments

@ppanwin10
Copy link

ppanwin10 commented May 7, 2024

What's happening?

Hi,

I am not sure if I miss anything, I have the following setup for the camera format:

 const screenAspectRatio = 1 / 1
 const format = useCameraFormat(device, [
    { fps: targetFps },
    { videoAspectRatio: screenAspectRatio },
    { videoResolution: 'max' },
    { photoAspectRatio: screenAspectRatio },
    { photoResolution: 'max' },
  ])

ResizeMode = "contain"

The preview quality for all kinds of ratios (e.g. 16:9, 4:3) are high enough, except for 1:1.

RPReplay_Final1715105964.MP4

Reproduceable Code

<ReanimatedCamera
                style={StyleSheet.absoluteFill}
                device={device}
                isActive={isActive}
                ref={camera}
                onInitialized={onInitialized}
                onError={onError}
                onStarted={() => 'Camera started!'}
                onStopped={() => 'Camera stopped!'}
                format={format}
                fps={fps}
                photoHdr={photoHdr}
                videoHdr={videoHdr}
                photoQualityBalance="quality"
                lowLightBoost={device.supportsLowLightBoost && enableNightMode}
                enableZoomGesture={false}
                animatedProps={cameraAnimatedProps}
                exposure={0}
                enableFpsGraph={true}
                orientation="portrait"
                photo={true}
                video={true}
                audio={microphone.hasPermission}
                enableLocation={location.hasPermission}
                frameProcessor={frameProcessor}
				resizeMode={'contain'}
              />

Relevant log output

11:23:19.460: [info] 馃摳 VisionCamera.didSetProps(_:): Updating 34 props: [lowLightBoost, onAverageFpsChanged, exposure, photoHdr, onShutter, resizeMode, onStarted, preview, onStopped, collapsable, onCodeScanned, left, zoom, photo, onViewReady, orientation, enableFrameProcessor, enableLocation, position, isActive, top, enableZoomGesture, photoQualityBalance, format, audio, right, video, cameraId, fps, onError, bottom, videoHdr, onInitialized, enableBufferCompression]
11:23:19.464: [info] 馃摳 VisionCamera.configure(_:): configure { ... }: Waiting for lock...
11:23:19.467: [info] 馃摳 VisionCamera.configure(_:): configure { ... }: Updating CameraSession Configuration... Difference(inputChanged: true, outputsChanged: true, videoStabilizationChanged: true, orientationChanged: true, formatChanged: true, sidePropsChanged: true, torchChanged: true, zoomChanged: true, exposureChanged: true, audioSessionChanged: true, locationChanged: true)
11:23:19.467: [info] 馃摳 VisionCamera.configureDevice(configuration:): Configuring Input Device...
11:23:19.467: [info] 馃摳 VisionCamera.configureDevice(configuration:): Configuring Camera com.apple.avfoundation.avcapturedevice.built-in_video:0...
11:23:19.481: [info] 馃摳 VisionCamera.configureDevice(configuration:): Successfully configured Input Device!
11:23:19.481: [info] 馃摳 VisionCamera.configureOutputs(configuration:): Configuring Outputs...
11:23:19.481: [info] 馃摳 VisionCamera.configureOutputs(configuration:): Adding Photo output...
11:23:19.485: [info] 馃摳 VisionCamera.configureOutputs(configuration:): Adding Video Data output...
11:23:19.487: [info] 馃摳 VisionCamera.configureOutputs(configuration:): Successfully configured all outputs!
11:23:19.488: [info] 馃摳 VisionCamera.configureFormat(configuration:device:): Configuring Format (3696x3024 | 352x288@60.0 (ISO: 32.0..3072.0))...
11:23:19.488: [info] 馃摳 VisionCamera.configureFormat(configuration:device:): Successfully configured Format!
11:23:19.489: [info] 馃摳 VisionCamera.getPixelFormat(for:): Available Pixel Formats: ["420v", "420f", "BGRA"], finding best match... (pixelFormat="yuv", enableHdr={false}, enableBufferCompression={false})
11:23:19.489: [info] 馃摳 VisionCamera.getPixelFormat(for:): Using PixelFormat: 420f...
[I] <MMKV_OSX.cpp:99::setIsInBackground> g_isInBackground:0
[I] <libMMKV.mm:313::+[MMKV didBecomeActive]> isInBackground:0
11:23:19.774: [info] 馃摳 VisionCamera.onCameraStarted(): Camera started!
11:23:19.774: [info] 馃摳 VisionCamera.onSessionInitialized(): Camera initialized!
11:23:19.774: [info] 馃摳 VisionCamera.configure(_:): Beginning AudioSession configuration...
11:23:19.775: [info] 馃摳 VisionCamera.configureAudioSession(configuration:): Configuring Audio Session...
Camera initialized!
11:23:19.775: [info] 馃摳 VisionCamera.configureAudioSession(configuration:): Adding Audio input...

Camera Device

{
  "id": "com.apple.avfoundation.avcapturedevice.built-in_video:0",
  "maxZoom": 16,
  "minFocusDistance": 12,
  "minZoom": 1,
  "hardwareLevel": "full",
  "position": "back",
  "hasTorch": true,
  "minExposure": -8,
  "hasFlash": true,
  "name": "Back Camera",
  "sensorOrientation": "landscape-right",
  "maxExposure": 8,
  "supportsLowLightBoost": false,
  "formats": [],
  "physicalDevices": [
    "wide-angle-camera"
  ],
  "neutralZoom": 1,
  "supportsFocus": true,
  "supportsRawCapture": false,
  "isMultiCam": false
}

Device

iPhont 11 IOS17.4.1

VisionCamera Version

4.0.3

Can you reproduce this issue in the VisionCamera Example app?

Yes, I can reproduce the same issue in the Example app here

Additional information

@ppanwin10 ppanwin10 added the 馃悰 bug Something isn't working label May 7, 2024
@ppanwin10 ppanwin10 changed the title 馃悰 Square ratio preview is low quality 馃悰 Square ratio preview has low quality May 7, 2024
@ppanwin10
Copy link
Author

BTW, I think this won't be a big problem if we go with cutting the view manually.

@mrousavy
Copy link
Owner

What resolution does format have?

@ppanwin10
Copy link
Author

What resolution does format have?

always "max"

@mrousavy
Copy link
Owner

No, I'm talking about the format. Not your format filter. Log the format that you get.

@ppanwin10
Copy link
Author

ok, here you go.
{"autoFocusSystem": "phase-detection", "fieldOfView": 97.75704193115234, "maxFps": 60, "maxISO": 3072, "minFps": 1, "minISO": 32, "photoHeight": 3024, "photoWidth": 3696, "supportsDepthCapture": false, "supportsPhotoHdr": false, "supportsVideoHdr": false, "videoHeight": 288, "videoStabilizationModes": ["auto", "off"], "videoWidth": 352}

@mrousavy
Copy link
Owner

videoWidth: 352, videoHeight: 288 <-- that's why your format is so low quality.

The Preview view is also a video stream obviously, so it depends on the video size in the format. Choose a format with a higher video size. You could also just write your own format filter if you want.

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

No branches or pull requests

2 participants