Successfully training models based on a collection of images
This commit is contained in:
15
src/index.ts
15
src/index.ts
@ -1,26 +1,11 @@
|
||||
import { Rtsp } from "rtsp-stream/lib";
|
||||
// import nodejs bindings to native tensorflow,
|
||||
// not required, but will speed up things drastically (python required)
|
||||
|
||||
import * as faceapi from "face-api.js";
|
||||
|
||||
// implements nodejs wrappers for HTMLCanvasElement, HTMLImageElement, ImageData
|
||||
const canvas = require("canvas");
|
||||
|
||||
// patch nodejs environment, we need to provide an implementation of
|
||||
// HTMLCanvasElement and HTMLImageElement
|
||||
const { Canvas, Image, ImageData } = canvas;
|
||||
faceapi.env.monkeyPatch({ Canvas, Image, ImageData });
|
||||
|
||||
const main = async () => {
|
||||
const rtsp = new Rtsp("rtsp://brandon:asdf1234@192.168.1.229/live", {
|
||||
rate: 10,
|
||||
});
|
||||
await faceapi.nets.ssdMobilenetv1.loadFromDisk("./resources");
|
||||
|
||||
rtsp.on("data", async (data: Buffer) => {
|
||||
const input = await canvas.loadImage(data);
|
||||
const detections = await faceapi.detectAllFaces(input);
|
||||
console.log();
|
||||
process.exit(0);
|
||||
});
|
||||
|
Reference in New Issue
Block a user