Is there a way to read videos from internet?(Opencv.JS)

asked 2018-02-13 06:42:21 -0600

my-lord gravatar image

updated 2018-02-13 07:08:37 -0600

Hello guys.I am wondering about "How to read Videos frame by frame from internet (youtube,dailymotion...) using an url with OPENCV.js ?"

I do some research on google and i find this topic http://answers.opencv.org/question/24...

I try this mp4 url

VideoCapture cap;
cap.open(https://www.w3schools.com/html/mov_bbb.mp4);

But this code doesn't work on OPENCV.js

I think VideoCapture has different syntax on Opencv.JS and i can't find this syntax on opencv.JS documentation

edit retag flag offensive close merge delete

Comments

can you take a look here ?

i'm not sure, but it looks like you have to have a <video> element on your page, and pass that to the VideoCapture, not any url (in js)

berak gravatar imageberak ( 2018-02-13 07:12:09 -0600 )edit

How can I place a hidden(not display) video tag , set its source url with javascript when the user press Start button on the html and do image-processing on this video?

my-lord gravatar imagemy-lord ( 2018-02-13 15:11:22 -0600 )edit

In your HTML you have to have a <video></video> tag, if want it to be hidden, just give style="display:none" and the src attribute should be the URL. Here is an example

<video id="videoId" src="https://www.w3schools.com/html/mov_bbb.mp4" style="display: none;" width="320" height="240"></video>

Then you can use cap like this

const video = document.querySelector('#videoId')
const {width, height} = video;

let img = new cv.Mat(height, width, cv.CV_8UC4);

const cap = new cv.VideoCapture(video);
cap.read(img);

Take a look at this example

Lucy8 gravatar imageLucy8 ( 2019-02-06 04:31:27 -0600 )edit