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.0.1.tar.gz (5.8 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.0.1-py3-none-any.whl (5.9 MB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for tracking_py-1.0.1.tar.gz
Algorithm Hash digest
SHA256 a1af59231f5038cf5c0e85512fa09f70adcd7ade29740b9f74098c968cbffa0c
MD5 55e8e7bb692ad6017715e801dd52fee2
BLAKE2b-256 568e5b90801ef31c0b0623fe1aacac2004b2c95ec57b7e427dec764eb69eb578

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for tracking_py-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3d42c2a346d891566b7abbc78752ce41744c767e9bb44420017e390c4a5f4888
MD5 4d6ac6ca08ca656d3f82fd251555a616
BLAKE2b-256 8f98a450b4b64b82448083405e9d4803dbcb3e319ef2e09c844f54ecfb665b54

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