VinceG/vue-web-cam

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

nickfan opened this issue · 1 comments

  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
}

i created a PR for this, maybe it could be helpful.
#62