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 |
|---|---|
Licença
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tracking_py-1.0.0.tar.gz.
File metadata
- Download URL: tracking_py-1.0.0.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7701d5c27026007fa6d7069c66f61d763fd92fe7eb15a43b85e5b42bf72c8ae4
|
|
| MD5 |
839c6f31f757ec3b7518e68581defb5e
|
|
| BLAKE2b-256 |
5206e50442de2805f634fdd9fa83a37d21e8b1c901c78fbc7822474c13c8f0be
|
File details
Details for the file tracking_py-1.0.0-py3-none-any.whl.
File metadata
- Download URL: tracking_py-1.0.0-py3-none-any.whl
- Upload date:
- Size: 13.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9658009931f7ad59729234f6540c911db443f699be6eff557d33879672a59d7b
|
|
| MD5 |
c7ef03d18071615ea5dba5d20d78b71d
|
|
| BLAKE2b-256 |
1269f7b1e937aa1fdcb92af2fc35f9cd0273ac3aa318add879ffe719f3f4bc80
|