Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update code blocks to improve readability #27

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ A simple [Rock, Scissors, Paper game](https://github.com/andypotato/rock-paper-s
## Quick start

### Include MediaPipe Handpose and its prerequisites (TFJS >= 2.1.0)
```
```html
<!-- this example uses TFJS 3.7.0 - older versions back to 2.1.0 are supported -->
<script src="https://unpkg.com/@tensorflow/[email protected]/dist/tf-core.js"></script>

Expand All @@ -54,18 +54,18 @@ A simple [Rock, Scissors, Paper game](https://github.com/andypotato/rock-paper-s
```

### Include this library
```
```html
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/fingerpose.min.js" type="text/javascript"></script>
```
#### Alternatives
You can copy the whole file from [fingerpose.js](./dist/fingerpose.js) or install from NPM with

```
```console
npm install fingerpose
```

### Add the gestures you want do detect
```
```javascript
// add "✌🏻" and "👍" as sample gestures
const GE = new fp.GestureEstimator([
fp.Gestures.VictoryGesture,
Expand All @@ -74,18 +74,18 @@ const GE = new fp.GestureEstimator([
```

### Use Handpose to estimate the landmarks
```
```javascript
const model = await handpose.load();
const predictions = await model.estimateHands(video, true);
```

### Estimate the gestures
```
```javascript
// using a minimum match score of 8.5 (out of 10)
const estimatedGestures = GE.estimate(predictions.landmarks, 8.5);
```
The result is an object containing possible gestures and their match score, for example:
```
```javascript
{
poseData: [ ... ],
gestures: [
Expand All @@ -97,7 +97,7 @@ The result is an object containing possible gestures and their match score, for

In addition, you receive the `poseData` array including the raw curl and direction information for each finger. This is useful for debugging purposes as it can help you understand how an individual finger is "seen" by the library.

```
```javascript
// example for raw pose data
poseData: [
['Thumb', 'No Curl', 'Vertical Up],
Expand Down Expand Up @@ -148,22 +148,22 @@ You can refer to the images below for an example of how the index finger is curl

#### Example: Thumbs down gesture description 👎
First, create a new GestureDescription object:
```
```javascript
const thumbsDownGesture = new fp.GestureDescription('thumbs_down');
```
Expect the thumb to be stretched out and pointing down:
```
```javascript
thumbsDownGesture.addCurl(fp.Finger.Thumb, fp.FingerCurl.NoCurl);
thumbsDownGesture.addDirection(fp.Finger.Thumb, fp.FingerDirection.VerticalDown, 1.0);
```
This will define that a thumb pointing downwards will result in the highest score (1.0) for this gesture. If the thumb is angled diagonally down left / right we can somehow still accept it, albeit with a lower score (0.9).
```
```javascript
thumbsDownGesture.addDirection(fp.Finger.Thumb, fp.FingerDirection.DiagonalDownLeft, 0.9);
thumbsDownGesture.addDirection(fp.Finger.Thumb, fp.FingerDirection.DiagonalDownRight, 0.9);
```

All other fingers are expected to be fully curled. For this gesture, it doesn't matter which direction the curled fingers are pointing at therefore only the curl description is added. Same as above, it's recommended to accept half-curled fingers too, with a little bit lower score.
```
```javascript
// do this for all other fingers
for(let finger of [fp.Finger.Index, fp.Finger.Middle, fp.Finger.Ring, fp.Finger.Pinky]) {
thumbsUpDescription.addCurl(finger, FingerCurl.FullCurl, 1.0);
Expand Down