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

Uploaded Python 3

File details

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

File metadata

  • Download URL: tracking_py-1.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 fb5504b7674a886b221d6d86f13dc079a634f678daec59b70303cfe2111a8ced
MD5 cc73e66ee6633aaa75261b0b87f5aed4
BLAKE2b-256 00af030a281217768542b17756896cc00f82f923823655b6c337a03138fea70a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tracking_py-1.0.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9f45b2af25de94801d0fdf1c5f80d08aaa8332f627e67363890059eab658346f
MD5 5a5a4f0839545c50fb3bdcd3dcb4b8fd
BLAKE2b-256 3a171a87da4d62801d698e502b647c4a7a6a563dd7c9f9bb167f204c410ca21e

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