Skip to content

Commit 1925079

Browse files
committed
Adressing comments and structure changes
1 parent 1c23e84 commit 1925079

File tree

8 files changed

+80
-117
lines changed

8 files changed

+80
-117
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ Afterwards, navigate to desired application as listed below
142142
</tr>
143143
</table>
144144

145-
### [🔄 Dynamic Calibration](dynamic-calibration/)
145+
### [⚙️ Dynamic Calibration](dynamic-calibration/)
146146

147147
<table>
148148
<tr>

dynamic-calibration/README.md

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ This example demonstrates **runtime stereo camera calibration** with the `Dynami
2222
## Requirements
2323

2424
- A **Luxonis device** connected via USB/Ethernet.
25-
- Python **3.10+** (tested with 3.12).
2625
- Packages:
2726
- `depthai`
2827
- `depthai-nodes`
@@ -50,41 +49,6 @@ http://localhost:8082
5049
```
5150
Replace `localhost` with your host IP if viewing from another machine.
5251

53-
## Wiring Notes (snippet)
54-
55-
Make sure to:
56-
1) Link a preview stream for timestamped overlays (e.g., colormapped disparity/depth),
57-
2) Link a raw depth OR disparity stream to the controller (for the ROI HUD),
58-
3) Provide the **device** handle to enable flashing.
59-
60-
```python
61-
visualizer = dai.RemoteConnection(httpPort=8082)
62-
device = pipeline.getDefaultDevice()
63-
64-
stereo = pipeline.create(dai.node.StereoDepth)
65-
# ... set stereo configs, link left/right, etc.
66-
67-
# Colormap for display
68-
depth_color = pipeline.create(ApplyColormap).build(stereo.disparity) # or stereo.depth
69-
depth_color.setColormap(cv2.COLORMAP_JET)
70-
71-
# Dynamic calibration node
72-
dyn_calib = pipeline.create(dai.node.DynamicCalibration)
73-
left_out.link(dyn_calib.left)
74-
right_out.link(dyn_calib.right)
75-
76-
# Controller
77-
dyn_ctrl = pipeline.create(DynamicCalibrationControler).build(
78-
preview=depth_color.out, # used for overlay timing
79-
depth=stereo.depth # or .disparity; call set_depth_units_is_mm(False) if disparity
80-
)
81-
dyn_ctrl.set_command_input(dyn_calib.inputControl.createInputQueue())
82-
dyn_ctrl.set_quality_output(dyn_calib.qualityOutput.createOutputQueue())
83-
dyn_ctrl.set_calibration_output(dyn_calib.calibrationOutput.createOutputQueue())
84-
dyn_ctrl.set_coverage_output(dyn_calib.coverageOutput.createOutputQueue())
85-
dyn_ctrl.set_device(device) # enables flashing p/k/f
86-
```
87-
8852
## Controls
8953

9054
Use these keys while the app is running (focus the browser visualizer window):

dynamic-calibration/main.py

Lines changed: 71 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,84 @@
1-
#!/usr/bin/env python3
1+
import numpy as np
2+
import cv2
23

3-
import depthai as dai
44
from depthai_nodes.node import ApplyColormap
5-
from utils.arguments import initialize_argparser
5+
import depthai as dai
6+
67
from utils.dynamic_controler import DynamicCalibrationControler
7-
import cv2
8-
import numpy as np
9-
print(dai.__file__)
8+
from utils.arguments import initialize_argparser
9+
1010
_, args = initialize_argparser()
1111

1212
visualizer = dai.RemoteConnection(httpPort=8082)
13+
device = dai.Device(dai.DeviceInfo(args.device)) if args.device else dai.Device()
1314
# ---------- Pipeline definition ----------
14-
pipeline = dai.Pipeline()
15+
with dai.Pipeline(device) as pipeline:
1516

16-
# Create camera nodes
17-
cam_left = pipeline.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_B)
18-
cam_right = pipeline.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_C)
17+
# Create camera nodes
18+
cam_left = pipeline.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_B)
19+
cam_right = pipeline.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_C)
1920

