简体   繁体   中英

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. The device this is going to run on has a tall screen (think 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.

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. 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
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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