πŸ€– LateAI
Home β€Ί Tutorials β€Ί Finger Counter
✌️

Finger Counter

Beginner Β· 1-2 hours
πŸ“Ά Beginner ⏱ 1-2 hours πŸ’° Free (software only) 🏷 CV Zone

πŸ“Œ Overview

Count in real time how many fingers are held up in front of the camera and show the number on screen.

The approach is a classic: use the geometry between the palm and the finger joints to decide whether each finger is extended - the index, middle, ring, and little finger are judged from the relative position of the fingertip against the preceding joint, and the thumb from the horizontal distance between its tip and the base of the index finger. It is the perfect beginner exercise in hand tracking plus simple logic.

🧰 What you need

πŸ”§ Step by step

1

Detect the hand

Use HandTrackingModule to get the 21 landmark coordinates

Write down the tip and joint index for each finger

2

Judge the four fingers

Compare the y coordinate of the fingertip against the previous joint

A finger is extended when the tip is above it (smaller y)

3

Judge the thumb

Compare the x coordinate of the thumb tip against the base of the index finger

Branch on the hand orientation to decide extended or curled

4

Count and display

Total up the extended fingers

Draw the number on the frame in a large font

5

Handle the edge cases

Fine-tune the logic for a palm facing away from the camera

Test a range of gestures to confirm the count is right

6

Extend it

You can feed it into a scoring game or gesture commands

Pass the count to another program as a control signal

πŸ’‘ Tips

View original β†— ← Back to LateAI home