mirror of https://github.com/vladmandic/human
updated gesture types
parent
fbe8a8b0f6
commit
e84e421a04
|
@ -26,6 +26,7 @@
|
||||||
"rules": {
|
"rules": {
|
||||||
"@typescript-eslint/ban-ts-comment": "off",
|
"@typescript-eslint/ban-ts-comment": "off",
|
||||||
"@typescript-eslint/explicit-module-boundary-types": "off",
|
"@typescript-eslint/explicit-module-boundary-types": "off",
|
||||||
|
"@typescript-eslint/no-shadow": "error",
|
||||||
"@typescript-eslint/no-var-requires": "off",
|
"@typescript-eslint/no-var-requires": "off",
|
||||||
"camelcase": "off",
|
"camelcase": "off",
|
||||||
"dot-notation": "off",
|
"dot-notation": "off",
|
||||||
|
@ -44,6 +45,7 @@
|
||||||
"no-bitwise": "off",
|
"no-bitwise": "off",
|
||||||
"no-case-declarations":"off",
|
"no-case-declarations":"off",
|
||||||
"no-continue": "off",
|
"no-continue": "off",
|
||||||
|
"no-lonely-if": "off",
|
||||||
"no-loop-func": "off",
|
"no-loop-func": "off",
|
||||||
"no-mixed-operators": "off",
|
"no-mixed-operators": "off",
|
||||||
"no-param-reassign":"off",
|
"no-param-reassign":"off",
|
||||||
|
@ -52,12 +54,12 @@
|
||||||
"no-restricted-globals": "off",
|
"no-restricted-globals": "off",
|
||||||
"no-restricted-syntax": "off",
|
"no-restricted-syntax": "off",
|
||||||
"no-return-assign": "off",
|
"no-return-assign": "off",
|
||||||
|
"no-shadow": "off",
|
||||||
"no-underscore-dangle": "off",
|
"no-underscore-dangle": "off",
|
||||||
"node/no-missing-import": ["error", { "tryExtensions": [".js", ".json", ".ts"] }],
|
"node/no-missing-import": ["error", { "tryExtensions": [".js", ".json", ".ts"] }],
|
||||||
"node/no-unpublished-import": "off",
|
"node/no-unpublished-import": "off",
|
||||||
"node/no-unpublished-require": "off",
|
"node/no-unpublished-require": "off",
|
||||||
"node/no-unsupported-features/es-syntax": "off",
|
"node/no-unsupported-features/es-syntax": "off",
|
||||||
"no-lonely-if": "off",
|
|
||||||
"node/shebang": "off",
|
"node/shebang": "off",
|
||||||
"object-curly-newline": "off",
|
"object-curly-newline": "off",
|
||||||
"prefer-destructuring": "off",
|
"prefer-destructuring": "off",
|
||||||
|
|
|
@ -9,7 +9,10 @@ Repository: **<git+https://github.com/vladmandic/human.git>**
|
||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
### **HEAD -> main** 2021/07/19 marcogodoy@untitled.cl
|
### **HEAD -> main** 2021/07/29 mandic00@live.com
|
||||||
|
|
||||||
|
|
||||||
|
### **origin/main** 2021/07/19 marcogodoy@untitled.cl
|
||||||
|
|
||||||
- add note on manually disping tensor
|
- add note on manually disping tensor
|
||||||
- modularize model loading
|
- modularize model loading
|
||||||
|
|
|
@ -4,9 +4,41 @@
|
||||||
|
|
||||||
import { Gesture } from '../result';
|
import { Gesture } from '../result';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef FaceGesture
|
||||||
|
*/
|
||||||
|
export type FaceGesture =
|
||||||
|
`facing ${'left' | 'center' | 'right'}`
|
||||||
|
| `blink ${'left' | 'right'} eye`
|
||||||
|
| `mouth ${number}% open`
|
||||||
|
| `head ${'up' | 'down'}`;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef IrisGesture
|
||||||
|
*/
|
||||||
|
export type IrisGesture =
|
||||||
|
'facing center'
|
||||||
|
| `looking ${'left' | 'right' | 'up' | 'down'}`
|
||||||
|
| 'looking center';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef BodyGesture
|
||||||
|
*/
|
||||||
|
export type BodyGesture =
|
||||||
|
`leaning ${'left' | 'right'}`
|
||||||
|
| `raise ${'left' | 'right'} hand`
|
||||||
|
| 'i give up';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef BodyGesture
|
||||||
|
*/
|
||||||
|
export type HandGesture =
|
||||||
|
`${'thumb' | 'index finger' | 'middle finger' | 'ring finger' | 'pinky'} forward`
|
||||||
|
| `${'thumb' | 'index finger' | 'middle finger' | 'ring finger' | 'pinky'} up`;
|
||||||
|
|
||||||
export const body = (res): Gesture[] => {
|
export const body = (res): Gesture[] => {
|
||||||
if (!res) return [];
|
if (!res) return [];
|
||||||
const gestures: Array<{ body: number, gesture: string }> = [];
|
const gestures: Array<{ body: number, gesture: BodyGesture }> = [];
|
||||||
for (let i = 0; i < res.length; i++) {
|
for (let i = 0; i < res.length; i++) {
|
||||||
// raising hands
|
// raising hands
|
||||||
const leftWrist = res[i].keypoints.find((a) => (a.part === 'leftWrist'));
|
const leftWrist = res[i].keypoints.find((a) => (a.part === 'leftWrist'));
|
||||||
|
@ -26,7 +58,7 @@ export const body = (res): Gesture[] => {
|
||||||
|
|
||||||
export const face = (res): Gesture[] => {
|
export const face = (res): Gesture[] => {
|
||||||
if (!res) return [];
|
if (!res) return [];
|
||||||
const gestures: Array<{ face: number, gesture: string }> = [];
|
const gestures: Array<{ face: number, gesture: FaceGesture }> = [];
|
||||||
for (let i = 0; i < res.length; i++) {
|
for (let i = 0; i < res.length; i++) {
|
||||||
if (res[i].mesh && res[i].mesh.length > 0) {
|
if (res[i].mesh && res[i].mesh.length > 0) {
|
||||||
const eyeFacing = res[i].mesh[33][2] - res[i].mesh[263][2];
|
const eyeFacing = res[i].mesh[33][2] - res[i].mesh[263][2];
|
||||||
|
@ -47,7 +79,7 @@ export const face = (res): Gesture[] => {
|
||||||
|
|
||||||
export const iris = (res): Gesture[] => {
|
export const iris = (res): Gesture[] => {
|
||||||
if (!res) return [];
|
if (!res) return [];
|
||||||
const gestures: Array<{ iris: number, gesture: string }> = [];
|
const gestures: Array<{ iris: number, gesture: IrisGesture }> = [];
|
||||||
for (let i = 0; i < res.length; i++) {
|
for (let i = 0; i < res.length; i++) {
|
||||||
if (!res[i].annotations || !res[i].annotations.leftEyeIris || !res[i].annotations.rightEyeIris) continue;
|
if (!res[i].annotations || !res[i].annotations.leftEyeIris || !res[i].annotations.rightEyeIris) continue;
|
||||||
const sizeXLeft = res[i].annotations.leftEyeIris[3][0] - res[i].annotations.leftEyeIris[1][0];
|
const sizeXLeft = res[i].annotations.leftEyeIris[3][0] - res[i].annotations.leftEyeIris[1][0];
|
||||||
|
@ -85,7 +117,7 @@ export const iris = (res): Gesture[] => {
|
||||||
|
|
||||||
export const hand = (res): Gesture[] => {
|
export const hand = (res): Gesture[] => {
|
||||||
if (!res) return [];
|
if (!res) return [];
|
||||||
const gestures: Array<{ hand: number, gesture: string }> = [];
|
const gestures: Array<{ hand: number, gesture: HandGesture }> = [];
|
||||||
for (let i = 0; i < res.length; i++) {
|
for (let i = 0; i < res.length; i++) {
|
||||||
const fingers: Array<{ name: string, position: number }> = [];
|
const fingers: Array<{ name: string, position: number }> = [];
|
||||||
for (const [finger, pos] of Object.entries(res[i]['annotations'])) {
|
for (const [finger, pos] of Object.entries(res[i]['annotations'])) {
|
||||||
|
@ -93,8 +125,9 @@ export const hand = (res): Gesture[] => {
|
||||||
}
|
}
|
||||||
if (fingers && fingers.length > 0) {
|
if (fingers && fingers.length > 0) {
|
||||||
const closest = fingers.reduce((best, a) => (best.position[2] < a.position[2] ? best : a));
|
const closest = fingers.reduce((best, a) => (best.position[2] < a.position[2] ? best : a));
|
||||||
|
gestures.push({ hand: i, gesture: `${closest.name} forward` as HandGesture });
|
||||||
const highest = fingers.reduce((best, a) => (best.position[1] < a.position[1] ? best : a));
|
const highest = fingers.reduce((best, a) => (best.position[1] < a.position[1] ? best : a));
|
||||||
gestures.push({ hand: i, gesture: `${closest.name} forward ${highest.name} up` });
|
gestures.push({ hand: i, gesture: `${highest.name} up` as HandGesture });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return gestures;
|
return gestures;
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Tensor } from './tfjs/types';
|
import { Tensor } from './tfjs/types';
|
||||||
|
import { FaceGesture, BodyGesture, HandGesture, IrisGesture } from './gesture/gesture';
|
||||||
|
|
||||||
/** Face results
|
/** Face results
|
||||||
* Combined results of face detector, face mesh, age, gender, emotion, embedding, iris models
|
* Combined results of face detector, face mesh, age, gender, emotion, embedding, iris models
|
||||||
|
@ -132,10 +133,10 @@ export interface Item {
|
||||||
* - gesture: gesture detected
|
* - gesture: gesture detected
|
||||||
*/
|
*/
|
||||||
export type Gesture =
|
export type Gesture =
|
||||||
{ 'face': number, gesture: string }
|
{ 'face': number, gesture: FaceGesture }
|
||||||
| { 'iris': number, gesture: string }
|
| { 'iris': number, gesture: IrisGesture }
|
||||||
| { 'body': number, gesture: string }
|
| { 'body': number, gesture: BodyGesture }
|
||||||
| { 'hand': number, gesture: string }
|
| { 'hand': number, gesture: HandGesture }
|
||||||
|
|
||||||
/** Person getter
|
/** Person getter
|
||||||
* @interface Person Interface
|
* @interface Person Interface
|
||||||
|
|
|
@ -10,13 +10,7 @@ Not required for normal funcioning of library
|
||||||
- Face rotation is disabled for `NodeJS` platform:
|
- Face rotation is disabled for `NodeJS` platform:
|
||||||
`Kernel 'RotateWithOffset' not registered for backend 'tensorflow'`
|
`Kernel 'RotateWithOffset' not registered for backend 'tensorflow'`
|
||||||
<https://github.com/tensorflow/tfjs/issues/4606>
|
<https://github.com/tensorflow/tfjs/issues/4606>
|
||||||
|
Work has recently been completed and will likely be included in TFJS 3.9.0
|
||||||
### NodeJS with GPU acceleation using CUDA
|
|
||||||
|
|
||||||
- Image filters are disabled due to lack of Canvas and WeBGL access
|
|
||||||
- Face rotation is disabled for `NodeJS` platform:
|
|
||||||
`Kernel 'RotateWithOffset' not registered for backend 'tensorflow'`
|
|
||||||
<https://github.com/tensorflow/tfjs/issues/4606>
|
|
||||||
|
|
||||||
### NodeJS using WASM
|
### NodeJS using WASM
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue