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.1.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.1-py3-none-any.whl (9.2 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tracking_py-1.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 30cc004e0b6a15032fcd8ea8d520ab7e618388d35633f125de1e4ea3878bd312
MD5 30b1ea47b8dcd8f8f601b02b698dfc1a
BLAKE2b-256 9d0df37c229c76aebfe60c51f8b75f4494616161a4c9ea322e0f35a628612e5b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tracking_py-1.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1989734af0d7f0fa8aa523a66dd1364a72a7bb1b9ad967c700e37469a30f3231
MD5 ca19d5ee204b9451ca032219350b1669
BLAKE2b-256 1eb4543528acfff038e321f07582a288dad891bc594bb938989e8b646f8fa947

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