Skip to main content

Monitor a person's body with just a webcam

Project description

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:

  pip install tracking

Exemplos

Desenhando as mãos de uma imagem local

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

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 marcoshrb

Licença

Apache-2.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tracking_py-1.1.0.tar.gz (9.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tracking_py-1.1.0-py3-none-any.whl (9.2 MB view details)

Uploaded Python 3

File details

Details for the file tracking_py-1.1.0.tar.gz.

File metadata

  • Download URL: tracking_py-1.1.0.tar.gz
  • Upload date:
  • Size: 9.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.19

File hashes

Hashes for tracking_py-1.1.0.tar.gz
Algorithm Hash digest
SHA256 bf3196699e250148486b032b34f1e3616c836139fc39d454bcb13a91dd32fcc8
MD5 c6df141f32d28b8fd8cdd9b88ebadadf
BLAKE2b-256 6e93bcf2e6d3aadf1dbfffbba91410dbb854386a48c5c9ba32d1eb44c19e40fc

See more details on using hashes here.

File details

Details for the file tracking_py-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: tracking_py-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.2 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.19

File hashes

Hashes for tracking_py-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5c750ca2d55852f2e4b06bf67976700bb2f415056c87c780d4deeaf1d23888b5
MD5 0d6245e63caa9bbbe67bf6a1f59fed17
BLAKE2b-256 436c0d9244fea1004264041c23799c6378176ef0846a5b2b337583d1337e61b4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page