mrousavy / react-native-vision-camera

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

🐛 Worklet Issue #3033

Closed noumanahmadstack closed 3 months ago

noumanahmadstack commented 3 months ago

What's happening?

I am trying to get raw Data for live stream. I use frameProcessor for get the frame and frame.toArrayBuffer() for RGB data.Now i want further process for collection the RawData.Even i used the runAsync in FrameProcessor but not success.

Reproduceable Code

const frameProcessor =  useFrameProcessor((frame) => {
    'worklet';
    try {
      const height = frame.height;
      const width = frame.width;
      const bytesPerRow = frame.bytesPerRow
      const buffer = frame.toArrayBuffer()
      const rawData = new Uint8Array(buffer)
        runAsync(frame, () => {
          'worklet'
          console.log("I'm running asynchronously, possibly at a lower FPS rate!")
        })
        }
        console.log(`Pixel at 0,0: RGB(${rawData[0]}, ${rawData[1]}, ${rawData[2]})`)
      // Process the frame here
    } catch (e) {
      console.error('Frame Processor Error:', e.message);
    }
  }, []);

Relevant log output

Frame Processor Error: Regular javascript function '' cannot be shared. Try decorating the function with the 'worklet' keyword to allow the javascript function to be used as a worklet., js engine: VisionCamera.

Camera Device

{
  "formats": [],
  "sensorOrientation": "landscape-left",
  "hardwareLevel": "full",
  "maxZoom": 8,
  "minZoom": 1,
  "maxExposure": 12,
  "supportsLowLightBoost": false,
  "neutralZoom": 1,
  "physicalDevices": [
    "wide-angle-camera"
  ],
  "supportsFocus": true,
  "supportsRawCapture": false,
  "isMultiCam": false,
  "minFocusDistance": 7.000000066757203,
  "minExposure": -12,
  "name": "0 (BACK) androidx.camera.camera2",
  "hasFlash": true,
  "hasTorch": true,
  "position": "back",
  "id": "0"
}

Device

on every device

VisionCamera Version

4.3.2

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

maintenance-hans[bot] commented 3 months ago

Guten Tag, Hans here.

[!NOTE] New features, bugfixes, updates and other improvements are all handled mostly by @mrousavy in his free time. To support @mrousavy, please consider 💖 sponsoring him on GitHub 💖. Sponsored issues will be prioritized.

mrousavy commented 3 months ago

Please try if you can reproduce in the example app. If not, then it is a bug on your end. Maybe you have reanimated installed, then you need to enable processNestedWorklets in babel config.

mrousavy commented 3 months ago

Either way this should probably be posted in react-native-worklets-core repo.