Software Stack
DepthAI

ON THIS PAGE

  • IR Projectors Control
  • Demo
  • Supported devices
  • Pipeline
  • Source code

IR Projectors Control

Displays left/right mono streams and lets you change IR dot‑projector and flood‑light intensities on the device at runtime. Controls: W/S for dot intensity, A/D for flood intensity, Q to quit.

Demo

This example requires the DepthAI v3 API, see installation instructions.

Supported devices

  • OAK 4 D Pro
  • OAK-D Pro W PoE
  • OAK-D Pro W
  • OAK-D Pro PoE
  • OAK-D Pro

Pipeline

Source code

Python
C++

Python

Python
GitHub
1#!/usr/bin/env python3
2
3import cv2
4import depthai as dai
5
6dot_intensity = 1
7DOT_STEP = 0.1
8
9flood_intensity = 1
10FLOOD_STEP = 0.1
11
12# Create pipeline
13device = dai.Device()
14with dai.Pipeline(device) as pipeline:
15    monoLeft = pipeline.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_B)
16    monoRight = pipeline.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_C)
17
18    # Linking
19    monoLeftOut = monoLeft.requestFullResolutionOutput(type=dai.ImgFrame.Type.NV12)
20    monoRightOut = monoRight.requestFullResolutionOutput(type=dai.ImgFrame.Type.NV12)
21
22    leftQueue = monoLeftOut.createOutputQueue()
23    rightQueue = monoRightOut.createOutputQueue()
24
25    pipeline.start()
26    pipeline.getDefaultDevice().setIrLaserDotProjectorIntensity(dot_intensity)
27    pipeline.getDefaultDevice().setIrFloodLightIntensity(flood_intensity)
28    while pipeline.isRunning():
29        leftSynced = leftQueue.get()
30        rightSynced = rightQueue.get()
31        assert isinstance(leftSynced, dai.ImgFrame)
32        assert isinstance(rightSynced, dai.ImgFrame)
33        cv2.imshow(f"left", leftSynced.getCvFrame())
34        cv2.imshow(f"right", rightSynced.getCvFrame())
35
36        key = cv2.waitKey(1)
37        if key == ord('q'):
38            pipeline.stop()
39            break
40        elif key == ord("w"):
41            dot_intensity += DOT_STEP
42            if dot_intensity > 1:
43                dot_intensity = 1
44            pipeline.getDefaultDevice().setIrLaserDotProjectorIntensity(dot_intensity)
45            print(f"Dot intensity: {dot_intensity}")
46        elif key == ord("s"):
47            dot_intensity -= DOT_STEP
48            if dot_intensity < 0:
49                dot_intensity = 0
50            pipeline.getDefaultDevice().setIrLaserDotProjectorIntensity(dot_intensity)
51            print(f"Dot intensity: {dot_intensity}")
52        elif key == ord("a"):
53            flood_intensity += FLOOD_STEP
54            if flood_intensity > 1:
55                flood_intensity = 1
56            pipeline.getDefaultDevice().setIrFloodLightIntensity(flood_intensity)
57            print(f"Flood intensity: {flood_intensity}")
58        elif key == ord("d"):
59            flood_intensity -= FLOOD_STEP
60            if flood_intensity < 0:
61                flood_intensity = 0
62            pipeline.getDefaultDevice().setIrFloodLightIntensity(flood_intensity)
63            print(f"Flood intensity: {flood_intensity}")

Need assistance?

Head over to Discussion Forum for technical support or any other questions you might have.