


Share an example tutorial on using h5 to call the camera to take pictures
Technology is advancing all the time. Our needs are also changing all the time. Recently, during development, I encountered the problem that users need a personal image when registering an account, and the website provides an automatic photo taking function. Also, after logging in to the computer, when logging in on the mobile phone, you only need to scan the QR code on the computer to log in. This is extremely difficult for a network. The advancement of technology has led us to HTML5The following simple and crude demonstration is to complete these functions directly by looking at the code:
<!DOCTYPE html> <HTML> <HEAD> <TITLE> HTML5调用摄像头实现拍照</ TITLE> <meta charset =“utf-8”> <meta name =“viewport”content =“width = device-width,initial-scale = 1”> </ HEAD> <BODY> <video id =“video”autoplay =“”style ='width:640px; height:480px'> </ video> <button id =“paizhao”>拍照</ button> <canvas id =“canvas”width =“640”height =“480”> </ canvas> <script type =“text / javascript”> var video = document.getElementById(“video”); var context = canvas.getContext(“2d”); var errocb = function(){ console.log(“sth srong”); } 如果(navigator.getUserMedia){ navigator.getUserMedia({ “视频”:真},函数(流){ video.src =流; video.play(); },errocb); } else if(navigator.webkitGetUserMedia){ navigator.webkitGetUserMedia({ “视频”:真},函数(流){ video.src = window.webkitURL.createObjectURL(流); video.play(); },errocb); } 的document.getElementById( “paizhao”)的addEventListener( “点击”,函数(){ context.drawImage(视频,0,0,640,480); }); </ SCRIPT> </ BODY> </ HTML>
[Related recommendations]
1. Detailed examples of implementing the camera function through H5
2. HTML5 sample code sharing for calling the camera
4. HTML5 custom mask implementation code sharing
5. Detailed introduction to the details of pictures and texts using HTML5 camera in AngularJS
The above is the detailed content of Share an example tutorial on using h5 to call the camera to take pictures. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.
