-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question about return of resize #38
Comments
Hey! I would love to return a
Overall it would definitely be a cooler API to return For now, you can still pass the returned type ( const { resize } = useResizePlugin()
const examplePlugin = VisionCameraProxy.initFrameProcessorPlugin('example_plugin')
const frameProcessor = useFrameProcessor((frame) => {
'worklet'
const resized = resize(frame, { ... })
const arrayBuffer = resized.buffer
// pass original `frame` because it is required for FPs, but we can ignore it later
examplePlugin.call(frame, {
// pass resized frame as an ArrayBuffer argument
resizedFrame: arrayBuffer
})
}, [resize]) Then just read the array from the arguments and ignore the @objc(ExampleFrameProcessorPlugin)
public class ExampleFrameProcessorPlugin: FrameProcessorPlugin {
public override func callback(_ frame: Frame, withArguments arguments: [AnyHashable: Any]?) -> Any? {
// we ignore `frame` as this is the full sized Frame
// SharedArray is from VisionCamera
let smallFrame = arguments["resizedFrame"] as SharedArray
smallFrame.data // <-- access
}
} |
Nice!! Thanks for the answer😁 |
Let's leave this open for now, maybe in the future there's gonna be an API in Android to create a pool of Images where I can have ownership of the memory without needing a Surface - that'd solve the problem of ImageWriter then! |
Hello!
It's possible resize/crop a frame and return as the same type "Frame" instead a "Uint8Array" or "Float32Array" ?😬
The text was updated successfully, but these errors were encountered: