当前位置:网站首页>JS call camera
JS call camera
2022-07-06 16:02:00 【Star age Cao Botao】
<!doctype html>
<html lang="en">
<head>
<title>GET VIDEO</title>
<meta charset="utf-8">
</head>
<body>
<input type="button" title=" Turn on camera " value=" Turn on camera " onclick="getMedia()" />
<video id="video" width="500px" height="500px" autoplay="autoplay"></video>
<canvas id="canvas" width="500px" height="500px"></canvas>
<button id="snap" onclick="takePhoto()"> Taking pictures </button>
<script> // get video Camera area let video = document.getElementById("video"); function getMedia() {
let constraints = {
video: {
width: 500, height: 500}, audio: true }; /* Here's a new way :H5 New media interface navigator.mediaDevices.getUserMedia() This method will prompt the user whether to allow media input ,( Media input mainly includes camera , Video capture devices , Screen sharing service , Microphone ,A/D Converter, etc ) Back to a Promise object . If the user agrees to use the permission , Will be MediaStream Object as resolve() The parameters of are passed to then() If the user denies permission , Or the requested media resource is not available , Will be PermissionDeniedError As reject() The parameters of are passed to catch() */ let promise = navigator.mediaDevices.getUserMedia(constraints); promise.then(function (MediaStream) {
video.srcObject = MediaStream; video.play(); }).catch(function (PermissionDeniedError) {
console.log(PermissionDeniedError); }) } function takePhoto() {
// get Canvas object let canvas = document.getElementById("canvas"); let ctx = canvas.getContext('2d'); ctx.drawImage(video, 0, 0, 500, 500); } </script>
</body>
</html>
边栏推荐
- China's earthwork tire market trend report, technical dynamic innovation and market forecast
- 信息安全-安全编排自动化与响应 (SOAR) 技术解析
- Cost accounting [16]
- China's salt water membrane market trend report, technological innovation and market forecast
- Record of force deduction and question brushing
- Market trend report, technical innovation and market forecast of geosynthetic clay liner in China
- 【练习-7】(Uva 10976)Fractions Again?!(分数拆分)
- STM32 learning record: LED light flashes (register version)
- Flink 使用之 CEP
- JS调用摄像头
猜你喜欢

渗透测试 ( 8 ) --- Burp Suite Pro 官方文档

X-Forwarded-For详解、如何获取到客户端IP
![[exercise-7] crossover answers](/img/66/3dcba2e70a4cd899fbd78ce4d5bea2.png)
[exercise-7] crossover answers

Penetration test (8) -- official document of burp Suite Pro

程序员的你,有哪些炫技的代码写法?

Determine the Photo Position

Optimization method of path problem before dynamic planning

Penetration test (2) -- penetration test system, target, GoogleHacking, Kali tool

1010 things that college students majoring in it must do before graduation

Information security - threat detection - detailed design of NAT log access threat detection platform
随机推荐
b站 实时弹幕和历史弹幕 Protobuf 格式解析
渗透测试 ( 2 ) --- 渗透测试系统、靶机、GoogleHacking、kali工具
STM32 how to use stlink download program: light LED running light (Library version)
Accounting regulations and professional ethics [1]
初入Redis
7-1 懂的都懂 (20 分)
Research Report on surgical fluid treatment industry - market status analysis and development prospect prediction
[exercise-9] Zombie's Treasury test
Nodejs+vue网上鲜花店销售信息系统express+mysql
Record of brushing questions with force deduction -- complete knapsack problem (I)
Market trend report, technical innovation and market forecast of lip care products in China and Indonesia
Cost accounting [19]
Penetration test (2) -- penetration test system, target, GoogleHacking, Kali tool
Penetration testing (5) -- a collection of practical skills of scanning King nmap and penetration testing tools
D - Function(HDU - 6546)女生赛
【练习-2】(Uva 712) S-Trees (S树)
【练习-8】(Uva 246)10-20-30==模拟
【练习-1】(Uva 673) Parentheses Balance/平衡的括号 (栈stack)
用C语言写网页游戏
渗透测试 2 --- XSS、CSRF、文件上传、文件包含、反序列化漏洞