Coder Social home page Coder Social logo

Comments (5)

klausw avatar klausw commented on May 22, 2024 8

@ArnaudHambenne is right, the current Chrome immersive-ar implementation does not allow JS-side access to camera pixels. For the future, my understanding is that there should be a separate API or feature that provides pose-aligned camera images, where applications would need to request such access at session start so that the user agent can show appropriate consent prompts.

See https://github.com/immersive-web/computer-vision which mentions this as a use case. Previous discussion was also in immersive-web/webxr#694 (comment) and immersive-web/proposals#36 .

(I also had some thoughts on this in a technical paper at https://www.tdcommons.org/dpubs_series/1902/ . That isn't intended to represent any particular future directions or plans, though I'm still partial to the dinosaur sketches.)

from webxr-samples.

bialpio avatar bialpio commented on May 22, 2024 2

There have been some efforts to make this happen. Very early prototype is available in Chrome, behind WebXRIncubations flag - the API is described here with a sample usage demonstrated here, but please note that the API is potentially unstable and in no way final.

from webxr-samples.

ArnaudHambenne avatar ArnaudHambenne commented on May 22, 2024 1

Hi @ArnaudHambenne ,

.readPixels() doesn't seem to work as well. What browser did you use and what device?

My code is something like -

  function onXRFrame(t, frame) {
        let session = frame.session;
        let gl = session.renderState.baseLayer.context;
        var pixels = new Uint8Array(gl.drawingBufferWidth * gl.drawingBufferHeight * 4);
        gl.readPixels(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight, gl.RGBA, gl.UNSIGNED_BYTE, pixels);
        if (pixels.every( (val, i, arr) => val === arr[0] ) ){
          console.log("none");
        }else{
            console.log(pixels);
        }
  }

What did you use to read the pixels?

I am not too worried about the performance hit as I would only like to read the frames at specific intervals. Could you please let me know if you used any other flag to access the pixel values?

Hi. It's been a while since I've worked on this API, although last time I did they had just released a major update stripping all extraction capabilities of the WebXR buffers out of privacy concerns. I'm not sure if they've come around on that, but if they haven't this means that neither readPixels() nor DrawImage() nor TransferToImageBitmap() can be used to extract the pixels from the buffers. All these functions will return an array of zeroes, so viewing any content of the buffers is off the table. I did however read that there was a group of people advocating for some kind of computer vision capabilities, but not sure how far they've come on that. Your code is probably fine.

from webxr-samples.

pavan4 avatar pavan4 commented on May 22, 2024

Hi @ArnaudHambenne ,

.readPixels() doesn't seem to work as well. What browser did you use and what device?

My code is something like -

  function onXRFrame(t, frame) {
        let session = frame.session;
        let gl = session.renderState.baseLayer.context;
        var pixels = new Uint8Array(gl.drawingBufferWidth * gl.drawingBufferHeight * 4);
        gl.readPixels(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight, gl.RGBA, gl.UNSIGNED_BYTE, pixels);
        if (pixels.every( (val, i, arr) => val === arr[0] ) ){
          console.log("none");
        }else{
            console.log(pixels);
        }
  }

What did you use to read the pixels?

I am not too worried about the performance hit as I would only like to read the frames at specific intervals. Could you please let me know if you used any other flag to access the pixel values?

from webxr-samples.

pikilipita avatar pikilipita commented on May 22, 2024

Are there any news on this issue?
It's a shame no to be able to let the user record a video or take a screenshot of his/her webXR session.

from webxr-samples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.