yasintorun / vision-camera-base64

Vision Camera Frame Processor plugin. Convert the frame to base64 image data
https://www.npmjs.com/package/vision-camera-base64
MIT License
14 stars 8 forks source link

Memory issue #2

Closed PiotrKalinski closed 1 year ago

PiotrKalinski commented 1 year ago

Hello,

I am using your plugin to catch frame and send it back to my server to process image. But after ~15s app crash due to

image image

is it common issue or am I using it wrong?

yasintorun commented 1 year ago

Hi, I think, console.log overflowing memory. Please use this code and can you try again?

console.log(imageAsBase64.substring(0, 20))

or This code from my real project and this is running correct.

const processThread = (base64: string) => {
  // setImage(base64)
  // Get Optic paper with using opencv and c++
  runOpticReader(base64, JSON.stringify(fmt), JSON.stringify(options)).then(setImage);
};
const process = useFrameProcessor((frame) => {
  'worklet';
  // Get QR only qr points
  const detectedBarcodes = scanBarcodes(frame, [BarcodeFormat.QR_CODE], {
    checkInverted: true,
  });
  const points = detectedBarcodes[0]?.cornerPoints;
  if (points && points[1]) {
    fmt.qr = {
      x: points[1].x,
      y: points[1].y,
    };
    const base64 = frameToBase64(frame);
    REA.runOnJS(processThread)(base64);
  }

}, []);
PiotrKalinski commented 1 year ago

Thanks for help