Skip to main content

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

Metadata

Release files for tracking-py 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tracking-py 1.1.1
File Size Uploaded
tracking_py-1.1.1.tar.gz 9.2 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for tracking-py 1.1.1
File Interpreter ABI Platform
tracking_py-1.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 18.4 MB

Release files / tracking_py-1.1.1.tar.gz

Download URL tracking_py-1.1.1.tar.gz
Size 9.2 MB
Tags Source
SHA-256 checksum
How to use checksums
30cc004e0b6a15032fcd8ea8d520ab7e618388d35633f125de1e4ea3878bd312
BLAKE2b-256 checksum
How to use checksums
9d0df37c229c76aebfe60c51f8b75f4494616161a4c9ea322e0f35a628612e5b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.19

Release files / tracking_py-1.1.1-py3-none-any.whl

Download URL tracking_py-1.1.1-py3-none-any.whl
Size 9.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
1989734af0d7f0fa8aa523a66dd1364a72a7bb1b9ad967c700e37469a30f3231
BLAKE2b-256 checksum
How to use checksums
1eb4543528acfff038e321f07582a288dad891bc594bb938989e8b646f8fa947
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.19

Release history Release notifications | RSS feed

This release

1.1.1 This release

2 release files

1.1.0

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page