简体   繁体   English

是否可以在javascript / html中更改相机方向?

[英]Is it possible to change camera orientation in javascript/html?

I am building a camera based application in HTML/Javascript that utilizes live video feed. 我正在使用HTML / Javascript构建基于摄像头的应用程序,该应用程序利用实时视频源。 The device this is going to run on has a tall screen (think 1080x1920). 要在其上运行的设备具有较高的屏幕(请考虑1080x1920)。 When using a camera I can't stretch the feed to fit the full screen as it auto-sets the height based on the width, even when I force it to something else. 使用相机时,我无法将Feed拉伸到适合整个屏幕的高度,因为它会根据宽度自动设置高度,即使我将其强制设置为其他值也是如此。

Is there any way to change the camera orientation to portrait? 有什么方法可以将相机方向更改为纵向? I believe that will fix it if that is possible. 我相信如果可能的话,它将解决此问题。 If not, is there some way to force dimensions of camera feed? 如果不是,是否有某种方法可以强制相机进纸的尺寸? Right now I have to rotate the camera onto its side and rotate the video feed accordingly to get it to what I need, but this feed will have a picture taken, and in doing so the saved image is rotated. 现在,我必须将相机旋转到一边,并相应地旋转视频源,以使其达到我需要的位置,但是此源将拍摄照片,并且这样做会旋转保存的图像。 There is just a lot to account for this way and it seems like something that should be relatively easy to do. 这种方式有很多要说明的地方,似乎有些事情应该比较容易做到。

In the framework webcam.js you can set input and output dimensions. 在框架webcam.js中,您可以设置输入和输出尺寸。 https://github.com/jhuckaby/webcamjs https://github.com/jhuckaby/webcamjs

Example: 例:

Webcam.set({
    width: 1080,
    height: 1920,
    dest_width: 1080,
    dest_height: 1920,
    flip_horiz: false,
    force_flash: false,
    image_format: 'jpeg',
    jpeg_quality: 100
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM