flash jquery 调用摄像头 vue chrome49浏览器

这个摄像头,不能一个页面加载多个,只能一个页面显示一次,所以 调用的时候,记得加v-if 把组件销毁,然后从新加载新的

<!--
* @description 摄像头vue版实例
* @fileName cameraObject.vue
* @author 彭成刚
* @date // ::
* @version V1.0.0
!-->
<template>
<div> <div id="webcam"></div>
<!--<button @click="jieping">截屏</button>-->
<div style="color:red; margin: 10px;">点击即可启用 Adobe Flash Player(拍照功能将启用Flash,第一次启用将会刷新页面,导致数据丢失,建议返回表单页面保存数据后开启拍照功能。)</div> <Button type='primary'
@click="handleCamera"
style="margin-bottom:5px; margin-right:5px;">拍照</Button><!--icon="md-camera"-->
<Button type='warning'
@click="leftRotate"
:disabled="buttonDisabled"
style="margin-bottom:5px; margin-right:5px;">逆旋转</Button>
<Button type='warning'
@click="rightRotate"
:disabled="buttonDisabled"
style="margin-bottom:5px;">正旋转</Button>
<!--<canvas id="canvas" width="" height=""></canvas>-->
<div>
<img ref="img" id="base64image" src='' />
</div>
</div>
</template> <script>
import jQuery from '@/../public/components/webcam/jquery.webcam'
export default {
data () {
return {
buttonDisabled: true,
timer: new Date().getTime().toString(),
picIsHave: false
}
}, components: {}, computed: {}, mounted () {
let _this = this
var pos = , ctx = null, saveCB, image = []; var canvas = document.createElement("canvas");
canvas.setAttribute('width', );
canvas.setAttribute('height', ); if (canvas.toDataURL) { ctx = canvas.getContext("2d"); image = ctx.getImageData(, , , ); saveCB = function(data) {
// console.info('data', data) var col = data.split(";");
var img = image; for(var i = ; i < ; i++) {
var tmp = parseInt(col[i]);
img.data[pos + ] = (tmp >> ) & 0xff;
img.data[pos + ] = (tmp >> ) & 0xff;
img.data[pos + ] = tmp & 0xff;
img.data[pos + ] = 0xff;
pos+= ;
} if (pos >= * * ) {
ctx.putImageData(img, , )
var base64 = canvas.toDataURL("image/png")
// console.info('canvas.toDataURL("image/png")',)
// document.getElementById('base64image').attributes('src',base64)
console.info('_this',_this)
jQuery('#base64image').attr('src',base64)
_this.buttonDisabled = false
// $.post("/upload.php", {type: "data", image: canvas.toDataURL("image/png")});
pos = ;
}
}; } else { saveCB = function(data) {
console.info('data2',data)
image.push(data); pos+= * ; if (pos >= * * ) {
console.info('data2 ok')
// $.post("/upload.php", {type: "pixel", image: image.join('|')});
pos = ;
}
};
} jQuery("#webcam").webcam({ width: ,
height: ,
mode: "callback",
swffile: "/familyMajor_web/components/webcam/jscam_canvas_only.swf", onSave: saveCB, onCapture: function () {
webcam.save();
}, debug: function (type, string) {
console.log(type + ": " + string);
}
});
}, methods: {
// 外层调用
getPicBase64 () {
let base64 = this.$refs.img.src
let ret = {
picIsHave: this.picIsHave,
base64: base64
}
return ret
},
handleCamera () {
this.picIsHave = true
webcam.capture()
},
leftRotate () {
let src = this.$refs.img.src
let edg = -
this.rotateBase64Img(src, edg, (_) => { this.$refs.img.src = _ })
},
rightRotate () {
let src = this.$refs.img.src
let edg =
this.rotateBase64Img(src, edg, (_) => { this.$refs.img.src = _ })
},
rotateBase64Img (src, edg, callback) {
var canvas = document.createElement('canvas')
var ctx = canvas.getContext('2d') var imgW // 图片宽度
var imgH // 图片高度
var size // canvas初始大小 if (edg % !== ) {
console.error('旋转角度必须是90的倍数!')
// throw '旋转角度必须是90的倍数!'
}
(edg < ) && (edg = (edg % ) + )
const quadrant = (edg / ) % // 旋转象限
const cutCoor = { sx: , sy: , ex: , ey: } // 裁剪坐标 var image = new Image()
image.crossOrigin = 'anonymous'
image.src = src image.onload = function () {
imgW = image.width
imgH = image.height
size = imgW > imgH ? imgW : imgH canvas.width = size *
canvas.height = size *
switch (quadrant) {
case :
cutCoor.sx = size
cutCoor.sy = size
cutCoor.ex = size + imgW
cutCoor.ey = size + imgH
break
case :
cutCoor.sx = size - imgH
cutCoor.sy = size
cutCoor.ex = size
cutCoor.ey = size + imgW
break
case :
cutCoor.sx = size - imgW
cutCoor.sy = size - imgH
cutCoor.ex = size
cutCoor.ey = size
break
case :
cutCoor.sx = size
cutCoor.sy = size - imgW
cutCoor.ex = size + imgH
cutCoor.ey = size + imgW
break
} ctx.translate(size, size)
ctx.rotate(edg * Math.PI / )
ctx.drawImage(image, , ) var imgData = ctx.getImageData(cutCoor.sx, cutCoor.sy, cutCoor.ex, cutCoor.ey)
if (quadrant % === ) {
canvas.width = imgW
canvas.height = imgH
} else {
canvas.width = imgH
canvas.height = imgW
}
ctx.putImageData(imgData, , )
callback(canvas.toDataURL())
}
} }
} </script>
<style lang='less'> </style>

