Skip to content

Commit

Permalink
Streaming works again
Browse files Browse the repository at this point in the history
Also readme improvements, cleanup & fixes
  • Loading branch information
beele committed Jun 16, 2022
1 parent 6f43927 commit f9326b4
Show file tree
Hide file tree
Showing 10 changed files with 398 additions and 283 deletions.
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
foreground-scripts: true
loglevel: "verbose"
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: node_js
node_js: 12
node_js: 16
install:
- npm install
- npm run compile
script:
- npm run test
- npm run test
223 changes: 115 additions & 108 deletions README.md

Large diffs are not rendered by default.

135 changes: 109 additions & 26 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "homebridge-unifi-protect-camera-motion",
"version": "0.6.4-beta-001",
"version": "0.6.5",
"description": "Unifi Protect cameras & motion sensors for Homebridge. AI enabled Motion detection for Unifi Protect cameras.",
"main": "src/index.js",
"scripts": {
"postinstall": "node scripts/postinstall.js",
"prepublishOnly": "node --max-old-space-size=1024 ./node_modules/typescript/lib/tsc.js",
"compile": "node --max-old-space-size=1024 ./node_modules/typescript/lib/tsc.js",
"prepublishOnly": "tsc",
"compile": "tsc",
"homebridge": "tsc && homebridge -C -D -P . -U ./resources/test-config/",
"watch": "nodemon",
"test": "npm run compile && jest --config jest.config.js --collect-coverage && cd src/integration-tests && node detection-integration-test.js"
Expand Down
20 changes: 5 additions & 15 deletions src/integration-tests/detection-integration-test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {Canvas, Image} from "canvas";
import { Detection } from "../motion/motion";
import {ImageUtils} from "../utils/image-utils";

const assert = require("assert");
Expand All @@ -11,22 +12,12 @@ export class DetectionIntegrationTest {
}

public async run(): Promise<void> {
console.log('Loader-detect-image-full-model-IT');
// TODO: Fix tests!
/*
let modelLoader: Loader = new Loader(this.mockLogging());
let detector: Detector = await modelLoader.loadCoco(true);
await this.verifyDetections(detector);
console.log('Loader-detect-image-lite-model-IT');
modelLoader = new Loader(this.mockLogging());
detector = await modelLoader.loadCoco();
await this.verifyDetections(detector);
*/
console.log('Loader-detect-image');
// TODO: Implement new test for python based detector!
// await this.verifyDetections(detector);
}

private async verifyDetections(): Promise<void> {
/*
//This is needed to run on a machine which does not have a .homebridge folder!
const homebridgeDir = require('os').homedir() + '/.homebridge';
ImageUtils.userStoragePath = homebridgeDir;
Expand All @@ -37,7 +28,7 @@ export class DetectionIntegrationTest {
let image: Image = await ImageUtils.createImage(path.resolve('../../resources/images/test.jpg'));
assert(image !== null);

let detections: Detection[] = await detector.detect(image, true);
let detections: Detection[] = []; // TODO: Perform detection
assert(detections !== null);
assert(detections.length > 0);

Expand All @@ -47,7 +38,6 @@ export class DetectionIntegrationTest {
assert(stats.isFile() == true);

fs.unlinkSync(fileName);
*/
};

private mockLogging(): any {
Expand Down
1 change: 0 additions & 1 deletion src/motion/detector/upload/readme.md

This file was deleted.

2 changes: 2 additions & 0 deletions src/motion/motion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ export class MotionDetector {
continue outer;
}

const start = Date.now();
const data = await fetch('http://127.0.0.1:5050', { method: 'POST', body: form });
this.log.debug(camera.name + ' upload + yolo processing took: ' + (Date.now() - start) + 'ms');
const detections: Detection[] = this.mapDetectorJsonToDetections(await data.json());

for (const classToDetect of this.unifiConfig.enhanced_classes) {
Expand Down
Loading

0 comments on commit f9326b4

Please sign in to comment.