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

馃悰 Pinch to Zoom is not stable (ios). #2637

Closed
3 of 5 tasks
prasan2421 opened this issue Mar 6, 2024 · 1 comment
Closed
3 of 5 tasks

馃悰 Pinch to Zoom is not stable (ios). #2637

prasan2421 opened this issue Mar 6, 2024 · 1 comment
Labels
馃悰 bug Something isn't working

Comments

@prasan2421
Copy link

What's happening?

While the pinch to zoom in and out is smooth, I am having quality issues where the camera quality is not same in comparison to the ios camera and also sometimes the zoomed images fluctuates from pixelated to smooth.

Reproduceable Code

const neutralZoom = device?.neutralZoom ?? 1;
  const zoom = useSharedValue(neutralZoom);

  const animatedProps = useAnimatedProps<CameraProps>(
    () => ({ zoom: zoom.value }),
    [zoom]
  )

const minZoom = device?.minZoom ?? 1;
  const maxZoom = Math.min(device?.maxZoom ?? 1, MAX_ZOOM_FACTOR);
  const zoomOffset = useSharedValue(0);

  const onPinchGesture = Gesture.Pinch()
  .onBegin((e) => {
    zoomOffset.value = zoom.value

  })
  .onUpdate(event => {
    const z = zoomOffset.value * event.scale
    zoom.value = interpolate(
      z,
      [1, 10],
      [minZoom,  maxZoom],
      Extrapolation.CLAMP,
    )
  })

return(
 <GestureDetector 
     gesture={onPinchGesture}>     
                  <Reanimated.View style={{height: adjustedHeight}}>
                    <GestureDetector gesture={gesture}>
                      <ReanimatedCamera
                        ref={cameraRef}
                        style={{
                          height: adjustedHeight,
                        }}
                        device={device}
                        fps={fps}
                        isActive={isActive}
                        format={format}
                        onError={onError}
                        enableZoomGesture={true}
                        animatedProps={animatedProps}
                        orientation="portrait"
                        video={true}
                        audio={true}>
                        {focusValue && (
                          <View
                            style={{
                              position: 'absolute',
                              borderWidth: 1,
                              borderColor: 'white',
                              top: focusValue.y - 30,
                              left: focusValue.x - 30,
                              zIndex: 100,
                              width: 60,
                              height: 60,
                              alignSelf: 'center',
                              justifyContent: 'center',
                            }}
                          />
                        )}
                      </ReanimatedCamera>
                    </GestureDetector>
                  </Reanimated.View>
                  </GestureDetector>
)

Relevant log output

