2026-05-21 22:57:35 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
# -*- coding: utf-8 -*-
|
2026-05-05 13:15:09 +00:00
|
|
|
|
2026-05-21 22:57:35 +00:00
|
|
|
import depthai as dai
|
2026-05-05 13:15:09 +00:00
|
|
|
|
|
|
|
|
|
2026-05-21 22:57:35 +00:00
|
|
|
def ler_attr_ou_metodo(obj, nomes, default=None):
|
|
|
|
|
for nome in nomes:
|
|
|
|
|
try:
|
|
|
|
|
valor = getattr(obj, nome, None)
|
2026-05-05 13:15:09 +00:00
|
|
|
|
2026-05-21 22:57:35 +00:00
|
|
|
if valor is None:
|
|
|
|
|
continue
|
2026-05-05 13:15:09 +00:00
|
|
|
|
2026-05-21 22:57:35 +00:00
|
|
|
if callable(valor):
|
|
|
|
|
return valor()
|
2026-05-05 13:15:09 +00:00
|
|
|
|
2026-05-21 22:57:35 +00:00
|
|
|
return valor
|
|
|
|
|
except Exception:
|
|
|
|
|
pass
|
2026-05-05 13:15:09 +00:00
|
|
|
|
2026-05-21 22:57:35 +00:00
|
|
|
return default
|
2026-05-05 13:15:09 +00:00
|
|
|
|
|
|
|
|
|
2026-05-21 22:57:35 +00:00
|
|
|
def main():
|
|
|
|
|
print("==========================================")
|
|
|
|
|
print("Teste simples - listar dispositivos DepthAI")
|
|
|
|
|
print("==========================================")
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
devices = dai.Device.getAllAvailableDevices()
|
|
|
|
|
except Exception as e:
|
|
|
|
|
print("[ERRO] Falha ao chamar dai.Device.getAllAvailableDevices()")
|
|
|
|
|
print("Erro:", e)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
if not devices:
|
|
|
|
|
print("[INFO] Nenhum dispositivo DepthAI/OAK encontrado.")
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
print(f"[OK] Dispositivos encontrados: {len(devices)}")
|
|
|
|
|
print()
|
|
|
|
|
|
|
|
|
|
for i, dev_info in enumerate(devices, start=1):
|
|
|
|
|
device_id = ler_attr_ou_metodo(
|
|
|
|
|
dev_info,
|
|
|
|
|
["getMxId", "mxid", "getDeviceId", "deviceId"],
|
|
|
|
|
default=None
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
name = ler_attr_ou_metodo(dev_info, ["name"], default=None)
|
|
|
|
|
state = ler_attr_ou_metodo(dev_info, ["state"], default=None)
|
|
|
|
|
protocol = ler_attr_ou_metodo(dev_info, ["protocol"], default=None)
|
|
|
|
|
platform = ler_attr_ou_metodo(dev_info, ["platform"], default=None)
|
|
|
|
|
status = ler_attr_ou_metodo(dev_info, ["status"], default=None)
|
|
|
|
|
|
|
|
|
|
print(f"Dispositivo #{i}")
|
|
|
|
|
print(f" DeviceId : {device_id}")
|
|
|
|
|
print(f" Name : {name}")
|
|
|
|
|
print(f" State : {state}")
|
|
|
|
|
print(f" Protocol : {protocol}")
|
|
|
|
|
print(f" Platform : {platform}")
|
|
|
|
|
print(f" Status : {status}")
|
|
|
|
|
print("-" * 42)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
main()
|