Skip to content

🐛 Focus on tap #758

@TasigurIshtar

Description

@TasigurIshtar

What were you trying to do?

Hello,

I am trying to simulate focus on tap, but the location where I tapped is newer focussed correctly.

Fresh project - ("react-native": "0.66.4", "react-native-vision-camera": "^2.12.0", ...android device)
Locked portrait orientation,
Camera component has marginTop:60, marginLeft:60 to better check of tap coordinates.
I am using coordinates relative to Camera component rectangle as mentiond here https://mrousavy.com/react-native-vision-camera/docs/guides/focusing/

I made demo project where this problem is ilustrated.
https://github.com/TasigurIshtar/RNVisionCameraTest

Thanks for your time.

Reproduceable Code

const touchII = async (event: NativeTouchEvent) => {
    let point: Point = {
      x: Math.round(event.pageX - camLocation.x),
      y: Math.round(event.pageY - camLocation.y),
    };
    await cameraRef?.current?.focus(point)     
  };

.....
 <Camera
      ref={cameraRef}
      style={{
        marginTop: 60,
        marginLeft: 60,
        width: window.width - 60,
        height: window.height - 60,
      }}
      onLayout={event => {
        const layout = event.nativeEvent.layout;
        setCamLocation({x: layout.x, y: layout.y});
      }}
      device={device}
      isActive={true}
      onTouchEnd={x => device.supportsFocus && touchII(x.nativeEvent)}
    />

What happened instead?

after tapping to the top of the bottle .focus({"x": 53, "y": 393}) -> the bottle doesn't seems to be focused. (when I was tapping more on the right site around the grayish mat, occasionaly the top of the bottle was super sharp. )

image

Relevant log output

No response

Device

Samsung Galaxy S10

VisionCamera Version

2.12.0

Additional information

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐛 bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions