or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

advanced-apis.mdindex.mdkeypoints.mdmodel-loading.mdmulti-pose.mdpose-utilities.mdsingle-pose.md

single-pose.mddocs/

0

# Single Person Pose Estimation

1

2

Fast pose detection algorithm optimized for single person scenarios. Ideal when only one person is expected in the image.

3

4

## Capabilities

5

6

### Estimate Single Pose

7

8

Detects and estimates a single pose from input image using the fastest decoding algorithm.

9

10

```typescript { .api }

11

/**

12

* Estimate single person pose from input image

13

* @param input - Input image (various formats supported)

14

* @param config - Configuration options for inference

15

* @returns Promise resolving to single detected pose

16

*/

17

estimateSinglePose(

18

input: PosenetInput,

19

config?: SinglePersonInterfaceConfig

20

): Promise<Pose>;

21

```

22

23

**Usage Examples:**

24

25

```typescript

26

import * as posenet from '@tensorflow-models/posenet';

27

28

// Load model

29

const net = await posenet.load();

30

31

// Basic single pose estimation

32

const imageElement = document.getElementById('person-image') as HTMLImageElement;

33

const pose = await net.estimateSinglePose(imageElement);

34

35

console.log('Overall pose confidence:', pose.score);

36

console.log('Number of keypoints detected:', pose.keypoints.length);

37

38

// With horizontal flipping (for webcam feeds)

39

const webcamPose = await net.estimateSinglePose(videoElement, {

40

flipHorizontal: true

41

});

42

43

// Process high-confidence keypoints

44

const highConfidenceKeypoints = pose.keypoints.filter(kp => kp.score > 0.7);

45

highConfidenceKeypoints.forEach(keypoint => {

46

console.log(`${keypoint.part}: (${keypoint.position.x}, ${keypoint.position.y}) confidence: ${keypoint.score}`);

47

});

48

49

// Access specific body parts

50

const nose = pose.keypoints.find(kp => kp.part === 'nose');

51

const leftWrist = pose.keypoints.find(kp => kp.part === 'leftWrist');

52

if (nose && leftWrist) {

53

const distance = Math.sqrt(

54

Math.pow(nose.position.x - leftWrist.position.x, 2) +

55

Math.pow(nose.position.y - leftWrist.position.y, 2)

56

);

57

console.log('Distance from nose to left wrist:', distance);

58

}

59

```

60

61

### Single Person Configuration

62

63

Configuration options for single person pose estimation.

64

65

```typescript { .api }

66

/**

67

* Configuration interface for single person pose estimation

68

*/

69

interface SinglePersonInterfaceConfig {

70

/** Whether to flip poses horizontally (useful for webcam feeds) */

71

flipHorizontal: boolean;

72

}

73

```

74

75

### Default Configuration

76

77

```typescript { .api }

78

const SINGLE_PERSON_INFERENCE_CONFIG: SinglePersonInterfaceConfig = {

79

flipHorizontal: false

80

};

81

```

82

83

### Input Types

84

85

Single pose estimation supports multiple input formats:

86

87

```typescript { .api }

88

type PosenetInput =

89

| ImageData // Canvas ImageData object

90

| HTMLImageElement // HTML img element

91

| HTMLCanvasElement // HTML canvas element

92

| HTMLVideoElement // HTML video element

93

| tf.Tensor3D; // TensorFlow.js 3D tensor

94

```

95

96

**Input Examples:**

97

98

```typescript

99

// HTML Image Element

100

const img = document.getElementById('photo') as HTMLImageElement;

101

const pose1 = await net.estimateSinglePose(img);

102

103

// HTML Video Element (for real-time processing)

104

const video = document.getElementById('webcam') as HTMLVideoElement;

105

const pose2 = await net.estimateSinglePose(video, { flipHorizontal: true });

106

107

// HTML Canvas Element

108

const canvas = document.getElementById('drawing') as HTMLCanvasElement;

109

const pose3 = await net.estimateSinglePose(canvas);

110

111

// ImageData from canvas

112

const ctx = canvas.getContext('2d')!;

113

const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);

114

const pose4 = await net.estimateSinglePose(imageData);

115

```

116

117

### Return Value

118

119

Single pose estimation returns a Promise that resolves to a Pose object:

120

121

```typescript { .api }

122

/**

123

* Detected pose with keypoints and confidence score

124

*/

125

interface Pose {

126

/** Array of 17 keypoints representing body parts */

127

keypoints: Keypoint[];

128

/** Overall pose confidence score (0-1) */

129

score: number;

130

}

131

132

/**

133

* Individual body part keypoint with position and confidence

134

*/

135

interface Keypoint {

136

/** Confidence score for this keypoint (0-1) */

137

score: number;

138

/** 2D position in image coordinates */

139

position: Vector2D;

140

/** Body part name (e.g., 'nose', 'leftWrist') */

141

part: string;

142

}

143

144

interface Vector2D {

145

x: number;

146

y: number;

147

}

148

```

149

150

### Body Parts Detected

151

152

Single pose estimation detects 17 standard keypoints:

153

154

| ID | Part Name | Description |

155

|----|-----------|-------------|

156

| 0 | nose | Nose tip |

157

| 1 | leftEye | Left eye center |

158

| 2 | rightEye | Right eye center |

159

| 3 | leftEar | Left ear |

160

| 4 | rightEar | Right ear |

161

| 5 | leftShoulder | Left shoulder |

162

| 6 | rightShoulder | Right shoulder |

163

| 7 | leftElbow | Left elbow |

164

| 8 | rightElbow | Right elbow |

165

| 9 | leftWrist | Left wrist |

166

| 10 | rightWrist | Right wrist |

167

| 11 | leftHip | Left hip |

168

| 12 | rightHip | Right hip |

169

| 13 | leftKnee | Left knee |

170

| 14 | rightKnee | Right knee |

171

| 15 | leftAnkle | Left ankle |

172

| 16 | rightAnkle | Right ankle |

173

174

### Algorithm Details

175

176

The single pose estimation algorithm:

177

178

1. **Input Processing**: Resizes and normalizes input image

179

2. **Neural Network Inference**: Processes image through selected architecture (MobileNetV1/ResNet50)

180

3. **Heatmap Analysis**: Finds maximum confidence locations for each body part

181

4. **Offset Application**: Applies offset vectors to refine keypoint positions

182

5. **Coordinate Transformation**: Scales positions back to original image coordinates

183

184

### Performance Characteristics

185

186

- **Speed**: Fastest pose estimation algorithm in PoseNet

187

- **Accuracy**: Good for single person scenarios

188

- **Limitations**: May conflate keypoints when multiple people are present

189

- **Memory**: Lower memory usage compared to multi-person estimation

190

- **Real-time**: Suitable for real-time applications on moderate hardware