vision-camera-resize-plugin icon indicating copy to clipboard operation
vision-camera-resize-plugin copied to clipboard

Question - How to render vision-camera-resize-plugin with useSkiaFrameProcessor

Open frodriguez-hu opened this issue 1 year ago • 1 comments

Hey, I have been playing around and trying to render the output of resizing the frame but unfortunately my implementation is returning null and I am not completely sure why.

I have this:

const resized = resize(frame, {
      scale: {
        width: 256,
        height: 256
      },
      crop: {
        y: 0,
        x: 0,
        width: frame.width,
        height: frame.width
      },
      pixelFormat: 'rgb',
      dataType: 'uint8'
    });

    const data = Skia.Data.fromBytes(resized);
    const img = Skia.Image.MakeImage(
      {
        width: 256,
        height: 256,
        alphaType: AlphaType.Opaque,
        colorType: ColorType.RGBA_8888,
      },
      data,
      4 * resized.length
    )

I can't figure out what should be the right 3rd parameter of MakeImage. And I guess that is why it is returning an error

This is the Skia Doc about that: https://shopify.github.io/react-native-skia/docs/images/#makeimage

frodriguez-hu avatar Jul 01 '24 13:07 frodriguez-hu

I think RN Skia should throw useful errors (with messages) instead of swallowing it and returning null. Would be great if that can be changed.

But yea I guess you can only debug this via Skia logs, check the native adb logcat/Xcode logs to see what kind of error Skia throws.

mrousavy avatar Jul 02 '24 11:07 mrousavy