Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何从上传视频的随机点获取图像,以提供AutoML模型?_Javascript_Html_Computer Vision_Tensorflow.js_Automl - Fatal编程技术网

Javascript 如何从上传视频的随机点获取图像,以提供AutoML模型?

Javascript 如何从上传视频的随机点获取图像,以提供AutoML模型?,javascript,html,computer-vision,tensorflow.js,automl,Javascript,Html,Computer Vision,Tensorflow.js,Automl,我希望能够运行一个基于图像分类但带有视频的tensorflow.js模型。我希望能够抓取视频的多个快照,并将其传递给图像分类模型。如何抓取视频的多个快照,以便稍后将其传递到模型中 我试过: onFileChange(e) { const file = e.target.files[0]; this.url = URL.createObjectURL(file); this.video = document.getElementById('

我希望能够运行一个基于图像分类但带有视频的tensorflow.js模型。我希望能够抓取视频的多个快照,并将其传递给图像分类模型。如何抓取视频的多个快照,以便稍后将其传递到模型中

我试过:

    onFileChange(e) {

        const file = e.target.files[0];
        this.url = URL.createObjectURL(file);
        this.video = document.getElementById('video');

        this.video.src = this.url; 

        var canvas = document.getElementById('canvas');
        //var context = canvas.getContext('2d');
        canvas.width = this.videoWidth;
        canvas.height = this.videoHeight;

        this.video.addEventListener('loadeddata', function() {
            var $this = this; //cache

            const image = document.getElementById('img');

            $this.currentTime = Math.floor((Math.random() * $this.duration) + 1);
            $this.width = $this.videoWidth;
            $this.height = $this.videoHeight;

            canvas.getContext('2d').drawImage($this, 0, 0, canvas.width, canvas.height);

            image.src = canvas.toDataURL();

            const predictions =     this.model.classify(image);
            console.log(predictions);

        }, false);

        
        

        
    },
    


但这似乎没有更新画布,我只是不知道为什么