Giter VIP home page Giter VIP logo

camera's Introduction

camera

摄像头调用库,基于H5的api

使用

  • browser: window.Camera
<!--在head引入camera.js-->
<script src="./camera.js"></script>
<!--需要有用于初始化的video元素-->
<video id="myCamera" autoplay style="width: 500px;height: 500px"></video>
<img src="" alt="" id="img">
<button id="btn">拍摄</button>
<script>
  var myCamera = new Camera('myCamera');
  myCamera.init(function () {
    console.log('success');
  },function (err) {
    console.log('error');
  });
  btn.addEventListener('click', function () {
    myCamera.shoot({}, function (imageSrc) {
      document.getElementById('img').src = imageSrc;
      console.log(myCamera.imageSrcList)
    });
  }, false);
</script>

方法

init([successCallback, errorCallback])

初始化

destroy()

销毁

shoot([option, callback])

  • option
    • x
    • y
    • width
    • height
  • callback

拍照成功的回调,参数是照片的base64

工具

windowUrl()

返回浏览器兼容的window.URL对象

getUserMedia()

返回浏览器兼容的navigator.getUserMedia函数

toCamelCase(str)

字符串转驼峰

getStyle(el, styleName)

返回样式的值

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.