render/sensor_pipeline_runner.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // SPDX-License-Identifier: BSD-3-Clause | ||
| 2 | #pragma once | ||
| 3 | |||
| 4 | #include <cstdint> | ||
| 5 | #include <map> | ||
| 6 | #include <memory> | ||
| 7 | #include <optional> | ||
| 8 | #include <string> | ||
| 9 | #include <string_view> | ||
| 10 | #include <vector> | ||
| 11 | |||
| 12 | #include "chrono_batch_render/device/device.h" | ||
| 13 | #include "chrono_batch_render/device/tensor.h" | ||
| 14 | #include "chrono_batch_render/export.h" | ||
| 15 | #include "chrono_batch_render/scene/scene.h" | ||
| 16 | |||
| 17 | namespace chrono::batch_render { | ||
| 18 | |||
| 19 | namespace sensor_pipeline { | ||
| 20 | struct SensorPipelineDesc; | ||
| 21 | class NodeRegistry; | ||
| 22 | } | ||
| 23 | |||
| 24 | 130 | struct SensorPipelineNodePort { | |
| 25 | std::string name; | ||
| 26 | std::string type; | ||
| 27 | bool optional = false; | ||
| 28 | }; | ||
| 29 | |||
| 30 | struct SensorPipelineNodeInfo { | ||
| 31 | std::string id; | ||
| 32 | std::string kind; | ||
| 33 | std::vector<SensorPipelineNodePort> inputs; | ||
| 34 | std::vector<SensorPipelineNodePort> outputs; | ||
| 35 | }; | ||
| 36 | |||
| 37 | CHRONO_BATCH_RENDER_API std::optional<SensorPipelineNodeInfo> | ||
| 38 | FindSensorPipelineNode(std::string_view id); | ||
| 39 | |||
| 40 | struct DetectorDesc { | ||
| 41 | DetectorPattern pattern = DetectorPattern::Rgb; | ||
| 42 | float fullWell = 10000; | ||
| 43 | float readNoise = 2; | ||
| 44 | float darkCurrent = 1; | ||
| 45 | float darkCurrentDoubling = 7; | ||
| 46 | float temperature = 293.15f; | ||
| 47 | float prnu = 0.005f; | ||
| 48 | float dsnu = 0.5f; | ||
| 49 | float systemGain = 0.25f; | ||
| 50 | uint32_t bitDepth = 12; | ||
| 51 | float blackLevel = 0; | ||
| 52 | uint32_t seed = 0; | ||
| 53 | }; | ||
| 54 | |||
| 55 | 23 | struct SensorPipelineRunDesc { | |
| 56 | std::map<std::string, device::Tensor, std::less<>> inputs; | ||
| 57 | DetectorDesc detector; | ||
| 58 | float exposureTime = 1; | ||
| 59 | float iso = 100; | ||
| 60 | uint32_t capture = 0; | ||
| 61 | uint32_t identity = 0; | ||
| 62 | }; | ||
| 63 | |||
| 64 | using SensorPipelineOutputs = std::map<std::string, device::Tensor, std::less<>>; | ||
| 65 | |||
| 66 | class CHRONO_BATCH_RENDER_API SensorPipelineRunner { | ||
| 67 | public: | ||
| 68 | SensorPipelineRunner(const Ref<Scene>& scene, std::string_view path); | ||
| 69 | SensorPipelineRunner(device::Device& device, const sensor_pipeline::SensorPipelineDesc& desc); | ||
| 70 | SensorPipelineRunner(device::Device& device, const sensor_pipeline::SensorPipelineDesc& desc, | ||
| 71 | const sensor_pipeline::NodeRegistry& registry); | ||
| 72 | ~SensorPipelineRunner(); | ||
| 73 | SensorPipelineRunner(SensorPipelineRunner&&) noexcept; | ||
| 74 | SensorPipelineRunner& operator=(SensorPipelineRunner&&) noexcept; | ||
| 75 | |||
| 76 | SensorPipelineOutputs Run(const SensorPipelineRunDesc& desc) const; | ||
| 77 | |||
| 78 | device::Device& GetDevice() const; | ||
| 79 | std::vector<std::string> Sources() const; | ||
| 80 | std::vector<std::string> Outputs() const; | ||
| 81 | |||
| 82 | private: | ||
| 83 | friend class SensorPipelineSession; | ||
| 84 | struct State; | ||
| 85 | |||
| 86 | SensorPipelineOutputs Run(const SensorPipelineRunDesc& desc, device::Tensor& state) const; | ||
| 87 | |||
| 88 | std::unique_ptr<State> m_state; | ||
| 89 | }; | ||
| 90 | |||
| 91 | 5 | class CHRONO_BATCH_RENDER_API SensorPipelineSession { | |
| 92 | public: | ||
| 93 | 3 | explicit SensorPipelineSession(const SensorPipelineRunner& pipeline) : m_pipeline(pipeline) {} | |
| 94 | |||
| 95 | SensorPipelineOutputs Run(SensorPipelineRunDesc desc); | ||
| 96 | |||
| 97 | 2 | uint32_t Captures() const { | |
| 98 | 2 | return m_captures; | |
| 99 | } | ||
| 100 | |||
| 101 | 2 | const SensorPipelineRunner& GetRunner() const { | |
| 102 | 2 | return m_pipeline; | |
| 103 | } | ||
| 104 | |||
| 105 | private: | ||
| 106 | const SensorPipelineRunner& m_pipeline; | ||
| 107 | uint32_t m_captures = 0; | ||
| 108 | device::Tensor m_state; | ||
| 109 | }; | ||
| 110 | |||
| 111 | } | ||
| 112 |