20-
# Request full resolution NV12 outputs
21-
left_out = cam_left.requestFullResolutionOutput(dai.ImgFrame.Type.NV12, fps=args.fps_limit)
22-
right_out = cam_right.requestFullResolutionOutput(dai.ImgFrame.Type.NV12, fps=args.fps_limit)
21+
# Request full resolution NV12 outputs
22+
left_out = cam_left.requestFullResolutionOutput(dai.ImgFrame.Type.NV12, fps=args.fps_limit)
23+
right_out = cam_right.requestFullResolutionOutput(dai.ImgFrame.Type.NV12, fps=args.fps_limit)
2324

24-
# Stereo node
25-
stereo = pipeline.create(dai.node.StereoDepth)
26-
left_out.link(stereo.left)
27-
right_out.link(stereo.right)
25+
# Stereo node
26+
stereo = pipeline.create(dai.node.StereoDepth)
27+
left_out.link(stereo.left)
28+
right_out.link(stereo.right)
2829

29-
# Dynamic calibration node
30-
dyn_calib = pipeline.create(dai.node.DynamicCalibration)
31-
left_out.link(dyn_calib.left)
32-
right_out.link(dyn_calib.right)
30+
# Dynamic calibration node
31+
dyn_calib = pipeline.create(dai.node.DynamicCalibration)
32+
left_out.link(dyn_calib.left)
33+
right_out.link(dyn_calib.right)
3334

34-
# Output queues
35-
depth_parser = pipeline.create(ApplyColormap).build(stereo.disparity)
35+
# Output queues
36+
depth_parser = pipeline.create(ApplyColormap).build(stereo.disparity)
3637
# depth_parser.setMaxValue(int(stereo.initialConfig.getMaxDisparity())) # NOTE: Uncomment when DAI fixes a bug
37-
depth_parser.setColormap(cv2.COLORMAP_JET)
38-
39-
device = pipeline.getDefaultDevice()
40-
41-
calibration = device.readCalibration()
42-
new_calibration = None
43-
old_calibration = None
44-
# --- existing ---
45-
calibration_output = dyn_calib.calibrationOutput.createOutputQueue()
46-
coverage_output = dyn_calib.coverageOutput.createOutputQueue()
47-
quality_output = dyn_calib.qualityOutput.createOutputQueue()
48-
input_control = dyn_calib.inputControl.createInputQueue()
49-
device.setCalibration(calibration)
50-
# ---------- Visualizer setup ----------
51-
visualizer.addTopic("Left", stereo.syncedLeft, "images")
52-
visualizer.addTopic("Right", stereo.syncedRight, "images")
53-
visualizer.addTopic("Depth", depth_parser.out, "images")
54-
55-
dyn_ctrl = pipeline.create(DynamicCalibrationControler).build(
56-
preview=depth_parser.out, # for timestamped overlays
57-
depth=stereo.depth # raw uint16 depth in mm
58-
)
59-
visualizer.addTopic("DynCalib HUD", dyn_ctrl.out_annotations, "images")
60-
61-
pipeline.start()
62-
visualizer.registerPipeline(pipeline)
63-
64-
# give it queues
65-
dyn_ctrl.set_coverage_output(coverage_output)
66-
dyn_ctrl.set_calibration_output(calibration_output)
67-
dyn_ctrl.set_command_input(input_control)
68-
dyn_ctrl.set_quality_output(quality_output)
69-
dyn_ctrl.set_depth_units_is_mm(True) # True for stereo.depth, False for disparity
70-
dyn_ctrl.set_device(device)
71-
72-
# (optional) seed current calibration
73-
try:
74-
dyn_ctrl.set_current_calibration(device.readCalibration())
75-
except Exception:
76-
pass
77-
78-
while pipeline.isRunning():
79-
key = visualizer.waitKey(1)
80-
if key != -1:
81-
dyn_ctrl.handle_key_press(key)
82-
if dyn_ctrl.wants_quit:
83-
break
38+
depth_parser.setColormap(cv2.COLORMAP_JET)
39+
40+
calibration = device.readCalibration()
41+
new_calibration = None
42+
old_calibration = None
43+
44+
# --- existing ---
45+
calibration_output = dyn_calib.calibrationOutput.createOutputQueue()
46+
coverage_output = dyn_calib.coverageOutput.createOutputQueue()
47+
quality_output = dyn_calib.qualityOutput.createOutputQueue()
48+
input_control = dyn_calib.inputControl.createInputQueue()
49+
device.setCalibration(calibration)
50+
51+
# ---------- Visualizer setup ----------
52+
visualizer.addTopic("Left", stereo.syncedLeft, "images")
53+
visualizer.addTopic("Right", stereo.syncedRight, "images")
54+
visualizer.addTopic("Depth", depth_parser.out, "images")
55+
56+
dyn_ctrl = pipeline.create(DynamicCalibrationControler).build(
57+
preview=depth_parser.out, # for timestamped overlays
58+
depth=stereo.depth # raw uint16 depth in mm
59+
)
60+
visualizer.addTopic("DynCalib HUD", dyn_ctrl.out_annotations, "images")
61+
62+
pipeline.start()
63+
visualizer.registerPipeline(pipeline)
64+
65+
# give it queues
66+
dyn_ctrl.set_coverage_output(coverage_output)
67+
dyn_ctrl.set_calibration_output(calibration_output)
68+
dyn_ctrl.set_command_input(input_control)
69+
dyn_ctrl.set_quality_output(quality_output)
70+
dyn_ctrl.set_depth_units_is_mm(True) # True for stereo.depth, False for disparity
71+
dyn_ctrl.set_device(device)
72+
73+
# (optional) Set current calibration
74+
try:
75+
dyn_ctrl.set_current_calibration(device.readCalibration())
76+
except Exception:
77+
pass
78+
79+
while pipeline.isRunning():
80+
key = visualizer.waitKey(1)
81+
if key != -1:
82+
dyn_ctrl.handle_key_press(key)
83+
if dyn_ctrl.wants_quit:
84+
break
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
--extra-index-url https://artifacts.luxonis.com/artifactory/luxonis-python-snapshot-local
2-
depthai==3.0.0rc4.dev0+61682670ac5f02e7e6cf2e306fddce998e228720
2+
depthai==3.0.0rc4.dev0+e544ed203aa7f62a20922d7b0fd7c0a49645e952
33
depthai-nodes==0.3.1
44
numpy>=1.22
5-
open3d~=0.18
65
opencv-python==4.10.0.84
76
opencv-contrib-python==4.10.0.84

