pmr-core
Version:
Core library of Poor Man's Rekognition project under CCExtractor Development
54 lines (50 loc) • 1.29 kB
text/typescript
import { ObjectBlob } from '../tracker/object-blob';
import { drawRect, saveImage, Image, waitKey, showImage } from 'nodoface';
import { utils } from '..';
export const colorPallete = [
[], // red
[], // orange
[], // yellow
[], // green
[], // cyan
[], // blue
[], // purple
[], // pink
[], // pink-red
[], // gray
[], // dark green
[], // brown
[], // white
[] // black
];
export const colorNames = [
'red',
'orange',
'yellow',
'green',
'cyan',
'blue',
'pink',
'pink-red',
'gray',
'dark-green',
'brown',
'white',
'black'
];
export function randomColor() {
let index = Math.round(Math.random() * (colorPallete.length - 1));
return colorPallete[index];
}
export class VisTracking {
static frame = 0;
static annotate(image: Image, blobs: ObjectBlob[]) {
blobs.forEach((blob, i) => {
let color = colorPallete[blob.getId() % colorPallete.length];
drawRect(image, blob.lastRect, color);
waitKey(1000 / 30);
});
showImage(image, 'vis');
this.frame++;
}
}