Html5控制浏览器打开摄像头并转base64输出
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div>
<button id="start">开启摄像头</button>
<button id='picture'>拍照</button>
<button id="sc">转为base64并输出</button>
<button id="stop">关闭摄像头</button>
</div>
<div>
<video id="video" autoplay="" style='width:640px;height:480px'></video>
<canvas id="canvas" width="640" height="480"></canvas>
</div>
<div>
<textarea id = "imgbase64" style="width:800px; height:700px"></textarea>
</div>
</body>
<script type="text/javascript">
var mediaStreamTrack;
var video = document.getElementById("video");

本文介绍了如何使用HTML5的WebRTC API控制浏览器访问摄像头,并将捕获的视频帧转换为Base64编码,以实现图片或视频数据的前端处理。
最低0.47元/天 解锁文章
3032

被折叠的 条评论
为什么被折叠?



