import * as tf from '@tensorflow/tfjs' ; import * as posenet from '@tensorflow-models/posenet' ; import { Keypoint , Pose , PoseNet } from '@tensorflow-models/posenet' ; import { DrawPose } from '@/Models/DrawPose' ; export class PoseClassifier { private model : PoseNet | null = null ; private drawPose : DrawPose | null = null ; constructor ( ) { tf . ENV . set ( 'WEBGL_PACK' , false ) ; } public async Pose ( image , canvas ) { if ( ! this . model ) { this . model = await posenet . load ( ) ; this . drawPose = new DrawPose ( canvas ) ; } if ( this . model ) { const result = await this . model . estimateSinglePose ( image ) ; if ( result ) { this . drawPose ! . Draw ( result . keypoints ) ; return result . keypoints ; } } return null ; } }