dynamic-calibration/utils/arguments.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def initialize_argparser():
66
parser = argparse.ArgumentParser(
77
formatter_class=argparse.ArgumentDefaultsHelpFormatter
88
)
9-
parser.description = "This example showcases one possible approach for measuring the size of a box using DepthAI."
9+
parser.description = "This example showcases the capabinility of Dynamic Calibration on OAK devices. "
1010

1111
parser.add_argument(
1212
"-d",

dynamic-calibration/utils/dynamic_calibration_interactive.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
#!/usr/bin/env python3
1+
import numpy as np
2+
import cv2
23

34
import depthai as dai
4-
import cv2
5-
import numpy as np
6-
from helper_functions import *
5+
from helper_functions import update_master_frame, overlay_coverage_on_gray, draw_recalibration_message, draw_health_bar, display_text, draw_key_commands, print_final_calibration_results
6+
77

88
mouse_coords = (-1, -1)
99
def on_mouse_disparity(event, x, y, flags, param):

dynamic-calibration/utils/dynamic_controler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from typing import Optional, Tuple
22
import numpy as np
3+
import time
4+
35
import depthai as dai
4-
import time # at top of file
56

6-
print(dai.__version__)
77
class DynamicCalibrationControler(dai.node.HostNode):
88
def __init__(self):
99
super().__init__()

dynamic-calibration/utils/helper_functions.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import time
21
import cv2
32
import numpy as np
43

0 commit comments

Comments
 (0)