-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
69 lines (51 loc) · 1.83 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
from fullbody_tracking.fullbody_tracking import FullBodyTracking
import time
import contextlib
import cv2
import numpy as np
import depthai as dai
from dai_helper.pipeline import create_pipeline
from dai_helper.depthai import get_device_parameters
from visualize_tracking import VisualizeTracking
if __name__ == "__main__":
CAMERA_ROTATION = 90;
visualize_tracking = VisualizeTracking()
visualize_tracking.initialize()
with contextlib.ExitStack() as stack:
# Check a depthAI device exists
dai_available_devices = dai.Device.getAllAvailableDevices()
if len(dai_available_devices) == 0:
raise RuntimeError("No devices found!")
else:
print("Found", len(dai_available_devices), "devices")
# Prepare a pipeline for DAI use
dai_pipeline = create_pipeline();
# Setup the device to use the Pipeline
device = None;
for available_device in dai_available_devices:
device = dai.Device(dai_pipeline, available_device)
break;
print("Connected");
# Setup device intrinsics
intrinsics, extrinsics, width, height = get_device_parameters(device);
depth_queue = device.getOutputQueue("depth", 1, blocking=False)
color_queue = device.getOutputQueue("color", 1, blocking=False)
# Setup Fullbody Tracking
tracking = FullBodyTracking(intrinsics, extrinsics, width, height, CAMERA_ROTATION);
# Start program
counter = 0;
while True:
start_time = time.time()
# Get input from the camera
color_data = color_queue.get()
depth_data = depth_queue.get()
color_frame = color_data.getFrame()
depth_frame = depth_data.getFrame()
counter += 1;
if counter > 50:
# cv2.imshow("color", color_frame)
# cv2.waitKey(1)
tracking.image(color_frame, depth_frame);
tracking_data = tracking.get_result();
visualize_tracking.run(tracking_data)
# print(tracking_data)