惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The Hacker News
The Hacker News
MyScale Blog
MyScale Blog
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
GbyAI
GbyAI
罗磊的独立博客
M
MIT News - Artificial intelligence
J
Java Code Geeks
P
Proofpoint News Feed
月光博客
月光博客
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Google DeepMind News
Google DeepMind News
The Cloudflare Blog
T
The Blog of Author Tim Ferriss
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
雷峰网
雷峰网
V
V2EX
有赞技术团队
有赞技术团队
Microsoft Security Blog
Microsoft Security Blog
博客园 - Franky
IT之家
IT之家
博客园 - 三生石上(FineUI控件)
Webroot Blog
Webroot Blog
S
Secure Thoughts
Recent Announcements
Recent Announcements
T
Troy Hunt's Blog
Engineering at Meta
Engineering at Meta
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Hacker News: Ask HN
Hacker News: Ask HN
酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
Schneier on Security
Schneier on Security
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Heimdal Security Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Cyberwarzone
Cyberwarzone
N
News and Events Feed by Topic
T
Threat Research - Cisco Blogs
Martin Fowler
Martin Fowler
Hacker News - Newest:
Hacker News - Newest: "LLM"
Microsoft Azure Blog
Microsoft Azure Blog
Help Net Security
Help Net Security
S
SegmentFault 最新的问题
A
Arctic Wolf
C
Cybersecurity and Infrastructure Security Agency CISA
V
Vulnerabilities – Threatpost
腾讯CDC
K
Kaspersky official blog
博客园_首页

博客园 - 火腿骑士

webstorm+nodejs+express配置 树莓派raspberry pi配置无线路由器AP 树莓派raspberry pi配置 html5使用canvas实现毫秒级画心电图 html5使用canvas动态画医学设备毫秒级数据波形图 IntelliJ IDEA web项目 工程构建运行部署 [转]把树莓派配置成无线路由器 [转]Raspberry Pi做成路由器 websocket for python Linux 升级 Python 至 3.x 防抖(Debounce)与节流( throttle)区别 spring mvc 实战化项目之三板斧 vue开发资料 asp.net mvc 实战化项目之三板斧 [转]gulp构建前端工程 gulp前端自动化构建工具使用 laravel实战化项目之三板斧 免费网络视频监控软件cmsclient awesomes前端资源库网站
H5调用本地摄像头[转]
火腿骑士 · 2017-03-16 · via 博客园 - 火腿骑士

http://www.cnblogs.com/GoodPingGe/p/4726126.html

<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="http://123.56.106.187:8010/Scripts/listjs/jquery-1.7.2.min.js"></script>
<script>
//判断浏览器是否支持HTML5 Canvas
window.onload = function () {
try {
//动态创建一个canvas元 ,并获取他2Dcontext。如果出现异常则表示不支持 document.createElement("canvas").getContext("2d");
// document.getElementById("support").innerHTML = "浏览器支持HTML5 CANVAS";
}
catch (e) {
// document.getElementByIdx("support").innerHTML = "浏览器不支持HTML5 CANVAS";
}
};
//这段代 主要是获取摄像头的视频流并显示在Video 签中
window.addEventListener("DOMContentLoaded", function () {
var canvas = document.getElementById("canvas"),
context = canvas.getContext("2d"),
video = document.getElementById("video"),
videoObj = { "video": true },
errBack = function (error) {
console.log("Video capture error: ", error.code);
};
$("#snap").click(function () {
context.drawImage(video, 0, 0, 330, 250);
})
//navigator.getUserMedia这个写法在Opera中好像是navigator.getUserMedianow
if (navigator.getUserMedia) {
navigator.getUserMedia(videoObj, function (stream) {
video.srcObject  = stream;
video.play();
}, errBack);
} else if (navigator.webkitGetUserMedia) {
navigator.webkitGetUserMedia(videoObj, function (stream) {
video.src = window.webkitURL.createObjectURL(stream);
video.play();
}, errBack);
}

}, false);

//上传服务器
function CatchCode() {
var canvans = document.getElementById("canvas");
//获取浏览器页面的画布对象
//以下开始编 数据
var imgData = canvans.toDataURL();
//将图像转换为base64数据
var base64Data = imgData.substr(22);
//在前端截取22位之后的字符串作为图像数据
//开始异步上
$.post("uploadImgCode.ashx", { "img": base64Data }, function (data, status) {
if (status == "success") {
if (data == "OK") {
alert("二维 已经解析");
}
else {
// alert(data);
}
}
else {
alert("数据上 失败");
}
}, "text");
}
</script>
</head>
<body>
<div id="contentHolder">
<video id="video" width="320" height="320" autoplay>
</video>
<input type="button" id="snap" style="width:100px;height:35px;" value="拍 照" />
<canvas style="" id="canvas" width="320" height="320">
</canvas>
</div>
</body>
</html>