webAPi,使用js调取设备摄像头
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>video</title>
<style>
#video {
width: 100%;
}
</style>
</head>
<body>
<video autoplay id="video"></video>
</body>
<script>
async function init() {
video.srcObject = await navigator.mediaDevices.getUserMedia({
video: {
width: {
min: 1280,
ideal: 1920,
max: 2560,
},
height: {
min: 720,
ideal: 1080,
max: 1440,
},
facingMode: "user"
},
});
}
init();
</script>
</html>