mrousavy / vision-camera-resize-plugin

A VisionCamera Frame Processor plugin for fast buffer resizing and colorspace (YUV <> RGBA) conversions
https://mrousavy.com
MIT License
93 stars 23 forks source link

`ResizePlugin.kt` Too many arguments / Android #44

Closed pedrol2b closed 8 months ago

pedrol2b commented 8 months ago

Facing thoose issues when trying to build on Android

full logs:

e: file:///C:/Users/Pedro/dev/app/node_modules/vision-camera-resize-plugin/android/src/main/java/com/visioncameraresizeplugin/ResizePlugin.kt:155:7 Type mismatch: inferred type is Boolean but Int was expected

e: file:///C:/Users/Pedro/dev/app/node_modules/vision-camera-resize-plugin/android/src/main/java/com/visioncameraresizeplugin/ResizePlugin.kt:156:7 Too many arguments for private final external fun resize(image: Image, cropX: Int, cropY: Int, cropWidth: Int, cropHeight: Int, scaleWidth: Int, scaleHeight: Int, pixelFormat: Int, dataType: Int): ByteBuffer defined in com.visioncameraresizeplugin.ResizePlugin

e: file:///C:/Users/Pedro/dev/app/node_modules/vision-camera-resize-plugin/android/src/main/java/com/visioncameraresizeplugin/ResizePlugin.kt:157:7 Too many arguments for private final external fun resize(image: Image, cropX: Int, cropY: Int, cropWidth: Int, cropHeight: Int, scaleWidth: Int, scaleHeight: Int, pixelFormat: Int, dataType: Int): ByteBuffer defined in com.visioncameraresizeplugin.ResizePlugin

Heres the actual code

    val resized = resize(
      image,
      cropX,
      cropY,
      cropWidth,
      cropHeight,
      scaleWidth,
      scaleHeight,
      rotation.degrees,
      mirror,
      targetFormat.ordinal, /** pixelFormat */
      targetType.ordinal /** dataType */
    )

and the resize external function

  private external fun resize(
    image: Image,
    cropX: Int,
    cropY: Int,
    cropWidth: Int,
    cropHeight: Int,
    scaleWidth: Int,
    scaleHeight: Int,
    pixelFormat: Int,
    dataType: Int
  ): ByteBuffer

managed to supress the error and build removing params from the resize call above

     val resized = resize(
      image,
      cropX,
      cropY,
      cropWidth,
      cropHeight,
      scaleWidth,
      scaleHeight,
      // rotation.degrees,
      // mirror,
      targetFormat.ordinal, /** pixelFormat */
      targetType.ordinal /** dataType */
    )

as the error says the call had more params than in the function declaration

Heres my enviroment

    "react-native": "0.73.4",
    "react-native-vision-camera": "^3.9.1",
    "react-native-worklets-core": "^0.3.0",
    "vision-camera-resize-plugin": "^2.1.0",
PercipioCorey commented 8 months ago

I also saw this error and fixed the issue (with rotation enabled and working), by modifying the resize function

  private external fun resize(
    image: Image,
    cropX: Int,
    cropY: Int,
    cropWidth: Int,
    cropHeight: Int,
    scaleWidth: Int,
    scaleHeight: Int,
    rotation: Int,
    mirror: Boolean,
    pixelFormat: Int,
    dataType: Int
  ): ByteBuffer

This adds in the new rotation and mirror arguments. I was working on creating an issue and PR, but was unable to reproduce the original error. Then my fix stopped working too (now the app just crashes).

SimpleLogix commented 8 months ago

What about for expo?

mrousavy commented 8 months ago

Hey - whoops, sorry for that, fixed and released in 2.1.1 :)