flash jquery 调用摄像头 vue chrome49浏览器的更多相关文章

  1. 使用vue做移动app时,调用摄像头扫描二维码

    现在前端技术发展飞快,前端都能做app了,那么项目中,也会遇到调用安卓手机基层的一些功能,比如调用摄像头,完成扫描二维码功能 下面我就为大家讲解一下,我在项目中调用这功能的过程. 首先我们需要一个中间 ...

  2. vue实现PC端调用摄像头拍照人脸录入、移动端调用手机前置摄像头人脸录入、及图片旋转矫正、压缩上传base64格式/文件格式

    进入正题 1. PC端调用摄像头拍照上传base64格式到后台,这个没什么花里胡哨的骚操作,直接看代码 (canvas + video) <template> <div> &l ...

  3. html5调用摄像头并拍照

    随着flash被禁用,flash上传附件的方式已成为过去,现在开始用html5上传了.本片文章就是介绍如何使用html5拍照,其实挺简单的原理: 调用摄像头采集视频流,利用canvas的特性生成bas ...

  4. jQuery 调用jsonp实现与原理

    jQuery 调用jsonp实现与原理 您的评价:        收藏该经验     阅读目录 1.客户端代码 2.服务器端 通过jQuery实现JSONP 一般的ajax是不能跨域请求的,因此需要使 ...

  5. HTML之调用摄像头实现拍照和摄像功能

    应该有很多人知道,我们的手机里面有个功能是“抓拍入侵者”,说白了就是在解锁应用时如果我们输错了密码手机就会调用这一功能实现自动拍照. 其实在手机上还有很多我们常用的软件都有类似于这样的功能,比如微信扫 ...

  6. web HTML5 调用摄像头的代码

    最近公司要求做一个在线拍照的功能,具体代码如下: <html> <head> <title>html5调用摄像头拍照</title> <style ...

  7. VS2010中使用Jquery调用Wcf服务读取数据库记录

    VS2010中使用Jquery调用Wcf服务读取数据库记录 开发环境:Window Servere 2008 +SQL SERVE 2008 R2+ IIS7 +VS2010+Jquery1.3.2 ...

  8. 抛弃WebService,在.NET4中用 jQuery 调用 WCF

    在我们之前的开发中,对于ajax程序,都是通过jQuery调用标记为[System.Web.Script.Services.ScriptService]的WebService,然后在WebServic ...

  9. [转]html5调用摄像头实例

    原文:https://blog.csdn.net/binquan_liang/article/details/79489989 最近在学习在做HTML5的项目,看了博客上html5调用摄像头拍照的文章 ...

随机推荐

  1. The web.config file for this project is missing the required DirectRequestModule.

    The web.config file for this project is missing the required DirectRequestModule.   将应用程序集的模式由集成改为经典 ...

  2. 基于pthread实现读写锁

    读写锁可用于在多线程访问map等数据结构时使用 #include <pthread.h> class ReadWriteLock { public: ReadWriteLock() { p ...

  3. Bzoj 3380: [Usaco2004 Open]Cave Cows 1 洞穴里的牛之一

    3380: [Usaco2004 Open]Cave Cows 1 洞穴里的牛之一 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 64  Solved ...

  4. PV、UV、VV、IP是什么意思?

    PV.UV.VV.IP作为网站分析中最常见的基础指标,能够从宏观概括性地衡量网站的整体运营状况,也是检测网站运营是否正常的最直观的指标. 1.VV(来访次数/访问次数):VisitView 记录所有访 ...

  5. nodejs动态路由

    主要功能:根据输入路由的不同,加载访问不同的HTML页面 在这里我不得不说webstorm真的是一个很棒的开发工具,我学习nodejs也是用的它. 文件目录: first_server.js: 首先我 ...

  6. 黑马学习Ajax 概念和基本使用

  7. Java程序的运行机制和JVM

    1. Java语言比较特殊, 由Java编写的程序需要经过编译步骤,但这个编译步骤不会产生特定平台的机器码,而是生成一种与平台无关的字节码(也就是.class文件).这种字节码不是可执行性的,必须使用 ...

  8. 新的JSON / YAML插件:在JMeter中使用YAML

    在JMS插件从jmeter-plugins.org捐赠给核心JMeter之后,JSON插件在Apache JMeter™版本4中被弃用.现在,我已更新此插件以支持新功能和新功能.在这个新版本中,两个插 ...

  9. HTML5----前段各种常见BUG

     1.在IE6下,DIV中的字会多出,并且自成一行,而且是原来的字. 这是注释bug,经典的ie6 bug.    说明:注释造成文字溢出是IE6的BUG,注释造成文字溢出与其位置有关,注释造成文字溢 ...

  10. ZROI WC Round5 题解

    ZROI WC Round5 题解 Problem A 题意 给定一个长度为 \(n\) 的序列,操作是交换两个相邻的数,要求将序列变成先单调不降再单调不升,求最小操作数,注意可以完全单调不降或者完全 ...