You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

25 lines
690 B

const cv2 = require('opencv4nodejs');
const path = require('path');
const express = require('express');
const app = express();
const server = require('http').Server(app);
const io = require('socket.io')(server);
app.set('view engine', 'ejs');
app.get('/', (req, res, next) => {
res.render('index');
});
const FPS = 100;
const Vcap = new cv2.VideoCapture(0);
Vcap.set(cv2.CAP_PROP_FRAME_WIDTH, 300);
Vcap.set(cv2.CAP_PROP_FRAME_HEIGHT, 300);
setInterval(() => {
const frame = Vcap.read();
const image = cv2.imencode('.jpg', frame).toString('base64');
io.emit('image', image);
}, 1000 / FPS);
server.listen(3030, () => console.log('narenltk says open up your browser'));