Software Stack
DepthAI
  • DepthAI Components
    • AprilTags
    • Benchmark
    • Camera
    • DetectionNetwork
    • EdgeDetector
    • Events
    • FeatureTracker
    • HostNodes
    • ImageAlign
    • ImageManip
    • IMU
    • Misc
    • Modelzoo
    • NeuralNetwork
    • RecordReplay
    • RGBD
    • Script
    • SpatialDetectionNetwork
    • SpatialLocationCalculator
    • StereoDepth
    • Sync
    • SystemLogger
    • VideoEncoder
    • Visualizer
    • Warp
    • RVC2-specific
  • Advanced Tutorials
  • API Reference
  • Tools

ON THIS PAGE

  • Thermal
  • Pipeline
  • Source code

Thermal

The example streams thermal sensor data, displaying a colorized temperature image with a mouse-controlled crosshair showing real-time temperature values, and provides keyboard controls to adjust sensor settings like brightness, orientation, noise filtering, and shutter operation.This example requires the DepthAI v3 API, see installation instructions.

Pipeline

Source code

Python
C++

Python

Python
GitHub
1import depthai as dai
2import cv2
3
4THERMAL_IMAGE_BRIGHTNESS_STEP = 10
5
6with dai.Pipeline(True) as pipeline:
7    thermal = pipeline.create(dai.node.Thermal)
8    thermalImgOut = thermal.color.createOutputQueue()
9    thermalConfIn = thermal.inputConfig.createInputQueue()
10    thermalConf = dai.ThermalConfig()
11
12    pipeline.start()
13    WINDOW_NAME = "thermal"
14    cv2.namedWindow(WINDOW_NAME, cv2.WINDOW_NORMAL)
15    initialRescaleDone = False
16    while True:
17        thermalImg = thermalImgOut.get()
18        if not initialRescaleDone:
19            cv2.resizeWindow(WINDOW_NAME, thermalImg.getWidth(), thermalImg.getHeight())
20            initialRescaleDone = True
21        cv2.imshow(WINDOW_NAME, thermalImg.getCvFrame())
22        key = cv2.waitKey(1)
23        changed = False
24        if key == ord("q"):
25            break
26        elif key == ord("n"):
27            if thermalConf.imageParams.brightnessLevel is None:
28                thermalConf.imageParams.brightnessLevel = THERMAL_IMAGE_BRIGHTNESS_STEP
29            if (
30                thermalConf.imageParams.brightnessLevel - THERMAL_IMAGE_BRIGHTNESS_STEP
31            ) <= THERMAL_IMAGE_BRIGHTNESS_STEP:
32                thermalConf.imageParams.brightnessLevel = THERMAL_IMAGE_BRIGHTNESS_STEP
33            thermalConf.imageParams.brightnessLevel -= THERMAL_IMAGE_BRIGHTNESS_STEP
34            print(
35                "Set image brightness level to ",
36                thermalConf.imageParams.brightnessLevel,
37            )
38            changed = True
39        elif key == ord("m"):
40            if thermalConf.imageParams.brightnessLevel is None:
41                thermalConf.imageParams.brightnessLevel = 0
42            if (
43                thermalConf.imageParams.brightnessLevel + THERMAL_IMAGE_BRIGHTNESS_STEP
44            ) >= 255:
45                thermalConf.imageParams.brightnessLevel = (
46                    255 - THERMAL_IMAGE_BRIGHTNESS_STEP
47                )
48            thermalConf.imageParams.brightnessLevel += THERMAL_IMAGE_BRIGHTNESS_STEP
49            print(
50                "Set image brightness level to ",
51                thermalConf.imageParams.brightnessLevel,
52            )
53            changed = True
54        elif key == ord("a"):
55            if thermalConf.ffcParams.autoFFC is None:
56                thermalConf.ffcParams.autoFFC = True
57            thermalConf.ffcParams.autoFFC = not thermalConf.ffcParams.autoFFC
58            print(
59                "Set auto shutter to",
60                "on." if thermalConf.ffcParams.autoFFC else "off.",
61            )
62            changed = True
63        elif key == ord("s"):
64            if thermalConf.ffcParams.closeManualShutter is None:
65                thermalConf.ffcParams.closeManualShutter = False
66            thermalConf.ffcParams.closeManualShutter = (
67                not thermalConf.ffcParams.closeManualShutter
68            )
69            print(
70                "Closing" if thermalConf.ffcParams.closeManualShutter else "Opening",
71                "manual shutter.",
72            )
73            changed = True
74
75        if changed:
76            thermalConfIn.send(thermalConf)

Need assistance?

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