mrousavy / react-native-vision-camera

📸 A powerful, high-performance React Native Camera library.
https://react-native-vision-camera.com
MIT License
7.35k stars 1.07k forks source link

💭 Issue with FrameProcessorsUnavailableError #3131

Closed KarthiPN closed 1 month ago

KarthiPN commented 1 month ago

Question

I have used useFrameprocessor like the code mentioned below but no matter what I do I'm getting " ERROR TypeError: Cannot read property 'FrameProcessorsUnavailableError' of undefined, js engine: hermes"

What I tried

import React, { useState, useEffect } from 'react'; import { View, Text, StyleSheet, Button } from 'react-native'; import { Camera, useCameraDevice,CameraPermissionStatus, useFrameProcessor } from 'react-native-vision-camera';

const CameraVision = ()=>{ const [frameCount, setFrameCount] = useState(0); const [cameraPermission, setCameraPermission] = useState('not-determined'); const device = useCameraDevice('front');

useEffect(() => {
    const getPermission = async () => {
      const status = await Camera.requestCameraPermission();
      setCameraPermission(status);
    };
    getPermission();
}, []);

  const frameProcessor = useFrameProcessor((frame) => {
    if (!frame){
        console.log("Frame error")
    }
    'worklet'; // Required for worklet code

    // Access frame properties
    console.log('Frame Dimensions are:', frame.width, frame.height);
    console.log('Pixel format:', frame.pixelFormat);
    setFrameCount(prevCount => prevCount + 1);
  }, []);

  if (cameraPermission === 'not-determined') {
    return <Text>Requesting camera permission...</Text>;
  }

  if (cameraPermission === 'denied') {
    return <Text>Camera permission denied</Text>;
  }

  if (!device) {
    return <Text>Loading camera...</Text>;
  }

return(
    <View>
        <Camera

        frameProcessor={frameProcessor}
        style={{'width':'100%',height:'80%'}}
        device = {device}
        isActive={true}
        // onFrame={frame => {
        //     // Custom frame processing logic
        //     console.log('Received frame', frame);
        //   }}
      />
      <Text>Frame Count: {frameCount}</Text>

    </View>

)

}

export {CameraVision}

VisionCamera Version

latest

Additional information

maintenance-hans[bot] commented 1 month ago

Guten Tag, Hans here! 🍻

It looks like you're facing an issue with FrameProcessorsUnavailableError. However, I notice you haven't provided any relevant logs, which are essential for troubleshooting. Please check your logs in Xcode or using adb logcat for Android, then provide those in your issue. This will help mrousavy to understand and fix the problem more effectively. Also, please ensure your environment details are included, like versions of React Native and any relevant libraries.

Feel free to follow up with those logs, and we can take a look!

Note: If you think I made a mistake, please ping @mrousavy to take a look.

lucksp commented 1 month ago

Did you install react-native-worklets-core?

mrousavy commented 1 month ago

This is a bug, not a question. You used the wrong issue template.