网友回复
使用ew ImageCapture(videoTrack)与navigator.mediaDevices.getUserMedia实现,完整代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Camera Capture</title>
<style>
body {
font-family: Arial, sans-serif;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
}
#preview {
margin-top: 20px;
max-width: 80%;
}
button {
margin-top: 20px;
}
</style>
</head>
<body>
<h1>Camera Capture</h1>
<button onclick="capturePhoto()">拍照</button>
<img id="preview" ref="previewImg" alt="Captured Ph...点击查看剩余70%


