-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathapp.js
75 lines (59 loc) · 2.04 KB
/
app.js
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
const express = require('express');
var router = express.Router();
const darknet = require('@moovel/yolo');
const fs = require('fs');
var app = express();
var sendDetections;
app.set("view engine", "ejs");
app.set('views', __dirname + '/views');
app.use(express.static(__dirname + '/public'));
//app.use(express.static('public'));
app.use('/public', express.static('public'));
app.get('/', function(req,res) {
res.send('hello');
});
app.get('/dashboard', function(req, res) {
res.render('dashboard');
});
app.use('/roadPage', function(req, res) {
res.render('roadPage');
});
app.use('/roadBoard', function(req, res) {
res.render('roadBoard');
});
app.use('/roadMap', function(req, res) {
res.render('roadMap');
});
app.post('/sendDetectInfo', function(req, res) {
res.send( sendDetections );
});
//./darknet detector demo cfg/coco.data cfg/yolo.cfg yolo.weights <video file>
darknet.detect({
cfg: './cfg/yolo.cfg',
weights: './yolo.weights',
data: './cfg/coco.data',
cameraIndex: 0, // optional, default: 0,
video: './test2.mp4', // optional, forces to use the video file instead of a camera
thresh: 0.24, // optional, default: 0.24
hierThresh: 0.5, // optional, default: 0.5
}, function(modified, original, detections, dimensions) {
//console.log(modified.length, original.length, detections, dimensions);
console.log(detections);
sendDetections = detections;
//var jsonData = JSON.stringify(detections);
//console.log(jsonData);
//fs.writeFileSync('./data.modified.raw', modified);
// ffmpeg -f rawvideo -s 768x576 -pix_fmt bgr24 -i data.raw data.png
//fs.writeFileSync('./data.raw', original);
// ffmpeg -f rawvideo -s 768x576 -pix_fmt bgr24 -i data.modified.raw data.png
/*
modified - raw frame with detections drawn, rgb24 format
original - raw frame, as captured by the webcam/video, rgb24 format,
detections - array of detections
dimenstions - image width and height
*/
});
app.listen(3007, function() {
console.log('Example app listening on port 3007!');
console.log('http://192.168.0.174:3007/');
});