ExpoTHREE.createARBackgroundTexture(arSession, renderer) is an expo-three utility that returns a THREE.Texture that live-updates to display the current AR background frame.
And I am wondering how do we access the live-updated frames? Can we somehow read the data from the .image property of Texture?
What are you trying to do with a potential .image property in particular? What format would you expect this property to be in? Also it would have new data every frame – would you expect a push or poll API?
Hi, thank you for fast reply. I want to obtain the frame data so I can do some basic computer vision tasks or machine learning on it.
Given that, OpenCV will probably be used in most common cases, so 8-bit input image could be a desirable output format:
E.g. Canny Edge Detection: OpenCV: Canny Edge Detection
I guess a push API would be nice, the event of every frame update will call a listener with the frame data passed as a parameter would be ideal.
You could render the texture and use gl.readPixels(...) to read into a TypedArray and run OpenCV.js (are you planning on using an Emscripten build?) on that. Also you could use requestAnimationFrame(...) to schedule your own polls for now – that would give you the fastest refresh rate possible in JavaScript.
HTMLImageElement isn’t built-in to JavaScript, but it is built-into the DOM libraries conventionally available in web JavaScript contexts. React Native’s JavaScript context is a pure JavaScript context without the DOM, while it does have ‘polyfills’ for many common browser libraries such as requestAnimationFrame(...).
It would be really helpful for us to build cube like objects with sides using different materials, thank you! I can’t find a way to use CubeTexture directly because it depends on the DOM.
Hi bacon, thank you. As I mentioned in an ealier post (2 posts back), I have tried this. But somehow it doesn’t work, my code snippet is also up there. Would really appreciate any help! Thanks.
On second thought, just use the single instance. Basically when you clone the material you create separate references which allows you to use separate manipulation patterns. That’s what I was doing in my example, but this is actually less efficient than using the single instance.
If you find the materials are acting weird and not appearing then you will want to clone. Try and avoid that if you can