Metadata-Version: 2.1
Name: tracking-py
Version: 1.0.2
Summary: Monitor a person's body with just a webcam
Home-page: https://github.com/ilunnie/tracking
Author: ilunnie & marcoshrb
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Description-Content-Type: text/markdown
Requires-Dist: mediapipe
Requires-Dist: numpy
Requires-Dist: opencv-python
Provides-Extra: tests
Requires-Dist: pytest; extra == "tests"
Requires-Dist: pytest-cov; extra == "tests"


# Tracking

A biblioteca **Tracking** Ã© projetada para facilitar o rastreamento de caracterÃ­sticas do corpo em imagens com **Mediapipe**. Ela fornece uma estrutura organizada para manipular e acessar pontos de referÃªncia, bem como suas coordenadas em 2D e 3D.



## InstalaÃ§Ã£o

Para instalar a biblioteca, utilize o seguinte comando:

```bash
  pip install tracking
```
    
## Exemplos

Desenhando as mÃ£os de uma imagem local
```python
import cv2
from tracking.hand_tracking import Tracking # Importando apenas o mÃ³dulo de hand_tracking

# Carregando uma imagem
image = cv2.imread('path/to/image.jpg')

# Instanciando a classe de tracking
hand_tck = Tracking()

# Busca todas as mÃ£os na imagem
hands = hand_tck.predict(cv2.cvtColor(image, cv2.COLOR_RGB2BGR))
for hand in hands:
    hand.draw(image, (255, 0, 0)) # Desenha todas as mÃ£os encontradas

cv2.imshow("Hand(s)", image) # Mostrar imagem
cv2.waitKey() # Esperar o usuario clicar alguma tecla
cv2.destroyAllWindows()
```

Desenhando cada dedo separadamente e detectando quais dedos estÃ£o levantados
```python
import cv2
import tracking as tck

# 1Â° parametro: Define o tamanho da tela
# 2Â° parametro: Define a webcam que serÃ¡ usada
# 3Â° parametro: Define quais tipos de tracking deve carregar os modulos
tck.init((1920, 1080), 0, flags=tck.type.HAND_TRACKING)

# Instancia a classe de tracking de mÃ£os
hand_tck = tck.HandTracking(tck.running_mode.LIVE_STREAM,   # running_mode = LIVE_STREAM para rastrear de forma assincrona
                            max_num_hands=2)                # max_num_hands = 2 Para rastrear atÃ© duas mÃ£os ao mesmo tempo
cap = tck.CONFIG.VIDEO_CAPTURE # Referencia para a webcam

# Enquanto webcam estiver aberta
while cap.isOpened:
    # Obtem todas as mÃ£os na camera (side_mirror=True se a imagem estiver invertida)
    hands = hand_tck.predict(side_mirror=True)

    # Ultimo frame que foi capturado
    frame = cap.frame

    for hand in hands:
        for finger in tck.finger:
            # Cor azul caso o dedo estiver levantado, senÃ£o, cor vermelha
            color = (255, 0, 0) if hand.finger_is_raised(finger) else (0, 0, 255)
            # Desenha apenas o dedo atual do loop
            hand.draw(frame, color, palm=False, fingers=[finger])

    # Mostra a imagem
    cv2.imshow("WebCam", frame)
    if cv2.waitKey(10) & 0xFF == 27:    # Se apertar Esc
        cap.close()                     # Fecha a webcam

cv2.destroyAllWindows() # Fecha a janela aberta pelo programa
```


## Autores

| ilunnie | marcoshrb |
| :---: | :---: |
| [![ilunnie](https://github.com/ilunnie.png?size=115)](https://github.com/ilunnie) | [![marcoshrb](https://github.com/marcoshrb.png?size=115)](https://github.com/marcoshrb) |


## LicenÃ§a

[Apache-2.0](https://choosealicense.com/licenses/apache-2.0/)

