VinceG / vue-web-cam

Webcam component for VueJs.
MIT License
257 stars 110 forks source link

feature request: manually call setupMedia and assign canvas Element by object refs #61

Open nickfan opened 4 years ago

nickfan commented 4 years ago
  1. is that possible to add a property something like 'autosetup' to control Whether call this.setupMedia() on mounted or not?
autosetup: {
      type: Boolean,
      default: true
    },

so that we can give user to show some guide ui before the browser pop up the permission request on page load.

  1. i want to integration something like opencv or face detect api that required to setup a canvas element .
    /**
     * get canvas
     */
    getCanvas() {
      let video = this.$refs.video;
      if (!this.ctx) {
        let canvas = document.createElement("canvas");
        canvas.height = video.videoHeight;
        canvas.width = video.videoWidth;
        this.canvas = canvas;
        this.ctx = canvas.getContext("2d");
      }
      const { ctx, canvas } = this;
      ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
      return canvas;
    }

so is that possible to add a property something like 'canvasEl'

canvasEl: {
      type: Object,
      default: null
    },

so change code into something like this:

if(this.$refs.canvasEl !==null){
    let canvas = this.$refs.canvasEl
}
nickfan commented 4 years ago

i created a PR for this, maybe it could be helpful. https://github.com/VinceG/vue-web-cam/pull/62