Giter Site home page Giter Site logo

Comments (9)

xavierjs avatar xavierjs commented on May 13, 2024

Take a look here : https://developer.mozilla.org/en-US/docs/Web/API/Media_Streams_API/Constraints
idealWidth and ideal height are only suggested values : it impacts the resolution of the video. The resolution of a video is different from its displayed size. If the webcam cannot set to the given values it can return a video with a different resolution.

Set the displayed size by setting the width and height attributes of the canvas element. Then the video will be cropped to fit into the canvas. Give the idealWidth and height as if it was always lanscape values.

If you want to switch dynamically between landscape and portrait mode, you need to resize the canvas, call the JEEFACEFILTERAPI.resize() function to recompute the crop params of the video and to recompute your projection matrix. You should take a look at the GLTF FULLSCREEN DEMO : https://jeeliz.com/demos/faceFilter/demos/threejs/gltf_fullScreen/

from jeelizfacefilter.

yuensunn avatar yuensunn commented on May 13, 2024

Please correct me if I'm wrong. Based on what you have just said, it seems like there is no way to have a true portrait video instead of cropping it from a landscape video? I have tried this sample demo on mobile, the video itself seems like it was cropped out of a landscape video (way too close up even with my arm extended at full length) sample image

from jeelizfacefilter.

xavierjs avatar xavierjs commented on May 13, 2024

If the camera is in landscape mode (a phone handled horizontally or a laptop), you will get a landscape video from getUserMedia API even if you request portrait ideal width and height.

Same for portrait mode : if your camera is in portrait mode, you will get a portrait video.

Then the video is cropped to fit the canvas the same way than CSS background: cover does : if the canvas is more landscape than the video we crop only top and bottom margins of the video, otherwise we crop only left and right margins.

But depending on the camera configuration sometimes the default zoom is too high. There is a draft API to give access to the camera intrinsic parameters but this is not available yet.

There are some informations about this issue here : #22

The demo you have tried (https://jeeliz.com/demos/faceFilter/demos/threejs/gltf_fullScreen/) is fullscreen. So it is in a very portrait mode (if we compute the canvas aspect ratio ac = canvasWidth/canvasHeight, ac is small).

I think the video from the webcam is less portrait (it depends a lot on the phone brand, the OS, the camera maker...). If we compute the video aspect ratio, av=videoWidth/videoHeight, we have av>ac .

So we need to crop the left and right margins quite a lot to display the video in fullscreen in order to not distort it or display blank space at the top/bottom.

So what I suggest is to not use a fullscreen canvas. With a square canvas for example we have ac=1 and the video should be less cropped (try the THREE.JS boilerplate demos for example).

from jeelizfacefilter.

yuensunn avatar yuensunn commented on May 13, 2024

I guess I will just use a square canvas until the new API releases. Thanks for the prompt feedback.

from jeelizfacefilter.

xavierjs avatar xavierjs commented on May 13, 2024

This is not a problem with FaceFilter API, so new releases won't change anything. I just wish the WebRTC standard will be better applied by browser and hardware builders.

from jeelizfacefilter.

xavierjs avatar xavierjs commented on May 13, 2024

I close the issue. Do not mind to re-open it.

from jeelizfacefilter.

ouzhou avatar ouzhou commented on May 13, 2024

i tried your gltf_fullScreen demo, it works
but the number of times it lost face is more bigger than rect canvas
any performance loss when fullscreen?

from jeelizfacefilter.

ouzhou avatar ouzhou commented on May 13, 2024

@xavierjs sorry i dont have any screenshot or any test code, i just feel it become more worse than use rect canvas, so if width !== height really cause performance loss?

from jeelizfacefilter.

xavierjs avatar xavierjs commented on May 13, 2024

In fullscreen mode, there are more pixels so it requires more computationnal power and it may be slower. It depends on your graphic hardware. The performance depends on the area of the canvas.

from jeelizfacefilter.

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.