VisionCamera.didSetProps(_:): Updating 20 props: [onInitialized, cameraId, enableBufferCompression, onStarted, onCodeScanned, collapsable, isActive, video, onViewReady, onError, onStopped, videoStabilizationMode, fps, enableFrameProcessor, enableZoomGesture, orientation, format, audio, height, zoom]
VisionCamera.configure(_:): configure { ... }: Waiting for lock...
The permission is granted
[GESTURE HANDLER] Initialize gesture handler for view <RCTRootContentView: 0x143606c50; reactTag: 1; frame = (0 0; 414 896); gestureRecognizers = <NSArray: 0x282db79c0>; layer = <CALayer: 0x282380880>>
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)
VisionCamera.withSessionLock(_:): Beginning CameraSession configuration...
VisionCamera.configureDevice(configuration:): Configuring Input Device...
VisionCamera.configureDevice(configuration:): Configuring Camera com.apple.avfoundation.avcapturedevice.built-in_video:7...
VisionCamera.configureDevice(configuration:): Successfully configured Input Device!
VisionCamera.configureOutputs(configuration:): Configuring Outputs...
VisionCamera.configureOutputs(configuration:): Adding Video Data output...
VisionCamera.configureOutputs(configuration:): Successfully configured all outputs!
VisionCamera.withSessionLock(_:): Committed CameraSession configuration!
VisionCamera.withDeviceLock(_:): Beginning CaptureDevice configuration...
VisionCamera.configureFormat(configuration:device:): Configuring Format (2112x1188 | 1920x1080@60.0 (ISO: 32.0..3072.0, Pixel Formats: [VisionCamera.PixelFormat.yuv, VisionCamera.PixelFormat.yuv, VisionCamera.PixelFormat.rgb]))...
VisionCamera.configureFormat(configuration:device:): Successfully configured Format!
VisionCamera.withDeviceLock(_:): Committed CaptureDevice configuration!
The permission is granted
VisionCamera.onCameraStarted(): Camera started!
VisionCamera.withDeviceLock(_:): Beginning CaptureDevice configuration...
VisionCamera.withDeviceLock(_:): Committed CaptureDevice configuration!
VisionCamera.onSessionInitialized(): Camera initialized!
VisionCamera.configure(_:): Beginning AudioSession configuration...
VisionCamera.configureAudioSession(configuration:): Configuring Audio Session...
VisionCamera.configureAudioSession(configuration:): Adding Audio input...
VisionCamera.configureAudioSession(configuration:): Adding Audio Data output...
VisionCamera.configure(_:): Committed AudioSession configuration!
VisionCamera.didSetProps(_:): Updating 2 props: [cameraId, format]
VisionCamera.configure(_:): configure { ... }: Waiting for lock...
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: false)
VisionCamera.withSessionLock(_:): Beginning CameraSession configuration...
VisionCamera.configureDevice(configuration:): Configuring Input Device...
VisionCamera.configureDevice(configuration:): Configuring Camera com.apple.avfoundation.avcapturedevice.built-in_video:1...
VisionCamera.configureDevice(configuration:): Successfully configured Input Device!
VisionCamera.configureOutputs(configuration:): Configuring Outputs...
VisionCamera.configureOutputs(configuration:): Adding Video Data output...
VisionCamera.configureOutputs(configuration:): Successfully configured all outputs!
VisionCamera.withSessionLock(_:): Committed CameraSession configuration!
VisionCamera.withDeviceLock(_:): Beginning CaptureDevice configuration...
VisionCamera.configureFormat(configuration:device:): Configuring Format (3840x2160 | 3840x2160@60.0 (ISO: 23.0..2208.0, Pixel Formats: [VisionCamera.PixelFormat.yuv, VisionCamera.PixelFormat.yuv, VisionCamera.PixelFormat.rgb]))...
VisionCamera.configureFormat(configuration:device:): Successfully configured Format!
VisionCamera.withDeviceLock(_:): Committed CaptureDevice configuration!
VisionCamera.withDeviceLock(_:): Beginning CaptureDevice configuration...
VisionCamera.withDeviceLock(_:): Committed CaptureDevice configuration!
VisionCamera.onSessionInitialized(): Camera initialized!
VisionCamera.didSetProps(_:): Updating 0 props: []
VisionCamera.configure(_:): configure { ... }: Waiting for lock...
VisionCamera.configure(_:): configure { ... }: Updating CameraSession Configuration... Difference(inputChanged: false, outputsChanged: false, videoStabilizationChanged: false, orientationChanged: false, formatChanged: false, sidePropsChanged: false, torchChanged: false, zoomChanged: true, exposureChanged: false, audioSessionChanged: false)
VisionCamera.withDeviceLock(_:): Beginning CaptureDevice configuration...
VisionCamera.withDeviceLock(_:): Committed CaptureDevice configuration!
VisionCamera.didSetProps(_:): Updating 0 props: []
VisionCamera.configure(_:): configure { ... }: Waiting for lock...
VisionCamera.didSetProps(_:): Updating 0 props: []
VisionCamera.configure(_:): configure { ... }: Waiting for lock...
VisionCamera.didSetProps(_:): A new configure { ... } call arrived, aborting this one...
VisionCamera.configure(_:): configure { ... }: Updating CameraSession Configuration... Difference(inputChanged: false, outputsChanged: false, videoStabilizationChanged: false, orientationChanged: false, formatChanged: false, sidePropsChanged: false, torchChanged: false, zoomChanged: false, exposureChanged: false, audioSessionChanged: false)
VisionCamera.configure(_:): configure { ... }: Updating CameraSession Configuration... Difference(inputChanged: false, outputsChanged: false, videoStabilizationChanged: false, orientationChanged: false, formatChanged: false, sidePropsChanged: false, torchChanged: false, zoomChanged: true, exposureChanged: false, audioSessionChanged: false)
VisionCamera.withDeviceLock(_:): Beginning CaptureDevice configuration...
VisionCamera.didSetProps(_:): Updating 0 props: []
VisionCamera.configure(_:): configure { ... }: Waiting for lock...
VisionCamera.withDeviceLock(_:): Committed CaptureDevice configuration!
VisionCamera.configure(_:): configure { ... }: Updating CameraSession Configuration... Difference(inputChanged: false, outputsChanged: false, videoStabilizationChanged: false, orientationChanged: false, formatChanged: false, sidePropsChanged: false, torchChanged: false, zoomChanged: true, exposureChanged: false, audioSessionChanged: false)
VisionCamera.withDeviceLock(_:): Beginning CaptureDevice configuration...
VisionCamera.withDeviceLock(_:): Committed CaptureDevice configuration!
VisionCamera.didSetProps(_:): Updating 0 props: []
VisionCamera.configure(_:): configure { ... }: Waiting for lock...
VisionCamera.configure(_:): configure { ... }: Updating CameraSession Configuration... Difference(inputChanged: false, outputsChanged: false, videoStabilizationChanged: false, orientationChanged: false, formatChanged: false, sidePropsChanged: false, torchChanged: false, zoomChanged: true, exposureChanged: false, audioSessionChanged: false)
VisionCamera.withDeviceLock(_:): Beginning CaptureDevice configuration...
VisionCamera.withDeviceLock(_:): Committed CaptureDevice configuration!
VisionCamera.didSetProps(_:): Updating 0 props: []
VisionCamera.configure(_:): configure { ... }: Waiting for lock...
VisionCamera.configure(_:): configure { ... }: Updating CameraSession Configuration... Difference(inputChanged: false, outputsChanged: false, videoStabilizationChanged: false, orientationChanged: false, formatChanged: false, sidePropsChanged: false, torchChanged: false, zoomChanged: true, exposureChanged: false, audioSessionChanged: false)
VisionCamera.withDeviceLock(_:): Beginning CaptureDevice configuration...
VisionCamera.withDeviceLock(_:): Committed CaptureDevice configuration!
VisionCamera.didSetProps(_:): Updating 0 props: []
VisionCamera.configure(_:): configure { ... }: Waiting for lock...
VisionCamera.configure(_:): configure { ... }: Updating CameraSession Configuration... Difference(inputChanged: false, outputsChanged: false, videoStabilizationChanged: false, orientationChanged: false, formatChanged: false, sidePropsChanged: false, torchChanged: false, zoomChanged: true, exposureChanged: false, audioSessionChanged: false)
VisionCamera.withDeviceLock(_:): Beginning CaptureDevice configuration...
VisionCamera.withDeviceLock(_:): Committed CaptureDevice configuration!
VisionCamera.didSetProps(_:): Updating 0 props: []
VisionCamera.configure(_:): configure { ... }: Waiting for lock...
VisionCamera.configure(_:): configure { ... }: Updating CameraSession Configuration... Difference(inputChanged: false, outputsChanged: false, videoStabilizationChanged: false, orientationChanged: false, formatChanged: false, sidePropsChanged: false, torchChanged: false, zoomChanged: true, exposureChanged: false, audioSessionChanged: false)
VisionCamera.withDeviceLock(_:): Beginning CaptureDevice configuration...
VisionCamera.withDeviceLock(_:): Committed CaptureDevice configuration!
VisionCamera.didSetProps(_:): Updating 0 props: []
VisionCamera.configure(_:): configure { ... }: Waiting for lock...
VisionCamera.configure(_:): configure { ... }: Updating CameraSession Configuration... Difference(inputChanged: false, outputsChanged: false, videoStabilizationChanged: false, orientationChanged: false, formatChanged: false, sidePropsChanged: false, torchChanged: false, zoomChanged: true, exposureChanged: false, audioSessionChanged: false)
VisionCamera.withDeviceLock(_:): Beginning CaptureDevice configuration...
VisionCamera.withDeviceLock(_:): Committed CaptureDevice configuration!
VisionCamera.didSetProps(_:): Updating 0 props: []
VisionCamera.configure(_:): configure { ... }: Waiting for lock...
VisionCamera.configure(_:): configure { ... }: Updating CameraSession Configuration... Difference(inputChanged: false, outputsChanged: false, videoStabilizationChanged: false, orientationChanged: false, formatChanged: false, sidePropsChanged: false, torchChanged: false, zoomChanged: true, exposureChanged: false, audioSessionChanged: false)
VisionCamera.withDeviceLock(_:): Beginning CaptureDevice configuration...
VisionCamera.withDeviceLock(_:): Committed CaptureDevice configuration!
VisionCamera.didSetProps(_:): Updating 0 props: []
VisionCamera.configure(_:): configure { ... }: Waiting for lock...
VisionCamera.configure(_:): configure { ... }: Updating CameraSession Configuration... Difference(inputChanged: false, outputsChanged: false, videoStabilizationChanged: false, orientationChanged: false, formatChanged: false, sidePropsChanged: false, torchChanged: false, zoomChanged: true, exposureChanged: false, audioSessionChanged: false)
VisionCamera.withDeviceLock(_:): Beginning CaptureDevice configuration...
VisionCamera.withDeviceLock(_:): Committed CaptureDevice configuration!
VisionCamera.didSetProps(_:): Updating 0 props: []
VisionCamera.configure(_:): configure { ... }: Waiting for lock...
VisionCamera.configure(_:): configure { ... }: Updating CameraSession Configuration... Difference(inputChanged: false, outputsChanged: false, videoStabilizationChanged: false, orientationChanged: false, formatChanged: false, sidePropsChanged: false, torchChanged: false, zoomChanged: true, exposureChanged: false, audioSessionChanged: false)
VisionCamera.withDeviceLock(_:): Beginning CaptureDevice configuration...
VisionCamera.withDeviceLock(_:): Committed CaptureDevice configuration!
VisionCamera.didSetProps(_:): Updating 0 props: []
VisionCamera.configure(_:): configure { ... }: Waiting for lock...
VisionCamera.configure(_:): configure { ... }: Updating CameraSession Configuration... Difference(inputChanged: false, outputsChanged: false, videoStabilizationChanged: false, orientationChanged: false, formatChanged: false, sidePropsChanged: false, torchChanged: false, zoomChanged: false, exposureChanged: false, audioSessionChanged: false)
VisionCamera.didSetProps(_:): Updating 0 props: []
VisionCamera.configure(_:): configure { ... }: Waiting for lock...
VisionCamera.configure(_:): configure { ... }: Updating CameraSession Configuration... Difference(inputChanged: false, outputsChanged: false, videoStabilizationChanged: false, orientationChanged: false, formatChanged: false, sidePropsChanged: false, torchChanged: false, zoomChanged: false, exposureChanged: false, audioSessionChanged: false)
VisionCamera.didSetProps(_:): Updating 0 props: []
VisionCamera.configure(_:): configure { ... }: Waiting for lock...
VisionCamera.configure(_:): configure { ... }: Updating CameraSession Configuration... Difference(inputChanged: false, outputsChanged: false, videoStabilizationChanged: false, orientationChanged: false, formatChanged: false, sidePropsChanged: false, torchChanged: false, zoomChanged: false, exposureChanged: false, audioSessionChanged: false)
VisionCamera.didSetProps(_:): Updating 0 props: []
VisionCamera.configure(_:): configure { ... }: Waiting for lock...
VisionCamera.configure(_:): configure { ... }: Updating CameraSession Configuration... Difference(inputChanged: false, outputsChanged: false, videoStabilizationChanged: false, orientationChanged: false, formatChanged: false, sidePropsChanged: false, torchChanged: false, zoomChanged: false, exposureChanged: false, audioSessionChanged: false)
VisionCamera.didSetProps(_:): Updating 0 props: []
VisionCamera.configure(_:): configure { ... }: Waiting for lock...
VisionCamera.configure(_:): configure { ... }: Updating CameraSession Configuration... Difference(inputChanged: false, outputsChanged: false, videoStabilizationChanged: false, orientationChanged: false, formatChanged: false, sidePropsChanged: false, torchChanged: false, zoomChanged: false, exposureChanged: false, audioSessionChanged: false)
VisionCamera.didSetProps(_:): Updating 0 props: []
VisionCamera.configure(_:): configure { ... }: Waiting for lock...
VisionCamera.configure(_:): configure { ... }: Updating CameraSession Configuration... Difference(inputChanged: false, outputsChanged: false, videoStabilizationChanged: false, orientationChanged: false, formatChanged: false, sidePropsChanged: false, torchChanged: false, zoomChanged: false, exposureChanged: false, audioSessionChanged: false)
VisionCamera.didSetProps(_:): Updating 0 props: []
VisionCamera.configure(_:): configure { ... }: Waiting for lock...
VisionCamera.configure(_:): configure { ... }: Updating CameraSession Configuration... Difference(inputChanged: false, outputsChanged: false, videoStabilizationChanged: false, orientationChanged: false, formatChanged: false, sidePropsChanged: false, torchChanged: false, zoomChanged: false, exposureChanged: false, audioSessionChanged: false)
VisionCamera.didSetProps(_:): Updating 0 props: []
VisionCamera.configure(_:): configure { ... }: Waiting for lock...
VisionCamera.configure(_:): configure { ... }: Updating CameraSession Configuration... Difference(inputChanged: false, outputsChanged: false, videoStabilizationChanged: false, orientationChanged: false, formatChanged: false, sidePropsChanged: false, torchChanged: false, zoomChanged: false, exposureChanged: false, audioSessionChanged: false)
VisionCamera.didSetProps(_:): Updating 1 props: [isActive]
VisionCamera.configure(_:): configure { ... }: Waiting for lock...
VisionCamera.configure(_:): configure { ... }: Updating CameraSession Configuration... Difference(inputChanged: false, outputsChanged: false, videoStabilizationChanged: false, orientationChanged: false, formatChanged: false, sidePropsChanged: false, torchChanged: false, zoomChanged: false, exposureChanged: false, audioSessionChanged: false)
[I] <MMKV_OSX.cpp:116::setIsInBackground> g_isInBackground:1
[I] <libMMKV.mm:283::+[MMKV didEnterBackground]> isInBackground:1

Camera Device

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

Device

iphone 11 pro max

VisionCamera Version

3.6.6

Can you reproduce this issue in the VisionCamera Example app?

I didn't try (鈿狅笍 your issue might get ignored & closed if you don't try this)

Additional information

@prasan2421 prasan2421 added the 馃悰 bug Something isn't working label Mar 6, 2024
@mrousavy
Copy link
Owner

mrousavy commented Mar 6, 2024

While the pinch to zoom in and out is smooth, I am having quality issues where the camera quality is not same in comparison to the ios camera and also sometimes the zoomed images fluctuates from pixelated to smooth.

What? Please attach side by side comparisons and screenshots.

Also the title is wrong then, no?

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