# ToF All Queues

This example shows all of the main ToF output queues at once, displaying `depth`, `amplitude`, and `intensity` on both platforms,
plus the platform-specific `rawDepth` (RVC2) or `confidence` (RVC4) output. The detected platform is printed at startup.For the
full output/architecture reference, see the [ToF node
docs](https://docs.luxonis.com/software-v3/depthai/depthai-components/nodes/tof.md).

This example requires the DepthAI v3 API, see [installation instructions](https://docs.luxonis.com/software-v3/depthai.md).

## Source code

#### Python

```python
#!/usr/bin/env python3
"""Simple ToF script showing all main ToF output queues.

RVC2 displays: depth, amplitude, intensity, rawDepth.
RVC4 displays: depth, amplitude, intensity, confidence.

Press 'q' to quit.
"""

import cv2
import depthai as dai

FPS = 30.0

def normalizeFrame(frame):
    return cv2.normalize(frame, None, 0, 255, cv2.NORM_MINMAX, cv2.CV_8U)

def main():
    pipeline = dai.Pipeline()

    minDepth = 100.0
    maxDepth = 7000.0

    profile = dai.ToFConfig.Profile.MID_RANGE

    tof = pipeline.create(dai.node.ToF).build(
        boardSocket=dai.CameraBoardSocket.AUTO,
        profile=profile,
        fps=FPS,
    )

    with pipeline as p:
        device = p.getDefaultDevice()
        isRVC2 = device.getPlatform() == dai.Platform.RVC2

        outputQueues = {
            "depth": tof.depth.createOutputQueue(maxSize=1, blocking=False),
            "amplitude": tof.amplitude.createOutputQueue(maxSize=1, blocking=False),
            "intensity": tof.intensity.createOutputQueue(maxSize=1, blocking=False),
        }
        if isRVC2:
            outputQueues["rawDepth"] = tof.rawDepth.createOutputQueue(maxSize=1, blocking=False)
        else:
            outputQueues["confidence"] = tof.confidence.createOutputQueue(maxSize=1, blocking=False)

        platformName = "RVC2" if isRVC2 else "RVC4"
        print(f"Detected {platformName} - showing queues: {', '.join(outputQueues)}")

        p.start()
        while p.isRunning():
            for name, queue in outputQueues.items():
                frame = queue.tryGet()
                if frame is None:
                    continue

                if name in {"depth", "rawDepth"}:
                    display = dai.utility.colorizeDepthFrame(frame, minDepth, maxDepth, useLog=True).getCvFrame()
                else:
                    display = normalizeFrame(frame.getCvFrame())
                cv2.imshow(name, display)

            if cv2.waitKey(1) == ord("q"):
                break

if __name__ == "__main__":
    main()
```

#### C++

```cpp
#include <iostream>
#include <map>
#include <opencv2/opencv.hpp>
#include <string>

#include "depthai/depthai.hpp"

constexpr float FPS = 30.0f;
cv::Mat normalizeFrame(const cv::Mat& frame) {
    cv::Mat normalized;
    cv::normalize(frame, normalized, 0, 255, cv::NORM_MINMAX, CV_8U);
    return normalized;
}

int main() {
    dai::Pipeline pipeline;

    constexpr float minDepth = 100.0f;
    constexpr float maxDepth = 7000.0f;

    auto profile = dai::ToFConfig::Profile::MID_RANGE;

    auto tof = pipeline.create<dai::node::ToF>()->build(dai::CameraBoardSocket::AUTO, profile, FPS);

    bool isRVC2 = pipeline.getDefaultDevice()->getPlatform() == dai::Platform::RVC2;

    std::map<std::string, std::shared_ptr<dai::MessageQueue>> outputQueues = {
        {"depth", tof->depth.createOutputQueue(1, false)},
        {"amplitude", tof->amplitude.createOutputQueue(1, false)},
        {"intensity", tof->intensity.createOutputQueue(1, false)},
    };
    if(isRVC2) {
        outputQueues["rawDepth"] = tof->rawDepth.createOutputQueue(1, false);
    } else {
        outputQueues["confidence"] = tof->confidence.createOutputQueue(1, false);
    }

    std::cout << "Detected " << (isRVC2 ? "RVC2" : "RVC4") << std::endl;

    pipeline.start();
    while(pipeline.isRunning()) {
        for(const auto& [name, queue] : outputQueues) {
            auto frame = queue->tryGet<dai::ImgFrame>();
            if(frame == nullptr) {
                continue;
            }

            cv::Mat displayFrame;

            if(name == "depth" || name == "rawDepth") {
                displayFrame = dai::utility::colorizeDepthFrame(*frame, minDepth, maxDepth, cv::COLORMAP_JET, true).getCvFrame();
            } else {
                displayFrame = normalizeFrame(frame->getCvFrame());
            }

            cv::imshow(name, displayFrame);
        }

        if(cv::waitKey(1) == 'q') {
            break;
        }
    }

    return 0;
}
```

### Need assistance?

Head over to [Discussion Forum](https://discuss.luxonis.com/) for technical support or any other questions you might have.
