-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
44 lines (35 loc) · 1.09 KB
/
index.js
File metadata and controls
44 lines (35 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const express = require('express')
const cv = require('opencv4nodejs')
const path = require('path')
const app = express()
const _PORT = 3000
const server = require('http').createServer(app)
const io = require('socket.io')(server)
const spawn = require("child_process").spawn
//const _PATHPS = '../cvcd/CardDetector.py'
//const pythonProces = spawn('python3', [_PATHPS])
const wCap = new cv.VideoCapture(0)
const _FR = 30
function load_ranks(filepath) {
let train_ranks = []
let i = 0
return train_ranks
}
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname,'splash.html'))
})
const height = 800
const width = 800
let src = new cv.Mat(height, width, cv.CV_8UC4);
let dst = new cv.Mat(height, width, cv.CV_8UC1);
setInterval(()=> {
const frame = wCap.read()
//todo: process image here
let gray = frame.cvtColor(cv.COLOR_BGR2GRAY)
let blur = gray.gaussianBlur(new cv.Size(5,5),0)
const image = cv.imencode('.jpg', frame).toString('base64')
io.emit('image', image)
}, 1000 / _FR)
server.listen('3000', () => {
console.log('listening on 3000')
})