GithubHelp home page GithubHelp logo

Comments (4)

gwendall avatar gwendall commented on July 19, 2024

You could only run the camera if the screen is active. If the camera doesn't run, the frame processor should not either. So something like:

import { useNavigation } from 'expo-router';
...
const navigation = useNavigation();
const isScreenFocused = navigation.isFocused();
...
<Camera
   ...
   isActive={isScreenFocused}
/>

from react-native-vision-camera.

kssgarcia avatar kssgarcia commented on July 19, 2024

I understood you that I should set the active property false when the screen is not focus, but I am already doing this,

<Camera
  style={StyleSheet.absoluteFillObject}
  ref={cameraRef}
  device={device}
  isActive={isActive}
  photo={true}
  format={format}
  fps={fps}
  orientation="portrait"
  photoQualityBalance="speed"
  // enableFpsGraph={true}
  frameProcessor={frameProcessor}
/>

the isActive={isActive} set this to false when the screen is not focus or when the app is in second plane. This seems to work fine, but when I use frameProcessor={frameProcessor} this is still running when the screen is not focus.

from react-native-vision-camera.

gwendall avatar gwendall commented on July 19, 2024

Strange, maybe it's a regression on a new version? In this case you could pass isActive as a dependency of the frame processor and not run what's inside if it is false, like:

useFrameProcessor((frame) => {
  if (!isActive) return;
  ...
}, [isActive]);

from react-native-vision-camera.

kssgarcia avatar kssgarcia commented on July 19, 2024

@gwendall you were right, ty. It seems that I was setting the isActive in a wrong way. Ty man

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.