├── .gitignore ├── 3rdparty ├── invoke_hpp │ └── invoke.hpp ├── linb │ └── any.hpp ├── nanorpc │ ├── core │ │ ├── client.h │ │ ├── detail │ │ │ ├── config.h │ │ │ ├── function_meta.h │ │ │ └── pack_meta.h │ │ ├── exception.h │ │ ├── hash.h │ │ ├── server.h │ │ └── type.h │ ├── packer │ │ ├── cereal_binary.h │ │ ├── nlohmann_json.h │ │ └── nlohmann_msgpack.h │ └── version │ │ └── core.h └── tl │ └── optional.hpp ├── LICENSE ├── README.md ├── include └── depthai-shared │ ├── common │ ├── CameraBoardSocket.hpp │ ├── CameraFeatures.hpp │ ├── CameraImageOrientation.hpp │ ├── CameraInfo.hpp │ ├── CameraModel.hpp │ ├── CameraSensorType.hpp │ ├── ChipTemperature.hpp │ ├── Colormap.hpp │ ├── ConnectionInterface.hpp │ ├── CpuUsage.hpp │ ├── DetectionNetworkType.hpp │ ├── DetectionParserOptions.hpp │ ├── EepromData.hpp │ ├── Extrinsics.hpp │ ├── FrameEvent.hpp │ ├── Interpolation.hpp │ ├── MedianFilter.hpp │ ├── MemoryInfo.hpp │ ├── Point2f.hpp │ ├── Point3f.hpp │ ├── ProcessorType.hpp │ ├── Rect.hpp │ ├── RotatedRect.hpp │ ├── Size2f.hpp │ ├── StereoPair.hpp │ ├── StereoRectification.hpp │ ├── TensorInfo.hpp │ ├── Timestamp.hpp │ ├── UsbSpeed.hpp │ └── optional.hpp │ ├── datatype │ ├── DatatypeEnum.hpp │ ├── RawAprilTagConfig.hpp │ ├── RawAprilTags.hpp │ ├── RawBuffer.hpp │ ├── RawCameraControl.hpp │ ├── RawEdgeDetectorConfig.hpp │ ├── RawEncodedFrame.hpp │ ├── RawFeatureTrackerConfig.hpp │ ├── RawIMUData.hpp │ ├── RawImageAlignConfig.hpp │ ├── RawImageManipConfig.hpp │ ├── RawImgDetections.hpp │ ├── RawImgFrame.hpp │ ├── RawMessageGroup.hpp │ ├── RawNNData.hpp │ ├── RawPointCloudConfig.hpp │ ├── RawPointCloudData.hpp │ ├── RawSpatialImgDetections.hpp │ ├── RawSpatialLocationCalculatorConfig.hpp │ ├── RawSpatialLocations.hpp │ ├── RawStereoDepthConfig.hpp │ ├── RawSystemInformation.hpp │ ├── RawToFConfig.hpp │ ├── RawTrackedFeatures.hpp │ └── RawTracklets.hpp │ ├── device │ ├── BoardConfig.hpp │ └── CrashDump.hpp │ ├── log │ ├── LogConstants.hpp │ ├── LogLevel.hpp │ └── LogMessage.hpp │ ├── pipeline │ ├── Assets.hpp │ ├── NodeConnectionSchema.hpp │ ├── NodeIoInfo.hpp │ ├── NodeObjInfo.hpp │ ├── PipelineSchema.hpp │ └── TraceEvent.hpp │ ├── properties │ ├── AprilTagProperties.hpp │ ├── CameraProperties.hpp │ ├── CastProperties.hpp │ ├── ColorCameraProperties.hpp │ ├── DetectionNetworkProperties.hpp │ ├── DetectionParserProperties.hpp │ ├── EdgeDetectorProperties.hpp │ ├── FeatureTrackerProperties.hpp │ ├── GlobalProperties.hpp │ ├── IMUProperties.hpp │ ├── ImageAlignProperties.hpp │ ├── ImageManipProperties.hpp │ ├── MessageDemuxProperties.hpp │ ├── MonoCameraProperties.hpp │ ├── NeuralNetworkProperties.hpp │ ├── ObjectTrackerProperties.hpp │ ├── PointCloudProperties.hpp │ ├── Properties.hpp │ ├── SPIInProperties.hpp │ ├── SPIOutProperties.hpp │ ├── ScriptProperties.hpp │ ├── SpatialDetectionNetworkProperties.hpp │ ├── SpatialLocationCalculatorProperties.hpp │ ├── StereoDepthProperties.hpp │ ├── SyncProperties.hpp │ ├── SystemLoggerProperties.hpp │ ├── ToFProperties.hpp │ ├── UVCProperties.hpp │ ├── VideoEncoderProperties.hpp │ ├── WarpProperties.hpp │ ├── XLinkInProperties.hpp │ └── XLinkOutProperties.hpp │ ├── utility │ ├── Checksum.hpp │ ├── NlohmannJsonCompat.hpp │ └── Serialization.hpp │ └── xlink │ └── XLinkConstants.hpp └── src ├── datatype └── DatatypeEnum.cpp └── utility └── Checksum.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | # generated backup 2 | pipeline_builder/generated_backup 3 | 4 | # git 5 | .vscode 6 | .vscode/* 7 | *.orig 8 | *_REMOTE_* 9 | *_LOCAL_* 10 | *_BACKUP_* 11 | *_BASE_* 12 | -------------------------------------------------------------------------------- /3rdparty/invoke_hpp/invoke.hpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of the "https://github.com/blackmatov/invoke.hpp" 3 | * For conditions of distribution and use, see copyright notice in LICENSE.md 4 | * Copyright (C) 2018-2020, by Matvey Cherevko (blackmatov@gmail.com) 5 | ******************************************************************************/ 6 | 7 | #pragma once 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #define INVOKE_HPP_NOEXCEPT_DECLTYPE_RETURN(...) \ 15 | noexcept(noexcept(__VA_ARGS__)) -> decltype (__VA_ARGS__) { return __VA_ARGS__; } 16 | 17 | // 18 | // void_t 19 | // 20 | 21 | namespace invoke_hpp 22 | { 23 | namespace impl 24 | { 25 | template < typename... Args > 26 | struct make_void { 27 | using type = void; 28 | }; 29 | } 30 | 31 | template < typename... Args > 32 | using void_t = typename impl::make_void::type; 33 | } 34 | 35 | // 36 | // integer_sequence 37 | // 38 | 39 | namespace invoke_hpp 40 | { 41 | template < typename T, T... Ints > 42 | struct integer_sequence { 43 | using value_type = T; 44 | static constexpr std::size_t size() noexcept { return sizeof...(Ints); } 45 | }; 46 | 47 | template < std::size_t... Ints > 48 | using index_sequence = integer_sequence; 49 | 50 | namespace impl 51 | { 52 | template < typename T, std::size_t N, T... Ints > 53 | struct make_integer_sequence_impl 54 | : make_integer_sequence_impl {}; 55 | 56 | template < typename T, T... Ints > 57 | struct make_integer_sequence_impl 58 | : integer_sequence {}; 59 | } 60 | 61 | template < typename T, std::size_t N > 62 | using make_integer_sequence = impl::make_integer_sequence_impl; 63 | 64 | template < std::size_t N > 65 | using make_index_sequence = make_integer_sequence; 66 | 67 | template < typename... Ts > 68 | using index_sequence_for = make_index_sequence; 69 | } 70 | 71 | // 72 | // is_reference_wrapper 73 | // 74 | 75 | namespace invoke_hpp 76 | { 77 | namespace impl 78 | { 79 | template < typename T > 80 | struct is_reference_wrapper_impl 81 | : std::false_type {}; 82 | 83 | template < typename U > 84 | struct is_reference_wrapper_impl> 85 | : std::true_type {}; 86 | } 87 | 88 | template < typename T > 89 | struct is_reference_wrapper 90 | : impl::is_reference_wrapper_impl::type> {}; 91 | } 92 | 93 | // 94 | // invoke 95 | // 96 | 97 | namespace invoke_hpp 98 | { 99 | namespace impl 100 | { 101 | // 102 | // invoke_member_object_impl 103 | // 104 | 105 | template 106 | < 107 | typename Base, typename F, typename Derived, 108 | typename std::enable_if::type>::value, int>::type = 0 109 | > 110 | constexpr auto invoke_member_object_impl(F Base::* f, Derived&& ref) 111 | INVOKE_HPP_NOEXCEPT_DECLTYPE_RETURN( 112 | std::forward(ref).*f) 113 | 114 | template 115 | < 116 | typename Base, typename F, typename RefWrap, 117 | typename std::enable_if::type>::value, int>::type = 0 118 | > 119 | constexpr auto invoke_member_object_impl(F Base::* f, RefWrap&& ref) 120 | INVOKE_HPP_NOEXCEPT_DECLTYPE_RETURN( 121 | ref.get().*f) 122 | 123 | template 124 | < 125 | typename Base, typename F, typename Pointer, 126 | typename std::enable_if< 127 | !std::is_base_of::type>::value && 128 | !is_reference_wrapper::type>::value 129 | , int>::type = 0 130 | > 131 | constexpr auto invoke_member_object_impl(F Base::* f, Pointer&& ptr) 132 | INVOKE_HPP_NOEXCEPT_DECLTYPE_RETURN( 133 | (*std::forward(ptr)).*f) 134 | 135 | // 136 | // invoke_member_function_impl 137 | // 138 | 139 | template 140 | < 141 | typename Base, typename F, typename Derived, typename... Args, 142 | typename std::enable_if::type>::value, int>::type = 0 143 | > 144 | constexpr auto invoke_member_function_impl(F Base::* f, Derived&& ref, Args&&... args) 145 | INVOKE_HPP_NOEXCEPT_DECLTYPE_RETURN( 146 | (std::forward(ref).*f)(std::forward(args)...)) 147 | 148 | template 149 | < 150 | typename Base, typename F, typename RefWrap, typename... Args, 151 | typename std::enable_if::type>::value, int>::type = 0 152 | > 153 | constexpr auto invoke_member_function_impl(F Base::* f, RefWrap&& ref, Args&&... args) 154 | INVOKE_HPP_NOEXCEPT_DECLTYPE_RETURN( 155 | (ref.get().*f)(std::forward(args)...)) 156 | 157 | template 158 | < 159 | typename Base, typename F, typename Pointer, typename... Args, 160 | typename std::enable_if< 161 | !std::is_base_of::type>::value && 162 | !is_reference_wrapper::type>::value 163 | , int>::type = 0 164 | > 165 | constexpr auto invoke_member_function_impl(F Base::* f, Pointer&& ptr, Args&&... args) 166 | INVOKE_HPP_NOEXCEPT_DECLTYPE_RETURN( 167 | ((*std::forward(ptr)).*f)(std::forward(args)...)) 168 | } 169 | 170 | template 171 | < 172 | typename F, typename... Args, 173 | typename std::enable_if::type>::value, int>::type = 0 174 | > 175 | constexpr auto invoke(F&& f, Args&&... args) 176 | INVOKE_HPP_NOEXCEPT_DECLTYPE_RETURN( 177 | std::forward(f)(std::forward(args)...)) 178 | 179 | template 180 | < 181 | typename F, typename T, 182 | typename std::enable_if::type>::value, int>::type = 0 183 | > 184 | constexpr auto invoke(F&& f, T&& t) 185 | INVOKE_HPP_NOEXCEPT_DECLTYPE_RETURN( 186 | impl::invoke_member_object_impl(std::forward(f), std::forward(t))) 187 | 188 | template 189 | < 190 | typename F, typename... Args, 191 | typename std::enable_if::type>::value, int>::type = 0 192 | > 193 | constexpr auto invoke(F&& f, Args&&... args) 194 | INVOKE_HPP_NOEXCEPT_DECLTYPE_RETURN( 195 | impl::invoke_member_function_impl(std::forward(f), std::forward(args)...)) 196 | } 197 | 198 | // 199 | // invoke_result 200 | // 201 | 202 | namespace invoke_hpp 203 | { 204 | namespace impl 205 | { 206 | struct invoke_result_impl_tag {}; 207 | 208 | template < typename Void, typename F, typename... Args > 209 | struct invoke_result_impl {}; 210 | 211 | template < typename F, typename... Args > 212 | struct invoke_result_impl(), std::declval()...))>, F, Args...> { 213 | using type = decltype(invoke_hpp::invoke(std::declval(), std::declval()...)); 214 | }; 215 | } 216 | 217 | template < typename F, typename... Args > 218 | struct invoke_result 219 | : impl::invoke_result_impl {}; 220 | 221 | template < typename F, typename... Args > 222 | using invoke_result_t = typename invoke_result::type; 223 | } 224 | 225 | // 226 | // is_invocable 227 | // 228 | 229 | namespace invoke_hpp 230 | { 231 | namespace impl 232 | { 233 | struct is_invocable_r_impl_tag {}; 234 | 235 | template < typename Void, typename R, typename F, typename... Args > 236 | struct is_invocable_r_impl 237 | : std::false_type {}; 238 | 239 | template < typename R, typename F, typename... Args > 240 | struct is_invocable_r_impl>, R, F, Args...> 241 | : std::conditional< 242 | std::is_void::value, 243 | std::true_type, 244 | std::is_convertible, R>>::type {}; 245 | } 246 | 247 | template < typename R, typename F, typename... Args > 248 | struct is_invocable_r 249 | : impl::is_invocable_r_impl {}; 250 | 251 | template < typename F, typename... Args > 252 | using is_invocable = is_invocable_r; 253 | } 254 | 255 | // 256 | // apply 257 | // 258 | 259 | namespace invoke_hpp 260 | { 261 | namespace impl 262 | { 263 | template < typename F, typename Tuple, std::size_t... I > 264 | constexpr auto apply_impl(F&& f, Tuple&& args, index_sequence) 265 | INVOKE_HPP_NOEXCEPT_DECLTYPE_RETURN( 266 | invoke_hpp::invoke( 267 | std::forward(f), 268 | std::get(std::forward(args))...)) 269 | } 270 | 271 | template < typename F, typename Tuple > 272 | constexpr auto apply(F&& f, Tuple&& args) 273 | INVOKE_HPP_NOEXCEPT_DECLTYPE_RETURN( 274 | impl::apply_impl( 275 | std::forward(f), 276 | std::forward(args), 277 | make_index_sequence::type>::value>())) 278 | } 279 | 280 | #undef INVOKE_HPP_NOEXCEPT_DECLTYPE_RETURN 281 | -------------------------------------------------------------------------------- /3rdparty/nanorpc/core/client.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------- 2 | // Nano RPC 3 | // https://github.com/tdv/nanorpc 4 | // Created: 05.2018 5 | // Copyright (C) 2018 tdv 6 | //------------------------------------------------------------------- 7 | 8 | #ifndef __NANO_RPC_CORE_CLIENT_H__ 9 | #define __NANO_RPC_CORE_CLIENT_H__ 10 | 11 | // STD 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | // C++17 backwards compatibility 19 | #include 20 | #include 21 | 22 | // NANORPC 23 | #include "nanorpc/core/detail/pack_meta.h" 24 | #include "nanorpc/core/exception.h" 25 | #include "nanorpc/core/type.h" 26 | #include "nanorpc/core/hash.h" 27 | #include "nanorpc/version/core.h" 28 | 29 | 30 | namespace nanorpc 31 | { 32 | namespace core 33 | { 34 | 35 | template 36 | class client final 37 | { 38 | private: 39 | class result; 40 | 41 | public: 42 | client(type::executor executor) 43 | : executor_{std::move(executor)} 44 | { 45 | } 46 | 47 | template 48 | result call(std::string name, TArgs && ... args) 49 | { 50 | return call(hash_id(name), std::forward(args) ... ); 51 | } 52 | 53 | template 54 | result call(type::id id, TArgs && ... args) 55 | { 56 | auto data = std::make_tuple(std::forward(args) ... ); 57 | 58 | packer_type packer; 59 | auto request = packer 60 | .pack(version::core::protocol::value) 61 | .pack(detail::pack::meta::type::request) 62 | .pack(id) 63 | .pack(data) 64 | .to_buffer(); 65 | 66 | auto buffer = executor_(std::move(request)); 67 | auto response = packer.from_buffer(std::move(buffer)); 68 | 69 | { 70 | version::core::protocol::value_type protocol{}; 71 | response = response.unpack(protocol); 72 | if (protocol != version::core::protocol::value) 73 | { 74 | throw exception::client{"[nanorpc::core::client::call] Unsupported protocol version \"" + 75 | std::to_string(protocol) + "\"."}; 76 | } 77 | } 78 | 79 | { 80 | detail::pack::meta::type type{}; 81 | response = response.unpack(type); 82 | if (type != detail::pack::meta::type::response) 83 | throw exception::client{"[nanorpc::core::client::call] Bad response type."}; 84 | } 85 | 86 | { 87 | detail::pack::meta::status status{}; 88 | response = response.unpack(status); 89 | if (status != detail::pack::meta::status::good) 90 | { 91 | std::string message; 92 | response = response.unpack(message); 93 | throw exception::logic{message}; 94 | } 95 | } 96 | 97 | return {std::move(response)}; 98 | } 99 | 100 | private: 101 | using packer_type = TPacker; 102 | using deserializer_type = typename packer_type::deserializer_type; 103 | 104 | type::executor executor_; 105 | 106 | class result final 107 | { 108 | public: 109 | result(result &&) noexcept = default; 110 | result& operator = (result &&) noexcept = default; 111 | ~result() noexcept = default; 112 | 113 | template 114 | T as() const 115 | { 116 | if (!value_ && !deserializer_) 117 | throw exception::client{"[nanorpc::core::client::result::as] No data."}; 118 | 119 | using Type = typename std::decay::type; 120 | 121 | if (!value_) 122 | { 123 | if (!deserializer_) 124 | throw exception::client{"[nanorpc::core::client::result::as] No data."}; 125 | 126 | Type data{}; 127 | deserializer_->unpack(data); 128 | 129 | value_ = std::move(data); 130 | deserializer_.reset(); 131 | } 132 | 133 | return linb::any_cast(*value_); 134 | } 135 | 136 | template 137 | operator T () const 138 | { 139 | return as(); 140 | } 141 | 142 | private: 143 | template 144 | friend class client; 145 | 146 | mutable tl::optional deserializer_; 147 | mutable tl::optional value_; 148 | 149 | result(deserializer_type deserializer) 150 | : deserializer_{std::move(deserializer)} 151 | { 152 | } 153 | 154 | result(result const &) = delete; 155 | result& operator = (result const &) = delete; 156 | }; 157 | }; 158 | 159 | } // namespace core 160 | } // namespace nanorpc 161 | 162 | #endif // !__NANO_RPC_CORE_CLIENT_H__ 163 | -------------------------------------------------------------------------------- /3rdparty/nanorpc/core/detail/config.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------- 2 | // Nano RPC 3 | // https://github.com/tdv/nanorpc 4 | // Created: 06.2018 5 | // Copyright (C) 2018 tdv 6 | //------------------------------------------------------------------- 7 | 8 | #ifndef __NANO_RPC_CORE_DETAIL_CONFIG_H__ 9 | #define __NANO_RPC_CORE_DETAIL_CONFIG_H__ 10 | 11 | 12 | #define NANORPC_PURE_CORE 13 | 14 | #endif // !__NANO_RPC_CORE_DETAIL_CONFIG_H__ 15 | -------------------------------------------------------------------------------- /3rdparty/nanorpc/core/detail/function_meta.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------- 2 | // Nano RPC 3 | // https://github.com/tdv/nanorpc 4 | // Created: 05.2018 5 | // Copyright (C) 2018 tdv 6 | //------------------------------------------------------------------- 7 | 8 | #ifndef __NANO_RPC_CORE_DETAIL_FUNCTION_META_H__ 9 | #define __NANO_RPC_CORE_DETAIL_FUNCTION_META_H__ 10 | 11 | // STD 12 | #include 13 | #include 14 | #include 15 | 16 | namespace nanorpc::core::detail 17 | { 18 | 19 | template 20 | struct function_meta; 21 | 22 | template 23 | struct function_meta> 24 | { 25 | using return_type = std::decay_t; 26 | using arguments_tuple_type = std::tuple ... >; 27 | }; 28 | 29 | template 30 | struct memfun_type 31 | { 32 | using type = void; 33 | }; 34 | 35 | template 36 | struct memfun_type 37 | { 38 | using type = std::function; 39 | }; 40 | 41 | template 42 | typename memfun_type::type 43 | lambdaToFunction(F const &func) 44 | { // Function from lambda ! 45 | return func; 46 | } 47 | 48 | 49 | } // namespace nanorpc::core::detail 50 | 51 | 52 | #endif // !__NANO_RPC_CORE_DETAIL_FUNCTION_META_H__ 53 | -------------------------------------------------------------------------------- /3rdparty/nanorpc/core/detail/pack_meta.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------- 2 | // Nano RPC 3 | // https://github.com/tdv/nanorpc 4 | // Created: 05.2018 5 | // Copyright (C) 2018 tdv 6 | //------------------------------------------------------------------- 7 | 8 | #ifndef __NANO_RPC_CORE_DETAIL_PACK_META_H__ 9 | #define __NANO_RPC_CORE_DETAIL_PACK_META_H__ 10 | 11 | // STD 12 | #include 13 | 14 | namespace nanorpc 15 | { 16 | namespace core 17 | { 18 | namespace detail 19 | { 20 | namespace pack 21 | { 22 | namespace meta 23 | { 24 | 25 | 26 | enum class type : std::uint32_t 27 | { 28 | unknown, 29 | request, 30 | response, 31 | }; 32 | 33 | enum class status : std::uint32_t 34 | { 35 | fail, 36 | good 37 | }; 38 | 39 | 40 | } // namespace meta 41 | } // namespace pack 42 | } // namespace detail 43 | } // namespace core 44 | } // namespace nanorpc 45 | 46 | 47 | #endif // !__NANO_RPC_CORE_DETAIL_PACK_META_H__ 48 | -------------------------------------------------------------------------------- /3rdparty/nanorpc/core/exception.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------- 2 | // Nano RPC 3 | // https://github.com/tdv/nanorpc 4 | // Created: 05.2018 5 | // Copyright (C) 2018 tdv 6 | //------------------------------------------------------------------- 7 | 8 | #ifndef __NANO_RPC_CORE_EXCEPTION_H__ 9 | #define __NANO_RPC_CORE_EXCEPTION_H__ 10 | 11 | // STD 12 | #include 13 | #include 14 | #include 15 | 16 | #define NANORPC_EXCEPTION_DECL(class_, base_) \ 17 | class class_ \ 18 | : public base_ \ 19 | { \ 20 | public: \ 21 | using base_type = base_; \ 22 | using base_type :: base_type; \ 23 | }; 24 | 25 | #define NANORPC_EXCEPTION_DECL_WITH_NAMESPACE(namespace_, class_, base_) \ 26 | namespace namespace_ \ 27 | { \ 28 | NANORPC_EXCEPTION_DECL(class_, base_) \ 29 | } 30 | 31 | namespace nanorpc 32 | { 33 | namespace core 34 | { 35 | namespace exception 36 | { 37 | 38 | 39 | NANORPC_EXCEPTION_DECL(nanorpc, std::runtime_error) 40 | NANORPC_EXCEPTION_DECL(packer, nanorpc) 41 | NANORPC_EXCEPTION_DECL(logic, nanorpc) 42 | NANORPC_EXCEPTION_DECL(transport, nanorpc) 43 | NANORPC_EXCEPTION_DECL(client, transport) 44 | NANORPC_EXCEPTION_DECL(server, transport) 45 | 46 | inline std::string to_string(std::exception const &e) 47 | { 48 | std::string message = e.what(); 49 | 50 | try 51 | { 52 | std::rethrow_if_nested(e); 53 | } 54 | catch (std::exception const &ex) 55 | { 56 | message += "\n"; 57 | message += "\t"; 58 | message += to_string(ex); 59 | } 60 | 61 | return message; 62 | } 63 | 64 | inline void default_error_handler(std::exception_ptr e) 65 | { 66 | if (!e) 67 | return; 68 | 69 | try 70 | { 71 | std::rethrow_exception(e); 72 | } 73 | catch (std::exception const &ex) 74 | { 75 | std::cerr << "NanoRPC exception message: " << to_string(ex) << std::endl; 76 | } 77 | } 78 | 79 | 80 | } // namespace exception 81 | } // namespace core 82 | } // namespace nanorpc 83 | 84 | 85 | #endif // !__NANO_RPC_CORE_EXCEPTION_H__ 86 | -------------------------------------------------------------------------------- /3rdparty/nanorpc/core/hash.h: -------------------------------------------------------------------------------- 1 | #ifndef __NANO_RPC_CORE_HASH_H__ 2 | #define __NANO_RPC_CORE_HASH_H__ 3 | 4 | // STD 5 | #include 6 | #include 7 | 8 | namespace nanorpc 9 | { 10 | namespace core 11 | { 12 | 13 | 14 | inline type::id hash_id(const std::string& str) { 15 | type::id h = UINT64_C(1125899906842597); // prime 16 | for(const auto& c : str) h = 31 * h + c; // as 'h' is unsigned, both 31 and 'c' are promoted to unsigned 17 | return h; 18 | } 19 | 20 | 21 | } // namespace core 22 | } // namespace nanorpc 23 | 24 | 25 | #endif // !__NANO_RPC_CORE_HASH_H__ 26 | -------------------------------------------------------------------------------- /3rdparty/nanorpc/core/server.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------- 2 | // Nano RPC 3 | // https://github.com/tdv/nanorpc 4 | // Created: 05.2018 5 | // Copyright (C) 2018 tdv 6 | //------------------------------------------------------------------- 7 | 8 | #ifndef __NANO_RPC_CORE_SERVER_H__ 9 | #define __NANO_RPC_CORE_SERVER_H__ 10 | 11 | // STD 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | // C++17 backwards compatibility 21 | #include 22 | 23 | // NANORPC 24 | #include "nanorpc/core/detail/function_meta.h" 25 | #include "nanorpc/core/detail/pack_meta.h" 26 | #include "nanorpc/core/exception.h" 27 | #include "nanorpc/core/type.h" 28 | #include "nanorpc/core/hash.h" 29 | #include "nanorpc/version/core.h" 30 | 31 | 32 | namespace nanorpc::core 33 | { 34 | 35 | // Helper 36 | template< class T, class U > 37 | constexpr bool is_same_v = std::is_same::value; 38 | 39 | template 40 | class server final 41 | { 42 | public: 43 | template 44 | void handle(std::string name, TFunc func) 45 | { 46 | handle(hash_id(name), std::move(func)); 47 | } 48 | 49 | template 50 | void handle(type::id id, TFunc func) 51 | { 52 | if (handlers_.find(id) != std::end(handlers_)) 53 | { 54 | throw std::invalid_argument{"[" + std::string{__func__ } + "] Failed to add handler. " 55 | "The id \"" + std::to_string(id) + "\" already exists."}; 56 | } 57 | 58 | auto wrapper = [f = std::move(func)] (deserializer_type &request, serializer_type &response) 59 | { 60 | auto func = detail::lambdaToFunction(std::move(f)); 61 | using function_meta = detail::function_meta; 62 | using arguments_tuple_type = typename function_meta::arguments_tuple_type; 63 | arguments_tuple_type data; 64 | request.unpack(data); 65 | 66 | apply(std::move(func), std::move(data), response); 67 | }; 68 | 69 | handlers_.emplace(std::move(id), std::move(wrapper)); 70 | } 71 | 72 | type::buffer execute(type::buffer buffer) 73 | try 74 | { 75 | if (handlers_.empty()) 76 | throw exception::server{"[nanorpc::core::server::execute] No handlers."}; 77 | 78 | packer_type packer; 79 | 80 | auto request = packer.from_buffer(std::move(buffer)); 81 | 82 | { 83 | version::core::protocol::value_type protocol{}; 84 | request = request.unpack(protocol); 85 | if (protocol != version::core::protocol::value) 86 | { 87 | throw exception::server{"[nanorpc::core::server::execute] Unsupported protocol version \"" + 88 | std::to_string(protocol) + "\"."}; 89 | } 90 | } 91 | 92 | { 93 | detail::pack::meta::type type{}; 94 | request = request.unpack(type); 95 | if (type != detail::pack::meta::type::request) 96 | throw exception::server{"[nanorpc::core::server::execute] Bad response type."}; 97 | } 98 | 99 | type::id function_id{}; 100 | request = request.unpack(function_id); 101 | 102 | auto response = packer 103 | .pack(version::core::protocol::value) 104 | .pack(detail::pack::meta::type::response); 105 | 106 | auto const iter = handlers_.find(function_id); 107 | if (iter == std::end(handlers_)) 108 | throw exception::server{"[nanorpc::core::server::execute] Function not found."}; 109 | 110 | try 111 | { 112 | iter->second(request, response); 113 | } 114 | catch (std::exception const &e) 115 | { 116 | response = response 117 | .pack(detail::pack::meta::status::fail) 118 | .pack(e.what()); 119 | } 120 | 121 | return response.to_buffer(); 122 | } 123 | catch (std::exception const &e) 124 | { 125 | return packer_type{} 126 | .pack(version::core::protocol::value) 127 | .pack(detail::pack::meta::type::response) 128 | .pack(detail::pack::meta::status::fail) 129 | .pack(e.what()) 130 | .to_buffer(); 131 | } 132 | 133 | private: 134 | using packer_type = TPacker; 135 | using serializer_type = typename packer_type::serializer_type; 136 | using deserializer_type = typename packer_type::deserializer_type; 137 | using handler_type = std::function; 138 | using handlers_type = std::map; 139 | 140 | handlers_type handlers_; 141 | 142 | template 143 | static 144 | std::enable_if_t(), std::declval()) ) >, void>, void> 145 | apply(TFunc func, TArgs args, serializer_type &serializer) 146 | { 147 | auto data = invoke_hpp::apply(std::move(func), std::move(args)); 148 | serializer = serializer.pack(detail::pack::meta::status::good); 149 | serializer = serializer.pack(data); 150 | } 151 | 152 | template 153 | static 154 | std::enable_if_t(), std::declval()) ) > , void>, void> 155 | apply(TFunc func, TArgs args, serializer_type &serializer) 156 | { 157 | invoke_hpp::apply(std::move(func), std::move(args)); 158 | serializer = serializer.pack(detail::pack::meta::status::good); 159 | } 160 | 161 | 162 | }; 163 | 164 | } // namespace nanorpc::core 165 | 166 | #endif // !__NANO_RPC_CORE_SERVER_H__ 167 | -------------------------------------------------------------------------------- /3rdparty/nanorpc/core/type.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------- 2 | // Nano RPC 3 | // https://github.com/tdv/nanorpc 4 | // Created: 05.2018 5 | // Copyright (C) 2018 tdv 6 | //------------------------------------------------------------------- 7 | 8 | #ifndef __NANO_RPC_CORE_TYPE_H__ 9 | #define __NANO_RPC_CORE_TYPE_H__ 10 | 11 | // STD 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | namespace nanorpc 20 | { 21 | namespace core 22 | { 23 | namespace type 24 | { 25 | 26 | 27 | using id = std::uint64_t; 28 | using buffer = std::vector; 29 | using executor = std::function; 30 | using executor_map = std::map; 31 | using error_handler = std::function; 32 | 33 | 34 | } // namespace type 35 | } // namespace core 36 | } // namespace nanorpc 37 | 38 | 39 | #endif // !__NANO_RPC_CORE_TYPE_H__ 40 | -------------------------------------------------------------------------------- /3rdparty/nanorpc/packer/cereal_binary.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | // STD 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | // NANORPC 20 | #include "nanorpc/core/detail/config.h" 21 | #include "nanorpc/core/exception.h" 22 | #include "nanorpc/core/type.h" 23 | 24 | // cereal 25 | #include "cereal/cereal.hpp" 26 | #include "cereal/archives/binary.hpp" 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | 35 | // Workaround for cereal not supporting serializing const char* 36 | namespace cereal { 37 | 38 | //! Serializing for const char* 39 | template inline 40 | void CEREAL_SERIALIZE_FUNCTION_NAME( Archive & ar, const char* c_str ) 41 | { 42 | ar(std::string(c_str)); 43 | } 44 | } 45 | 46 | namespace nanorpc 47 | { 48 | namespace packer 49 | { 50 | 51 | 52 | class cereal_binary final 53 | { 54 | private: 55 | class serializer; 56 | class deserializer; 57 | 58 | public: 59 | using serializer_type = serializer; 60 | using deserializer_type = deserializer; 61 | 62 | template 63 | serializer pack(T const &value) 64 | { 65 | return serializer{}.pack(value); 66 | } 67 | 68 | deserializer from_buffer(core::type::buffer buffer) 69 | { 70 | return deserializer{std::move(buffer)}; 71 | } 72 | 73 | private: 74 | class serializer final 75 | { 76 | public: 77 | serializer(serializer &&) noexcept = default; 78 | serializer& operator = (serializer &&) noexcept = default; 79 | ~serializer() noexcept = default; 80 | 81 | template 82 | serializer pack(T const &value) 83 | { 84 | assert(stream_ && "Empty stream."); 85 | if (!stream_) 86 | throw core::exception::packer{"[nanorpc::packer::cereal_binary::serializer::pack] Empty stream."}; 87 | 88 | pack_value(value); 89 | return std::move(*this); 90 | } 91 | 92 | core::type::buffer to_buffer() 93 | { 94 | assert(stream_ && "Empty stream."); 95 | if (!stream_) 96 | throw core::exception::packer{"[nanorpc::packer::cereal_binary::serializer::to_buffer] Empty stream."}; 97 | 98 | archive_ = nullptr; 99 | auto str = std::move(stream_->str()); 100 | return {begin(str), end(str)}; 101 | } 102 | 103 | private: 104 | 105 | using stream_type = std::stringstream; 106 | using stream_type_ptr = std::unique_ptr; 107 | 108 | stream_type_ptr stream_{std::make_unique()}; 109 | std::unique_ptr archive_; 110 | 111 | friend class cereal_binary; 112 | serializer(){ 113 | archive_ = std::make_unique(*stream_); 114 | } 115 | 116 | serializer(serializer const &) = delete; 117 | serializer& operator = (serializer const &) = delete; 118 | 119 | 120 | template 121 | void pack_value(T const &value) 122 | { 123 | (*archive_)(value); 124 | } 125 | 126 | // c string specialization 127 | void pack_value(const char* value) 128 | { 129 | (*archive_)(std::string(value)); 130 | } 131 | 132 | }; 133 | 134 | class deserializer final 135 | { 136 | public: 137 | deserializer(deserializer &&) noexcept = default; 138 | deserializer& operator = (deserializer &&) noexcept = default; 139 | ~deserializer() noexcept = default; 140 | 141 | template 142 | deserializer unpack(T &value) 143 | { 144 | assert(stream_ && "Empty stream."); 145 | if (!stream_) 146 | throw core::exception::packer{"[nanorpc::packer::plain_text::deserializer] Empty stream."}; 147 | 148 | unpack_value(value); 149 | return std::move(*this); 150 | } 151 | 152 | private: 153 | 154 | using stream_type = std::stringstream; 155 | using stream_type_ptr = std::unique_ptr; 156 | stream_type_ptr stream_{std::make_unique()}; 157 | 158 | std::unique_ptr archive_; 159 | 160 | 161 | friend class cereal_binary; 162 | 163 | deserializer(deserializer const &) = delete; 164 | deserializer& operator = (deserializer const &) = delete; 165 | 166 | deserializer(core::type::buffer buffer) 167 | : stream_{std::make_unique(std::string{begin(buffer), end(buffer)})} 168 | { 169 | archive_ = std::make_unique(*stream_); 170 | } 171 | 172 | 173 | template 174 | void unpack_value(T &value) 175 | { 176 | (*archive_)(value); 177 | } 178 | 179 | // c string specialization 180 | void pack_value(char* value) 181 | { 182 | std::string val; 183 | (*archive_)(val); 184 | strcpy(value, val.c_str()); 185 | } 186 | 187 | }; 188 | 189 | }; 190 | 191 | } // namespace packer 192 | } // namespace nanorpc 193 | -------------------------------------------------------------------------------- /3rdparty/nanorpc/packer/nlohmann_json.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | // STD 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | // NANORPC 20 | #include "nanorpc/core/detail/config.h" 21 | #include "nanorpc/core/exception.h" 22 | #include "nanorpc/core/type.h" 23 | 24 | // nlohmann 25 | #include "nlohmann/json.hpp" 26 | 27 | namespace nanorpc 28 | { 29 | namespace packer 30 | { 31 | 32 | class nlohmann_json final 33 | { 34 | private: 35 | class serializer; 36 | class deserializer; 37 | 38 | public: 39 | using serializer_type = serializer; 40 | using deserializer_type = deserializer; 41 | 42 | template 43 | serializer pack(T const &value) 44 | { 45 | return serializer{}.pack(value); 46 | } 47 | 48 | deserializer from_buffer(core::type::buffer buffer) 49 | { 50 | return deserializer{std::move(buffer)}; 51 | } 52 | 53 | private: 54 | class serializer final 55 | { 56 | public: 57 | serializer(serializer &&) noexcept = default; 58 | serializer& operator = (serializer &&) noexcept = default; 59 | ~serializer() noexcept = default; 60 | 61 | template 62 | serializer pack(T const &value) 63 | { 64 | pack_value(value); 65 | return std::move(*this); 66 | } 67 | 68 | core::type::buffer to_buffer() 69 | { 70 | assert(data.size() > 0 && "Empty stream."); 71 | if (data.empty()) 72 | throw core::exception::packer{"[nanorpc::packer::nlohmann_json::serializer::to_buffer] Empty data."}; 73 | 74 | //core::type::buffer buf = nlohmann::json::to_msgpack(data); 75 | nlohmann::json j = data; 76 | auto str = j.dump(); 77 | core::type::buffer buf(str.begin(), str.end()); 78 | 79 | return buf; 80 | } 81 | 82 | private: 83 | 84 | // data storage 85 | std::vector< nlohmann::json > data; 86 | 87 | friend class nlohmann_json; 88 | serializer() = default; 89 | 90 | serializer(serializer const &) = delete; 91 | serializer& operator = (serializer const &) = delete; 92 | 93 | template 94 | void pack_value(T const &value) 95 | { 96 | data.push_back(value); 97 | } 98 | 99 | }; 100 | 101 | class deserializer final 102 | { 103 | public: 104 | deserializer(deserializer &&) noexcept = default; 105 | deserializer& operator = (deserializer &&) noexcept = default; 106 | ~deserializer() noexcept = default; 107 | 108 | deserializer(core::type::buffer buffer) 109 | { 110 | nlohmann::from_json(nlohmann::json::parse(buffer), data); 111 | } 112 | 113 | template 114 | deserializer unpack(T &value) 115 | { 116 | assert(data.size() > 0 && "Empty stream."); 117 | if (data.empty()) 118 | throw core::exception::packer{"[nanorpc::packer::nlohmann_json::deserializer] Empty stream."}; 119 | 120 | unpack_value(value); 121 | return std::move(*this); 122 | } 123 | 124 | private: 125 | 126 | // data storage 127 | std::vector< nlohmann::json > data; 128 | 129 | friend class nlohmann_json; 130 | 131 | deserializer(deserializer const &) = delete; 132 | deserializer& operator = (deserializer const &) = delete; 133 | 134 | template 135 | void unpack_value(T &value) 136 | { 137 | nlohmann::from_json(data.front(), value); 138 | data.erase(data.begin()); 139 | } 140 | 141 | }; 142 | 143 | }; 144 | 145 | } // namespace packer 146 | } // namespace nanorpc 147 | -------------------------------------------------------------------------------- /3rdparty/nanorpc/packer/nlohmann_msgpack.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | // STD 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | // NANORPC 20 | #include "nanorpc/core/detail/config.h" 21 | #include "nanorpc/core/exception.h" 22 | #include "nanorpc/core/type.h" 23 | 24 | // nlohmann 25 | #include "nlohmann/json.hpp" 26 | 27 | namespace nanorpc 28 | { 29 | namespace packer 30 | { 31 | 32 | class nlohmann_msgpack final 33 | { 34 | private: 35 | class serializer; 36 | class deserializer; 37 | 38 | public: 39 | using serializer_type = serializer; 40 | using deserializer_type = deserializer; 41 | 42 | template 43 | serializer pack(T const &value) 44 | { 45 | return serializer{}.pack(value); 46 | } 47 | 48 | deserializer from_buffer(core::type::buffer buffer) 49 | { 50 | return deserializer{std::move(buffer)}; 51 | } 52 | 53 | private: 54 | class serializer final 55 | { 56 | public: 57 | serializer(serializer &&) noexcept = default; 58 | serializer& operator = (serializer &&) noexcept = default; 59 | ~serializer() noexcept = default; 60 | 61 | template 62 | serializer pack(T const &value) 63 | { 64 | pack_value(value); 65 | return std::move(*this); 66 | } 67 | 68 | core::type::buffer to_buffer() 69 | { 70 | assert(data.size() > 0 && "Empty stream."); 71 | if (data.empty()) 72 | throw core::exception::packer{"[nanorpc::packer::nlohmann_msgpack::serializer::to_buffer] Empty data."}; 73 | 74 | core::type::buffer buf = nlohmann::json::to_msgpack(data); 75 | return buf; 76 | } 77 | 78 | private: 79 | 80 | // data storage 81 | std::vector< nlohmann::json > data; 82 | 83 | 84 | friend class nlohmann_msgpack; 85 | serializer() = default; 86 | 87 | serializer(serializer const &) = delete; 88 | serializer& operator = (serializer const &) = delete; 89 | 90 | template 91 | void pack_value(T const &value) 92 | { 93 | data.push_back(value); 94 | } 95 | 96 | }; 97 | 98 | class deserializer final 99 | { 100 | public: 101 | deserializer(deserializer &&) noexcept = default; 102 | deserializer& operator = (deserializer &&) noexcept = default; 103 | ~deserializer() noexcept = default; 104 | 105 | deserializer(core::type::buffer buffer) 106 | { 107 | nlohmann::from_json(nlohmann::json::from_msgpack(buffer), data); 108 | } 109 | 110 | template 111 | deserializer unpack(T &value) 112 | { 113 | assert(data.size() > 0 && "Empty stream."); 114 | if (data.empty()) 115 | throw core::exception::packer{"[nanorpc::packer::nlohmann_msgpack::deserializer] Empty stream."}; 116 | 117 | unpack_value(value); 118 | return std::move(*this); 119 | } 120 | 121 | 122 | private: 123 | 124 | // data storage 125 | std::vector< nlohmann::json > data; 126 | 127 | friend class nlohmann_msgpack; 128 | 129 | deserializer(deserializer const &) = delete; 130 | deserializer& operator = (deserializer const &) = delete; 131 | 132 | 133 | template 134 | void unpack_value(T &value) 135 | { 136 | nlohmann::from_json(data.front(), value); 137 | data.erase(data.begin()); 138 | } 139 | 140 | }; 141 | 142 | }; 143 | 144 | } // namespace packer 145 | } // namespace nanorpc 146 | -------------------------------------------------------------------------------- /3rdparty/nanorpc/version/core.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------- 2 | // Nano RPC 3 | // https://github.com/tdv/nanorpc 4 | // Created: 05.2018 5 | // Copyright (C) 2018 tdv 6 | //------------------------------------------------------------------- 7 | 8 | #ifndef __NANO_RPC_VERSION_CORE_H__ 9 | #define __NANO_RPC_VERSION_CORE_H__ 10 | 11 | // STD 12 | #include 13 | #include 14 | 15 | namespace nanorpc 16 | { 17 | namespace version 18 | { 19 | namespace core 20 | { 21 | 22 | using protocol = std::integral_constant; 23 | 24 | } // namespace core 25 | } // namespace version 26 | } // namespace nanorpc 27 | 28 | 29 | #endif // !__NANO_RPC_VERSION_CORE_H__ 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Luxonis LLC 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # depthai-shared 2 | 3 | Shared code and data between device and host side of DepthAI 4 | 5 | -------------------------------------------------------------------------------- /include/depthai-shared/common/CameraBoardSocket.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | namespace dai { 4 | /** 5 | * Which Camera socket to use. 6 | * 7 | * AUTO denotes that the decision will be made by device 8 | */ 9 | enum class CameraBoardSocket : int32_t { 10 | AUTO = -1, 11 | CAM_A, 12 | CAM_B, 13 | CAM_C, 14 | CAM_D, 15 | CAM_E, 16 | CAM_F, 17 | CAM_G, 18 | CAM_H, 19 | CAM_I, 20 | CAM_J, 21 | // Deprecated naming 22 | RGB [[deprecated]] = CAM_A, 23 | CENTER [[deprecated]] = CAM_A, 24 | LEFT [[deprecated]] = CAM_B, 25 | RIGHT [[deprecated]] = CAM_C, 26 | }; 27 | 28 | } // namespace dai 29 | -------------------------------------------------------------------------------- /include/depthai-shared/common/CameraFeatures.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "depthai-shared/common/CameraBoardSocket.hpp" 4 | #include "depthai-shared/common/CameraImageOrientation.hpp" 5 | #include "depthai-shared/common/CameraSensorType.hpp" 6 | #include "depthai-shared/common/Rect.hpp" 7 | #include "depthai-shared/common/optional.hpp" 8 | #include "depthai-shared/utility/Serialization.hpp" 9 | 10 | namespace dai { 11 | 12 | /** 13 | * Sensor config 14 | */ 15 | struct CameraSensorConfig { 16 | /// Width and height in number of output pixels. 17 | std::int32_t width = -1, height = -1; 18 | float minFps = -1, maxFps = -1; 19 | /// Sensor active view area in physical area [pixels] 20 | Rect fov; 21 | CameraSensorType type; 22 | }; 23 | DEPTHAI_SERIALIZE_EXT(CameraSensorConfig, width, height, minFps, maxFps, fov, type); 24 | 25 | /** 26 | * CameraFeatures structure 27 | * 28 | * Characterizes detected cameras on board 29 | */ 30 | struct CameraFeatures { 31 | /** 32 | * Board socket where the camera was detected 33 | */ 34 | CameraBoardSocket socket = CameraBoardSocket::AUTO; 35 | /** 36 | * Camera sensor name, e.g: "IMX378", "OV9282" 37 | */ 38 | std::string sensorName; 39 | /** 40 | * Maximum sensor resolution 41 | */ 42 | std::int32_t width = -1, height = -1; 43 | /** 44 | * Default camera orientation, board dependent 45 | */ 46 | CameraImageOrientation orientation = CameraImageOrientation::AUTO; 47 | /** 48 | * List of supported types of processing for the given camera. 49 | * 50 | * For some sensors it's not possible to determine if they are color or mono 51 | * (e.g. OV9782 and OV9282), so this could return more than one entry 52 | */ 53 | std::vector supportedTypes; 54 | /** 55 | * Whether an autofocus VCM IC was detected 56 | */ 57 | bool hasAutofocusIC = false; 58 | /** 59 | * Whether camera has auto focus capabilities, or is a fixed focus lens 60 | */ 61 | bool hasAutofocus = false; 62 | /** 63 | * Camera name or alias 64 | */ 65 | std::string name; 66 | /** 67 | * Additional camera names or aliases 68 | */ 69 | std::vector additionalNames; 70 | /** 71 | * Available sensor configs 72 | */ 73 | std::vector configs; 74 | 75 | /** 76 | * The resolution which should be used for calibration. 77 | */ 78 | tl::optional calibrationResolution = tl::nullopt; 79 | 80 | DEPTHAI_SERIALIZE(CameraFeatures, 81 | socket, 82 | sensorName, 83 | width, 84 | height, 85 | orientation, 86 | supportedTypes, 87 | hasAutofocusIC, 88 | hasAutofocus, 89 | name, 90 | additionalNames, 91 | configs, 92 | calibrationResolution); 93 | }; 94 | 95 | } // namespace dai 96 | -------------------------------------------------------------------------------- /include/depthai-shared/common/CameraImageOrientation.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace dai { 5 | /** 6 | * Camera sensor image orientation / pixel readout. 7 | * This exposes direct sensor settings. 90 or 270 degrees rotation is not available. 8 | * 9 | * AUTO denotes that the decision will be made by device (e.g. on OAK-1/megaAI: ROTATE_180_DEG). 10 | */ 11 | enum class CameraImageOrientation : int32_t { AUTO = -1, NORMAL, HORIZONTAL_MIRROR, VERTICAL_FLIP, ROTATE_180_DEG }; 12 | 13 | } // namespace dai 14 | -------------------------------------------------------------------------------- /include/depthai-shared/common/CameraInfo.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "depthai-shared/common/CameraModel.hpp" 4 | #include "depthai-shared/common/Extrinsics.hpp" 5 | #include "depthai-shared/utility/Serialization.hpp" 6 | 7 | namespace dai { 8 | 9 | /// CameraInfo structure 10 | struct CameraInfo { 11 | uint16_t width = 0, height = 0; 12 | uint8_t lensPosition = 0; 13 | std::vector> intrinsicMatrix; 14 | std::vector distortionCoeff; 15 | Extrinsics extrinsics; 16 | float specHfovDeg = 0.0f; // fov in deg 17 | CameraModel cameraType = CameraModel::Perspective; 18 | DEPTHAI_SERIALIZE(CameraInfo, cameraType, width, height, specHfovDeg, lensPosition, intrinsicMatrix, distortionCoeff, extrinsics); 19 | }; 20 | 21 | } // namespace dai -------------------------------------------------------------------------------- /include/depthai-shared/common/CameraModel.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace dai { 6 | /** 7 | * Which CameraModel to initialize the calibration with. 8 | */ 9 | enum class CameraModel : int8_t { Perspective = 0, Fisheye = 1, Equirectangular = 2, RadialDivision = 3 }; 10 | 11 | } // namespace dai -------------------------------------------------------------------------------- /include/depthai-shared/common/CameraSensorType.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace dai { 6 | 7 | /// Camera sensor type 8 | enum class CameraSensorType : int32_t { AUTO = -1, COLOR = 0, MONO = 1, TOF = 2, THERMAL = 3 }; 9 | 10 | } // namespace dai 11 | -------------------------------------------------------------------------------- /include/depthai-shared/common/ChipTemperature.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "depthai-shared/utility/Serialization.hpp" 4 | 5 | namespace dai { 6 | 7 | /** 8 | * Chip temperature information. 9 | * 10 | * Multiple temperature measurement points and their average 11 | */ 12 | struct ChipTemperature { 13 | /** 14 | * CPU Subsystem 15 | */ 16 | float css; 17 | /** 18 | * Media Subsystem 19 | */ 20 | float mss; 21 | /** 22 | * Shave Array 23 | */ 24 | float upa; 25 | /** 26 | * DRAM Subsystem 27 | */ 28 | float dss; 29 | /** 30 | * Average of measurements 31 | */ 32 | float average; 33 | }; 34 | 35 | DEPTHAI_SERIALIZE_EXT(ChipTemperature, css, mss, upa, dss, average); 36 | 37 | } // namespace dai -------------------------------------------------------------------------------- /include/depthai-shared/common/Colormap.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace dai { 6 | 7 | /// Camera sensor type 8 | enum class Colormap : int32_t { 9 | NONE = 0, 10 | TURBO, 11 | JET, 12 | STEREO_TURBO, 13 | STEREO_JET 14 | // AUTUMN, 15 | // BONE, 16 | // JET, 17 | // WINTER, 18 | // RAINBOW, 19 | // OCEAN, 20 | // SUMMER, 21 | // SPRING, 22 | // COOL, 23 | // HSV, 24 | // PINK, 25 | // HOT, 26 | // PARULA, 27 | // MAGMA, 28 | // INFERNO, 29 | // PLASMA, 30 | // VIRIDIS, 31 | // CIVIDIS, 32 | // TWILIGHT, 33 | // TWILIGHT_SHIFTED, 34 | // DEEPGREEN 35 | }; 36 | 37 | } // namespace dai 38 | -------------------------------------------------------------------------------- /include/depthai-shared/common/ConnectionInterface.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace dai { 5 | enum class ConnectionInterface : int32_t { USB, ETHERNET, WIFI }; 6 | } // namespace dai 7 | -------------------------------------------------------------------------------- /include/depthai-shared/common/CpuUsage.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "depthai-shared/utility/Serialization.hpp" 4 | 5 | namespace dai { 6 | 7 | /** 8 | * CpuUsage structure 9 | * 10 | * Average usage in percent and time span of the average (since last query) 11 | */ 12 | struct CpuUsage { 13 | /** 14 | * Average CPU usage, expressed with a normalized value (0-1) 15 | */ 16 | float average; 17 | /** 18 | * Time span in which the average was calculated in milliseconds 19 | */ 20 | int32_t msTime; 21 | }; 22 | 23 | DEPTHAI_SERIALIZE_EXT(CpuUsage, average, msTime); 24 | 25 | } // namespace dai -------------------------------------------------------------------------------- /include/depthai-shared/common/DetectionNetworkType.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | enum class DetectionNetworkType : std::int32_t { YOLO, MOBILENET }; 6 | -------------------------------------------------------------------------------- /include/depthai-shared/common/DetectionParserOptions.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "depthai-shared/common/DetectionNetworkType.hpp" 4 | #include "depthai-shared/utility/Serialization.hpp" 5 | 6 | namespace dai { 7 | 8 | /** 9 | * DetectionParserOptions 10 | * 11 | * Specifies how to parse output of detection networks 12 | */ 13 | struct DetectionParserOptions { 14 | /// Generic Neural Network properties 15 | DetectionNetworkType nnFamily; 16 | float confidenceThreshold; 17 | 18 | /// YOLO specific network properties 19 | int classes; 20 | int coordinates; 21 | std::vector anchors; 22 | std::map> anchorMasks; 23 | float iouThreshold; 24 | }; 25 | 26 | DEPTHAI_SERIALIZE_EXT(DetectionParserOptions, nnFamily, confidenceThreshold, classes, coordinates, anchors, anchorMasks, iouThreshold); 27 | 28 | } // namespace dai -------------------------------------------------------------------------------- /include/depthai-shared/common/EepromData.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | #include "depthai-shared/common/CameraBoardSocket.hpp" 7 | #include "depthai-shared/common/CameraInfo.hpp" 8 | #include "depthai-shared/common/Extrinsics.hpp" 9 | #include "depthai-shared/common/Point3f.hpp" 10 | #include "depthai-shared/common/StereoRectification.hpp" 11 | #include "depthai-shared/utility/Serialization.hpp" 12 | 13 | namespace dai { 14 | /** 15 | * EepromData structure 16 | * 17 | * Contains the Calibration and Board data stored on device 18 | */ 19 | struct EepromData { 20 | uint32_t version = 7; 21 | std::string productName, boardCustom, boardName, boardRev, boardConf, hardwareConf, deviceName; 22 | std::string batchName; /// Deprecated, not used or stored 23 | uint64_t batchTime{0}; 24 | uint32_t boardOptions{0}; 25 | std::unordered_map cameraData; 26 | StereoRectification stereoRectificationData; 27 | Extrinsics imuExtrinsics; 28 | Extrinsics housingExtrinsics; 29 | std::vector miscellaneousData; 30 | bool stereoUseSpecTranslation{true}; 31 | bool stereoEnableDistortionCorrection{false}; 32 | CameraBoardSocket verticalCameraSocket = dai::CameraBoardSocket::AUTO; 33 | }; 34 | 35 | DEPTHAI_SERIALIZE_OPTIONAL_EXT(EepromData, 36 | version, 37 | boardCustom, 38 | boardName, 39 | boardRev, 40 | boardConf, 41 | hardwareConf, 42 | productName, 43 | deviceName, 44 | batchName, 45 | batchTime, 46 | boardOptions, 47 | cameraData, 48 | stereoRectificationData, 49 | imuExtrinsics, 50 | housingExtrinsics, 51 | miscellaneousData, 52 | stereoUseSpecTranslation, 53 | stereoEnableDistortionCorrection, 54 | verticalCameraSocket); 55 | 56 | } // namespace dai 57 | -------------------------------------------------------------------------------- /include/depthai-shared/common/Extrinsics.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "depthai-shared/common/CameraBoardSocket.hpp" 6 | #include "depthai-shared/common/Point3f.hpp" 7 | #include "depthai-shared/utility/Serialization.hpp" 8 | 9 | namespace dai { 10 | 11 | /// Extrinsics structure 12 | struct Extrinsics { 13 | std::vector> rotationMatrix; 14 | /** 15 | * (x, y, z) pose of destCameraSocket w.r.t currentCameraSocket obtained through calibration 16 | */ 17 | Point3f translation; 18 | /** 19 | * (x, y, z) pose of destCameraSocket w.r.t currentCameraSocket measured through CAD design 20 | */ 21 | Point3f specTranslation; 22 | CameraBoardSocket toCameraSocket = CameraBoardSocket::AUTO; 23 | DEPTHAI_SERIALIZE(Extrinsics, rotationMatrix, translation, specTranslation, toCameraSocket); 24 | }; 25 | 26 | } // namespace dai -------------------------------------------------------------------------------- /include/depthai-shared/common/FrameEvent.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // std 4 | #include 5 | 6 | namespace dai { 7 | 8 | enum class FrameEvent : int32_t { NONE, READOUT_START, READOUT_END }; 9 | 10 | } // namespace dai 11 | -------------------------------------------------------------------------------- /include/depthai-shared/common/Interpolation.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace dai { 6 | 7 | /** 8 | * Interpolation type 9 | */ 10 | enum class Interpolation : std::int32_t { 11 | 12 | AUTO = -1, 13 | BILINEAR = 0, 14 | BICUBIC = 1, 15 | NEAREST_NEIGHBOR = 2, 16 | BYPASS = NEAREST_NEIGHBOR, 17 | DEFAULT = BICUBIC, 18 | DEFAULT_DISPARITY_DEPTH = NEAREST_NEIGHBOR 19 | 20 | }; 21 | 22 | } // namespace dai 23 | -------------------------------------------------------------------------------- /include/depthai-shared/common/MedianFilter.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // std 4 | #include 5 | 6 | // project 7 | #include "depthai-shared/utility/Serialization.hpp" 8 | 9 | namespace dai { 10 | 11 | /** 12 | * Median filter config 13 | */ 14 | enum class MedianFilter : int32_t { MEDIAN_OFF = 0, KERNEL_3x3 = 3, KERNEL_5x5 = 5, KERNEL_7x7 = 7 }; 15 | 16 | } // namespace dai 17 | -------------------------------------------------------------------------------- /include/depthai-shared/common/MemoryInfo.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "depthai-shared/utility/Serialization.hpp" 4 | 5 | namespace dai { 6 | 7 | /** 8 | * MemoryInfo structure 9 | * 10 | * Free, remaining and total memory stats 11 | */ 12 | struct MemoryInfo { 13 | int64_t remaining; 14 | int64_t used; 15 | int64_t total; 16 | }; 17 | 18 | DEPTHAI_SERIALIZE_EXT(MemoryInfo, remaining, used, total); 19 | 20 | } // namespace dai -------------------------------------------------------------------------------- /include/depthai-shared/common/Point2f.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // std 4 | #include 5 | 6 | // project 7 | #include "depthai-shared/utility/Serialization.hpp" 8 | 9 | namespace dai { 10 | 11 | /** 12 | * Point2f structure 13 | * 14 | * x and y coordinates that define a 2D point. 15 | */ 16 | struct Point2f { 17 | Point2f() = default; 18 | Point2f(float x, float y) : x(x), y(y) {} 19 | float x = 0, y = 0; 20 | }; 21 | 22 | DEPTHAI_SERIALIZE_EXT(Point2f, x, y); 23 | 24 | } // namespace dai 25 | -------------------------------------------------------------------------------- /include/depthai-shared/common/Point3f.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // std 4 | #include 5 | 6 | // project 7 | #include "depthai-shared/utility/Serialization.hpp" 8 | 9 | namespace dai { 10 | 11 | /** 12 | * Point3f structure 13 | * 14 | * x,y,z coordinates that define a 3D point. 15 | */ 16 | struct Point3f { 17 | Point3f() = default; 18 | Point3f(float x, float y, float z) : x(x), y(y), z(z) {} 19 | float x = 0, y = 0, z = 0; 20 | }; 21 | 22 | DEPTHAI_SERIALIZE_EXT(Point3f, x, y, z); 23 | 24 | } // namespace dai 25 | -------------------------------------------------------------------------------- /include/depthai-shared/common/ProcessorType.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace dai { 6 | 7 | /** 8 | * On which processor the node will be placed 9 | * 10 | * Enum specifying processor 11 | */ 12 | enum class ProcessorType : int32_t { LEON_CSS, LEON_MSS }; 13 | 14 | } // namespace dai -------------------------------------------------------------------------------- /include/depthai-shared/common/Rect.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // libraries 4 | #include 5 | 6 | #include "depthai-shared/common/Point2f.hpp" 7 | #include "depthai-shared/common/Size2f.hpp" 8 | #include "depthai-shared/utility/Serialization.hpp" 9 | 10 | namespace dai { 11 | 12 | /** 13 | * Rect structure 14 | * 15 | * x,y coordinates together with width and height that define a rectangle. 16 | * Can be either normalized [0,1] or absolute representation. 17 | */ 18 | struct Rect { 19 | // default constructor 20 | Rect() = default; 21 | Rect(float x, float y, float width, float height) : x(x), y(y), width(width), height(height) {} 22 | Rect(const Rect& r) : x(r.x), y(r.y), width(r.width), height(r.height) {} 23 | Rect(const Point2f& org, const Size2f& sz) : x(org.x), y(org.y), width(sz.width), height(sz.height) {} 24 | Rect(const Point2f& pt1, const Point2f& pt2) 25 | : x(std::min(pt1.x, pt2.x)), y(std::min(pt1.y, pt2.y)), width(std::max(pt1.x, pt2.x) - x), height(std::max(pt1.y, pt2.y) - y) {} 26 | Rect& operator=(const Rect& r) = default; 27 | Rect& operator=(Rect&& r) = default; 28 | 29 | /** 30 | * The top-left corner. 31 | */ 32 | Point2f topLeft() const { 33 | return Point2f(x, y); 34 | } 35 | 36 | /** 37 | * The bottom-right corner 38 | */ 39 | Point2f bottomRight() const { 40 | return Point2f(x + width, y + height); 41 | } 42 | 43 | /** 44 | * Size (width, height) of the rectangle 45 | */ 46 | Size2f size() const { 47 | return Size2f(width, height); 48 | } 49 | 50 | /** 51 | * Area (width*height) of the rectangle 52 | */ 53 | float area() const { 54 | return width * height; 55 | } 56 | 57 | /** 58 | * True if rectangle is empty. 59 | */ 60 | bool empty() const { 61 | return width <= 0 || height <= 0; 62 | } 63 | 64 | /** 65 | * Checks whether the rectangle contains the point. 66 | */ 67 | bool contains(const Point2f& pt) const { 68 | return x <= pt.x && pt.x < x + width && y <= pt.y && pt.y < y + height; 69 | } 70 | 71 | /** 72 | * Whether rectangle is normalized (coordinates in [0,1] range) or not. 73 | */ 74 | bool isNormalized() const { 75 | if(x + width <= 1.f && y + height <= 1.f) return true; 76 | return !(x == static_cast(x) && y == static_cast(y) && width == static_cast(width) && height == static_cast(height)); 77 | } 78 | 79 | /** 80 | * Denormalize rectangle. 81 | * @param destWidth Destination frame width. 82 | * @param destHeight Destination frame height. 83 | */ 84 | Rect denormalize(int destWidth, int destHeight) const { 85 | if(isNormalized()) { 86 | return Rect(std::round(x * destWidth), std::round(y * destHeight), std::round(width * destWidth), std::round(height * destHeight)); 87 | } 88 | return *this; 89 | } 90 | 91 | /** 92 | * Normalize rectangle. 93 | * @param srcWidth Source frame width. 94 | * @param srcHeight Source frame height. 95 | */ 96 | Rect normalize(int srcWidth, int srcHeight) const { 97 | if(isNormalized()) { 98 | return *this; 99 | } 100 | return Rect(x / srcWidth, y / srcHeight, width / srcWidth, height / srcHeight); 101 | } 102 | 103 | // order of declaration must be x, y, width, height for constructor initializer lists 104 | float x = 0.0f; // x coordinate of the top-left corner 105 | float y = 0.0f; // y coordinate of the top-left corner 106 | float width = 0.0f; // width of the rectangle 107 | float height = 0.0f; // height of the rectangle 108 | }; 109 | DEPTHAI_SERIALIZE_EXT(Rect, x, y, width, height); 110 | 111 | } // namespace dai 112 | -------------------------------------------------------------------------------- /include/depthai-shared/common/RotatedRect.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // std 4 | #include 5 | 6 | // shared 7 | #include "depthai-shared/common/Point2f.hpp" 8 | #include "depthai-shared/common/Size2f.hpp" 9 | #include "depthai-shared/utility/Serialization.hpp" 10 | 11 | namespace dai { 12 | 13 | /// RotatedRect structure 14 | struct RotatedRect { 15 | Point2f center; 16 | Size2f size; 17 | /// degrees, increasing clockwise 18 | float angle = 0.f; 19 | }; 20 | 21 | DEPTHAI_SERIALIZE_EXT(RotatedRect, center, size, angle); 22 | 23 | } // namespace dai 24 | -------------------------------------------------------------------------------- /include/depthai-shared/common/Size2f.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // std 4 | #include 5 | 6 | #include "depthai-shared/utility/Serialization.hpp" 7 | 8 | namespace dai { 9 | 10 | /** 11 | * Size2f structure 12 | * 13 | * width, height values define the size of the shape/frame 14 | */ 15 | struct Size2f { 16 | Size2f() = default; 17 | Size2f(float width, float height) : width(width), height(height) {} 18 | float width = 0, height = 0; 19 | }; 20 | 21 | DEPTHAI_SERIALIZE_EXT(Size2f, width, height); 22 | 23 | } // namespace dai 24 | -------------------------------------------------------------------------------- /include/depthai-shared/common/StereoPair.hpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #pragma once 4 | 5 | #include "depthai-shared/common/CameraBoardSocket.hpp" 6 | namespace dai { 7 | /** 8 | * Describes which camera sockets can be used for stereo and their baseline. 9 | * 10 | */ 11 | struct StereoPair { 12 | CameraBoardSocket left; 13 | CameraBoardSocket right; 14 | /** 15 | * Baseline in centimeters. 16 | */ 17 | float baseline = -1; 18 | bool isVertical = false; 19 | DEPTHAI_SERIALIZE(StereoPair, left, right, baseline, isVertical); 20 | }; 21 | } // namespace dai 22 | -------------------------------------------------------------------------------- /include/depthai-shared/common/StereoRectification.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "depthai-shared/common/CameraBoardSocket.hpp" 6 | #include "depthai-shared/utility/Serialization.hpp" 7 | 8 | namespace dai { 9 | 10 | /// StereoRectification structure 11 | struct StereoRectification { 12 | std::vector> rectifiedRotationLeft, rectifiedRotationRight; 13 | CameraBoardSocket leftCameraSocket = CameraBoardSocket::AUTO, rightCameraSocket = CameraBoardSocket::AUTO; 14 | }; 15 | 16 | DEPTHAI_SERIALIZE_EXT(StereoRectification, rectifiedRotationLeft, rectifiedRotationRight, leftCameraSocket, rightCameraSocket); 17 | 18 | } // namespace dai 19 | -------------------------------------------------------------------------------- /include/depthai-shared/common/TensorInfo.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // std 4 | #include 5 | 6 | // project 7 | #include "depthai-shared/utility/Serialization.hpp" 8 | 9 | namespace dai { 10 | 11 | /// TensorInfo structure 12 | struct TensorInfo { 13 | enum class StorageOrder : int { 14 | NHWC = 0x4213, 15 | NHCW = 0x4231, 16 | NCHW = 0x4321, 17 | HWC = 0x213, 18 | CHW = 0x321, 19 | WHC = 0x123, 20 | HCW = 0x231, 21 | WCH = 0x132, 22 | CWH = 0x312, 23 | NC = 0x43, 24 | CN = 0x34, 25 | C = 0x3, 26 | H = 0x2, 27 | W = 0x1, 28 | }; 29 | 30 | enum class DataType : int { 31 | FP16 = 0, // Half precision floating point 32 | U8F = 1, // Unsigned byte 33 | INT = 2, // Signed integer (4 byte) 34 | FP32 = 3, // Single precision floating point 35 | I8 = 4, // Signed byte 36 | }; 37 | 38 | StorageOrder order = StorageOrder::NCHW; 39 | DataType dataType = DataType::FP16; 40 | unsigned int numDimensions = 0; 41 | std::vector dims; 42 | std::vector strides; 43 | std::string name; 44 | unsigned int offset = 0; 45 | }; 46 | 47 | DEPTHAI_SERIALIZE_EXT(TensorInfo, order, dataType, numDimensions, dims, strides, name, offset); 48 | 49 | } // namespace dai -------------------------------------------------------------------------------- /include/depthai-shared/common/Timestamp.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // std 4 | #include 5 | #include 6 | 7 | #include "depthai-shared/utility/Serialization.hpp" 8 | 9 | namespace dai { 10 | 11 | /// Timestamp structure 12 | struct Timestamp { 13 | int64_t sec = 0, nsec = 0; 14 | std::chrono::time_point get() const { 15 | using namespace std::chrono; 16 | return time_point{seconds(sec) + nanoseconds(nsec)}; 17 | } 18 | }; 19 | 20 | DEPTHAI_SERIALIZE_EXT(Timestamp, sec, nsec); 21 | 22 | } // namespace dai 23 | -------------------------------------------------------------------------------- /include/depthai-shared/common/UsbSpeed.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // std 4 | #include 5 | 6 | namespace dai { 7 | 8 | /** 9 | * Get USB Speed 10 | */ 11 | 12 | enum class UsbSpeed : int32_t { UNKNOWN, LOW, FULL, HIGH, SUPER, SUPER_PLUS }; 13 | 14 | } // namespace dai 15 | -------------------------------------------------------------------------------- /include/depthai-shared/common/optional.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "depthai-shared/utility/Serialization.hpp" 4 | #include "tl/optional.hpp" 5 | 6 | // tl::optional serialization for nlohmann json 7 | // partial specialization (full specialization works too) 8 | namespace nlohmann { 9 | template 10 | struct adl_serializer> { 11 | static void to_json(json& j, const tl::optional& opt) { // NOLINT this is a specialization, naming conventions don't apply 12 | if(opt == tl::nullopt) { 13 | j = nullptr; 14 | } else { 15 | j = *opt; // this will call adl_serializer::to_json which will 16 | // find the free function to_json in T's namespace! 17 | } 18 | } 19 | 20 | static void from_json(const json& j, tl::optional& opt) { // NOLINT this is a specialization, naming conventions don't apply 21 | if(j.is_null()) { 22 | opt = tl::nullopt; 23 | } else { 24 | opt = j.get(); // same as above, but with 25 | // adl_serializer::from_json 26 | } 27 | } 28 | }; 29 | } // namespace nlohmann 30 | 31 | // tl::optional serialization for libnop 32 | namespace nop { 33 | 34 | // 35 | // Optional encoding formats: 36 | // 37 | // Empty Optional: 38 | // 39 | // +-----+ 40 | // | NIL | 41 | // +-----+ 42 | // 43 | // Non-empty Optional 44 | // 45 | // +---//----+ 46 | // | ELEMENT | 47 | // +---//----+ 48 | // 49 | // Element must be a valid encoding of type T. 50 | // 51 | 52 | template 53 | struct Encoding> : EncodingIO> { 54 | using Type = tl::optional; 55 | 56 | static constexpr EncodingByte Prefix(const Type& value) { 57 | return value ? Encoding::Prefix(*value) : EncodingByte::Empty; 58 | } 59 | 60 | static constexpr std::size_t Size(const Type& value) { 61 | return value ? Encoding::Size(*value) : BaseEncodingSize(EncodingByte::Empty); 62 | } 63 | 64 | static constexpr bool Match(EncodingByte prefix) { 65 | return prefix == EncodingByte::Empty || Encoding::Match(prefix); 66 | } 67 | 68 | template 69 | static constexpr Status WritePayload(EncodingByte prefix, const Type& value, Writer* writer) { 70 | if(value) { 71 | return Encoding::WritePayload(prefix, *value, writer); 72 | } else { 73 | return {}; 74 | } 75 | } 76 | 77 | template 78 | static constexpr Status ReadPayload(EncodingByte prefix, Type* value, Reader* reader) { 79 | if(prefix == EncodingByte::Empty) { 80 | value->reset(); 81 | } else { 82 | T temp; 83 | auto status = Encoding::ReadPayload(prefix, &temp, reader); 84 | if(!status) return status; 85 | 86 | *value = std::move(temp); 87 | } 88 | 89 | return {}; 90 | } 91 | }; 92 | 93 | } // namespace nop 94 | -------------------------------------------------------------------------------- /include/depthai-shared/datatype/DatatypeEnum.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace dai { 6 | 7 | enum class DatatypeEnum : std::int32_t { 8 | Buffer, 9 | ImgFrame, 10 | EncodedFrame, 11 | NNData, 12 | ImageManipConfig, 13 | CameraControl, 14 | ImgDetections, 15 | SpatialImgDetections, 16 | SystemInformation, 17 | SpatialLocationCalculatorConfig, 18 | SpatialLocationCalculatorData, 19 | EdgeDetectorConfig, 20 | AprilTagConfig, 21 | AprilTags, 22 | Tracklets, 23 | IMUData, 24 | StereoDepthConfig, 25 | FeatureTrackerConfig, 26 | ImageAlignConfig, 27 | ToFConfig, 28 | PointCloudConfig, 29 | PointCloudData, 30 | TrackedFeatures, 31 | MessageGroup, 32 | }; 33 | bool isDatatypeSubclassOf(DatatypeEnum parent, DatatypeEnum children); 34 | 35 | } // namespace dai 36 | -------------------------------------------------------------------------------- /include/depthai-shared/datatype/RawAprilTagConfig.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "depthai-shared/datatype/DatatypeEnum.hpp" 7 | #include "depthai-shared/datatype/RawBuffer.hpp" 8 | #include "depthai-shared/utility/Serialization.hpp" 9 | 10 | namespace dai { 11 | 12 | /// RawAprilTags configuration structure 13 | struct RawAprilTagConfig : public RawBuffer { 14 | /** 15 | * Supported AprilTag families. 16 | */ 17 | enum class Family : std::int32_t { TAG_36H11 = 0, TAG_36H10, TAG_25H9, TAG_16H5, TAG_CIR21H7, TAG_STAND41H12 }; 18 | 19 | /** 20 | * AprilTag family. 21 | */ 22 | Family family = Family::TAG_36H11; 23 | 24 | /** 25 | * Detection of quads can be done on a lower-resolution image, 26 | * improving speed at a cost of pose accuracy and a slight 27 | * decrease in detection rate. Decoding the binary payload is 28 | * still done at full resolution. 29 | */ 30 | std::int32_t quadDecimate = 4; 31 | 32 | /** 33 | * What Gaussian blur should be applied to the segmented image. 34 | * Parameter is the standard deviation in pixels. 35 | * Very noisy images benefit from non-zero values (e.g. 0.8). 36 | */ 37 | float quadSigma = 0.0f; 38 | 39 | /** 40 | * When non-zero, the edges of the each quad are adjusted to "snap 41 | * to" strong gradients nearby. This is useful when decimation is 42 | * employed, as it can increase the quality of the initial quad 43 | * estimate substantially. Generally recommended to be on. 44 | * Very computationally inexpensive. Option is ignored if quadDecimate = 1. 45 | */ 46 | bool refineEdges = true; 47 | 48 | /** 49 | * How much sharpening should be done to decoded images? This 50 | * can help decode small tags but may or may not help in odd 51 | * lighting conditions or low light conditions. 52 | * The default value is 0.25. 53 | */ 54 | float decodeSharpening = 0.25f; 55 | 56 | /** 57 | * Max number of error bits that should be corrected. Accepting large numbers of 58 | * corrected errors leads to greatly increased false positive rates. 59 | * As of this implementation, the detector cannot detect tags with 60 | * a hamming distance greater than 2. 61 | */ 62 | std::int32_t maxHammingDistance = 1; 63 | 64 | /** 65 | * AprilTag quad threshold parameters. 66 | */ 67 | struct QuadThresholds { 68 | /** 69 | * Reject quads containing too few pixels. 70 | */ 71 | std::int32_t minClusterPixels = 5; 72 | 73 | /** 74 | * How many corner candidates to consider when segmenting a group of pixels into a quad. 75 | */ 76 | std::int32_t maxNmaxima = 10; 77 | 78 | /** 79 | * Reject quads where pairs of edges have angles that are close to 80 | * straight or close to 180 degrees. Zero means that no quads are 81 | * rejected. (In degrees). 82 | */ 83 | float criticalDegree = 10.f; 84 | 85 | /** 86 | * When fitting lines to the contours, what is the maximum mean 87 | * squared error allowed? This is useful in rejecting contours 88 | * that are far from being quad shaped; rejecting these quads "early" 89 | * saves expensive decoding processing. 90 | */ 91 | float maxLineFitMse = 10.f; 92 | 93 | /** 94 | * When we build our model of black & white pixels, we add an 95 | * extra check that the white model must be (overall) brighter 96 | * than the black model. How much brighter? (in pixel values: [0,255]). 97 | */ 98 | std::int32_t minWhiteBlackDiff = 5; 99 | 100 | /** 101 | * Should the thresholded image be deglitched? Only useful for very noisy images 102 | */ 103 | bool deglitch = false; 104 | 105 | DEPTHAI_SERIALIZE(QuadThresholds, minClusterPixels, maxNmaxima, criticalDegree, maxLineFitMse, minWhiteBlackDiff, deglitch); 106 | }; 107 | 108 | /** 109 | * AprilTag quad threshold parameters. 110 | */ 111 | QuadThresholds quadThresholds; 112 | 113 | void serialize(std::vector& metadata, DatatypeEnum& datatype) const override { 114 | metadata = utility::serialize(*this); 115 | datatype = DatatypeEnum::AprilTagConfig; 116 | }; 117 | 118 | DatatypeEnum getType() const override { 119 | return DatatypeEnum::AprilTagConfig; 120 | } 121 | 122 | DEPTHAI_SERIALIZE(RawAprilTagConfig, family, quadDecimate, quadSigma, refineEdges, decodeSharpening, maxHammingDistance, quadThresholds); 123 | }; 124 | 125 | } // namespace dai 126 | -------------------------------------------------------------------------------- /include/depthai-shared/datatype/RawAprilTags.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | #include "depthai-shared/common/Point2f.hpp" 6 | #include "depthai-shared/datatype/DatatypeEnum.hpp" 7 | #include "depthai-shared/datatype/RawAprilTagConfig.hpp" 8 | #include "depthai-shared/datatype/RawBuffer.hpp" 9 | #include "depthai-shared/utility/Serialization.hpp" 10 | 11 | namespace dai { 12 | 13 | /** 14 | * AprilTag structure. 15 | */ 16 | struct AprilTag { 17 | /** 18 | * The decoded ID of the tag 19 | */ 20 | int id = 0; 21 | 22 | /** 23 | * How many error bits were corrected? Note: accepting large numbers of 24 | * corrected errors leads to greatly increased false positive rates. 25 | * As of this implementation, the detector cannot detect tags with 26 | * a hamming distance greater than 2. 27 | */ 28 | int hamming = 0; 29 | 30 | /** 31 | * A measure of the quality of the binary decoding process; the 32 | * average difference between the intensity of a data bit versus 33 | * the decision threshold. Higher numbers roughly indicate better 34 | * decodes. This is a reasonable measure of detection accuracy 35 | * only for very small tags-- not effective for larger tags (where 36 | * we could have sampled anywhere within a bit cell and still 37 | * gotten a good detection. 38 | */ 39 | float decisionMargin = 0.f; 40 | 41 | /** 42 | * The detected top left coordinates. 43 | */ 44 | Point2f topLeft; 45 | 46 | /** 47 | * The detected top right coordinates. 48 | */ 49 | Point2f topRight; 50 | 51 | /** 52 | * The detected bottom right coordinates. 53 | */ 54 | Point2f bottomRight; 55 | 56 | /** 57 | * The detected bottom left coordinates. 58 | */ 59 | Point2f bottomLeft; 60 | }; 61 | DEPTHAI_SERIALIZE_EXT(AprilTag, id, hamming, decisionMargin, topLeft, topRight, bottomRight, bottomLeft); 62 | 63 | /// RawAprilTags structure 64 | struct RawAprilTags : public RawBuffer { 65 | std::vector aprilTags; 66 | 67 | void serialize(std::vector& metadata, DatatypeEnum& datatype) const override { 68 | metadata = utility::serialize(*this); 69 | datatype = DatatypeEnum::AprilTags; 70 | }; 71 | 72 | DatatypeEnum getType() const override { 73 | return DatatypeEnum::AprilTags; 74 | } 75 | 76 | DEPTHAI_SERIALIZE(RawAprilTags, aprilTags, RawBuffer::sequenceNum, RawBuffer::ts, RawBuffer::tsDevice); 77 | }; 78 | 79 | } // namespace dai 80 | -------------------------------------------------------------------------------- /include/depthai-shared/datatype/RawBuffer.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | #include "depthai-shared/common/Timestamp.hpp" 6 | #include "depthai-shared/datatype/DatatypeEnum.hpp" 7 | #include "depthai-shared/utility/Serialization.hpp" 8 | 9 | namespace dai { 10 | 11 | /// RawBuffer structure 12 | struct RawBuffer { 13 | virtual ~RawBuffer() = default; 14 | std::vector data; 15 | 16 | int64_t sequenceNum = 0; 17 | Timestamp ts = {}; 18 | Timestamp tsDevice = {}; 19 | 20 | virtual void serialize(std::vector& metadata, DatatypeEnum& datatype) const { 21 | metadata = utility::serialize(*this); 22 | datatype = DatatypeEnum::Buffer; 23 | }; 24 | 25 | virtual DatatypeEnum getType() const { 26 | return DatatypeEnum::Buffer; 27 | } 28 | 29 | DEPTHAI_SERIALIZE(RawBuffer, sequenceNum, ts, tsDevice); 30 | }; 31 | 32 | } // namespace dai 33 | -------------------------------------------------------------------------------- /include/depthai-shared/datatype/RawEdgeDetectorConfig.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | #include "RawImgFrame.hpp" 6 | #include "depthai-shared/common/Rect.hpp" 7 | #include "depthai-shared/datatype/DatatypeEnum.hpp" 8 | #include "depthai-shared/datatype/RawBuffer.hpp" 9 | #include "depthai-shared/utility/Serialization.hpp" 10 | 11 | namespace dai { 12 | 13 | /// EdgeDetectorConfigData configuration data structure 14 | struct EdgeDetectorConfigData { 15 | /** 16 | * Used for horizontal gradient computation in 3x3 Sobel filter 17 | * Format - 3x3 matrix, 2nd column must be 0 18 | * Default - +1 0 -1; +2 0 -2; +1 0 -1 19 | */ 20 | std::vector> sobelFilterHorizontalKernel; 21 | /** 22 | * Used for vertical gradient computation in 3x3 Sobel filter 23 | * Format - 3x3 matrix, 2nd row must be 0 24 | * Default - +1 +2 +1; 0 0 0; -1 -2 -1 25 | */ 26 | std::vector> sobelFilterVerticalKernel; 27 | }; 28 | DEPTHAI_SERIALIZE_EXT(EdgeDetectorConfigData, sobelFilterHorizontalKernel, sobelFilterVerticalKernel); 29 | 30 | /// RawEdgeDetectorConfig configuration structure 31 | struct RawEdgeDetectorConfig : public RawBuffer { 32 | EdgeDetectorConfigData config; 33 | 34 | void serialize(std::vector& metadata, DatatypeEnum& datatype) const override { 35 | metadata = utility::serialize(*this); 36 | datatype = DatatypeEnum::EdgeDetectorConfig; 37 | }; 38 | 39 | DatatypeEnum getType() const override { 40 | return DatatypeEnum::EdgeDetectorConfig; 41 | } 42 | 43 | DEPTHAI_SERIALIZE(RawEdgeDetectorConfig, config); 44 | }; 45 | 46 | } // namespace dai 47 | -------------------------------------------------------------------------------- /include/depthai-shared/datatype/RawEncodedFrame.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "depthai-shared/common/Timestamp.hpp" 4 | #include "depthai-shared/datatype/RawBuffer.hpp" 5 | #include "depthai-shared/utility/Serialization.hpp" 6 | 7 | namespace dai { 8 | 9 | struct RawEncodedFrame : public RawBuffer { 10 | enum class Profile : std::uint8_t { JPEG, AVC, HEVC }; 11 | enum class FrameType : std::uint8_t { I, P, B, Unknown }; 12 | 13 | struct CameraSettings { 14 | int32_t exposureTimeUs; 15 | int32_t sensitivityIso; 16 | int32_t lensPosition; 17 | int32_t wbColorTemp; 18 | float lensPositionRaw; 19 | 20 | DEPTHAI_SERIALIZE(CameraSettings, exposureTimeUs, sensitivityIso, lensPosition, wbColorTemp, lensPositionRaw); 21 | }; 22 | 23 | CameraSettings cam; 24 | uint32_t instanceNum = 0; // Which source created this frame (color, mono, ...) 25 | 26 | uint32_t quality; 27 | uint32_t bitrate; 28 | Profile profile; 29 | 30 | bool lossless; // jpeg 31 | FrameType type; // h264 32 | 33 | uint32_t frameOffset = 0; 34 | uint32_t frameSize = 0; 35 | 36 | void serialize(std::vector& metadata, DatatypeEnum& datatype) const override { 37 | metadata = utility::serialize(*this); 38 | datatype = DatatypeEnum::EncodedFrame; 39 | }; 40 | 41 | DatatypeEnum getType() const override { 42 | return DatatypeEnum::EncodedFrame; 43 | } 44 | 45 | DEPTHAI_SERIALIZE(RawEncodedFrame, 46 | cam, 47 | instanceNum, 48 | quality, 49 | bitrate, 50 | profile, 51 | lossless, 52 | type, 53 | frameOffset, 54 | frameSize, 55 | RawBuffer::sequenceNum, 56 | RawBuffer::ts, 57 | RawBuffer::tsDevice); 58 | }; 59 | 60 | } // namespace dai 61 | -------------------------------------------------------------------------------- /include/depthai-shared/datatype/RawIMUData.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "depthai-shared/common/Point3f.hpp" 4 | #include "depthai-shared/common/Timestamp.hpp" 5 | #include "depthai-shared/datatype/RawBuffer.hpp" 6 | #include "depthai-shared/utility/Serialization.hpp" 7 | 8 | namespace dai { 9 | 10 | struct IMUReport { 11 | enum class Accuracy : std::uint8_t { 12 | UNRELIABLE = 0, 13 | LOW = 1, 14 | MEDIUM = 2, 15 | HIGH = 3, 16 | }; 17 | /** 18 | * The sequence number increments once for each report sent. Gaps 19 | * in the sequence numbers indicate missing or dropped reports. 20 | * Max value 2^32 after which resets to 0. 21 | */ 22 | int32_t sequence = 0; 23 | 24 | /** Accuracy of sensor */ 25 | Accuracy accuracy = Accuracy::UNRELIABLE; 26 | 27 | /** Generation timestamp, synced to host time */ 28 | Timestamp timestamp = {}; 29 | 30 | /** Generation timestamp, direct device monotonic clock */ 31 | Timestamp tsDevice = {}; 32 | 33 | /** 34 | * Retrieves timestamp related to dai::Clock::now() 35 | */ 36 | std::chrono::time_point getTimestamp() const { 37 | return timestamp.get(); 38 | } 39 | 40 | /** 41 | * Retrieves timestamp directly captured from device's monotonic clock, 42 | * not synchronized to host time. Used mostly for debugging 43 | */ 44 | std::chrono::time_point getTimestampDevice() const { 45 | return tsDevice.get(); 46 | } 47 | 48 | /** 49 | * Retrieves IMU report sequence number 50 | */ 51 | int32_t getSequenceNum() const { 52 | return sequence; 53 | } 54 | }; 55 | DEPTHAI_SERIALIZE_EXT(IMUReport, sequence, accuracy, timestamp, tsDevice); 56 | 57 | /** 58 | * @brief Accelerometer 59 | * 60 | * Units are [m/s^2] 61 | */ 62 | struct IMUReportAccelerometer : public IMUReport { 63 | float x = 0; 64 | float y = 0; 65 | float z = 0; 66 | }; 67 | DEPTHAI_SERIALIZE_EXT(IMUReportAccelerometer, x, y, z, sequence, accuracy, timestamp, tsDevice); 68 | 69 | /** 70 | * @brief Gyroscope 71 | * 72 | * Units are [rad/s] 73 | */ 74 | struct IMUReportGyroscope : public IMUReport { 75 | float x = 0; 76 | float y = 0; 77 | float z = 0; 78 | }; 79 | DEPTHAI_SERIALIZE_EXT(IMUReportGyroscope, x, y, z, sequence, accuracy, timestamp, tsDevice); 80 | 81 | /** 82 | * @brief Magnetic field 83 | * 84 | * Units are [uTesla] 85 | */ 86 | struct IMUReportMagneticField : public IMUReport { 87 | float x = 0; 88 | float y = 0; 89 | float z = 0; 90 | }; 91 | DEPTHAI_SERIALIZE_EXT(IMUReportMagneticField, x, y, z, sequence, accuracy, timestamp, tsDevice); 92 | 93 | /** 94 | * @brief Rotation Vector with Accuracy 95 | * 96 | * Contains quaternion components: i,j,k,real 97 | */ 98 | struct IMUReportRotationVectorWAcc : public IMUReport { 99 | float i = 0; /**< @brief Quaternion component i */ 100 | float j = 0; /**< @brief Quaternion component j */ 101 | float k = 0; /**< @brief Quaternion component k */ 102 | float real = 0; /**< @brief Quaternion component, real */ 103 | float rotationVectorAccuracy = 0; /**< @brief Accuracy estimate [radians], 0 means no estimate */ 104 | }; 105 | DEPTHAI_SERIALIZE_EXT(IMUReportRotationVectorWAcc, i, j, k, real, rotationVectorAccuracy, sequence, accuracy, timestamp, tsDevice); 106 | 107 | #if 0 108 | 109 | /** 110 | * @brief Uncalibrated gyroscope 111 | * 112 | * See the SH-2 Reference Manual for more detail. 113 | */ 114 | struct IMUReportGyroscopeUncalibrated : public IMUReport { 115 | /* Units are rad/s */ 116 | float x = 0; /**< @brief [rad/s] */ 117 | float y = 0; /**< @brief [rad/s] */ 118 | float z = 0; /**< @brief [rad/s] */ 119 | float biasX = 0; /**< @brief [rad/s] */ 120 | float biasY = 0; /**< @brief [rad/s] */ 121 | float biasZ = 0; /**< @brief [rad/s] */ 122 | }; 123 | DEPTHAI_SERIALIZE_EXT(IMUReportGyroscopeUncalibrated, x, y, z, biasX, biasY, biasZ, sequence, accuracy, timestamp, tsDevice); 124 | 125 | 126 | 127 | /** 128 | * @brief Uncalibrated magnetic field 129 | * 130 | * See the SH-2 Reference Manual for more detail. 131 | */ 132 | struct IMUReportMagneticFieldUncalibrated : public IMUReport { 133 | /* Units are uTesla */ 134 | float x = 0; /**< @brief [uTesla] */ 135 | float y = 0; /**< @brief [uTesla] */ 136 | float z = 0; /**< @brief [uTesla] */ 137 | float biasX = 0; /**< @brief [uTesla] */ 138 | float biasY = 0; /**< @brief [uTesla] */ 139 | float biasZ = 0; /**< @brief [uTesla] */ 140 | }; 141 | DEPTHAI_SERIALIZE_EXT(IMUReportMagneticFieldUncalibrated, x, y, z, biasX, biasY, biasZ, sequence, accuracy, timestamp, tsDevice); 142 | 143 | 144 | 145 | /** 146 | * @brief Rotation Vector 147 | * 148 | * See the SH-2 Reference Manual for more detail. 149 | */ 150 | struct IMUReportRotationVector : public IMUReport { 151 | float i = 0; /**< @brief Quaternion component i */ 152 | float j = 0; /**< @brief Quaternion component j */ 153 | float k = 0; /**< @brief Quaternion component k */ 154 | float real = 0; /**< @brief Quaternion component real */ 155 | }; 156 | DEPTHAI_SERIALIZE_EXT(IMUReportRotationVector, i, j, k, real, sequence, accuracy, timestamp, tsDevice); 157 | 158 | 159 | /** 160 | * @brief Gyro integrated rotation vector 161 | * 162 | * See SH-2 Reference Manual for details. 163 | */ 164 | struct IMUReportGyroIntegratedRV : public IMUReport { 165 | float i = 0; /**< @brief Quaternion component i */ 166 | float j = 0; /**< @brief Quaternion component j */ 167 | float k = 0; /**< @brief Quaternion component k */ 168 | float real = 0; /**< @brief Quaternion component real */ 169 | float angVelX = 0; /**< @brief Angular velocity about x [rad/s] */ 170 | float angVelY = 0; /**< @brief Angular velocity about y [rad/s] */ 171 | float angVelZ = 0; /**< @brief Angular velocity about z [rad/s] */ 172 | }; 173 | DEPTHAI_SERIALIZE_EXT(IMUReportGyroIntegratedRV, i, j, k, real, angVelX, angVelY, angVelZ, sequence, accuracy, timestamp, tsDevice); 174 | 175 | #endif 176 | 177 | /** 178 | * IMU output 179 | * 180 | * Contains combined output for all possible modes. Only the enabled outputs are populated. 181 | */ 182 | struct IMUPacket { 183 | IMUReportAccelerometer acceleroMeter; 184 | IMUReportGyroscope gyroscope; 185 | IMUReportMagneticField magneticField; 186 | IMUReportRotationVectorWAcc rotationVector; 187 | 188 | #if 0 189 | IMUReportAccelerometer rawAcceleroMeter; 190 | 191 | IMUReportAccelerometer linearAcceleroMeter; 192 | IMUReportAccelerometer gravity; 193 | 194 | IMUReportGyroscope rawGyroscope; 195 | IMUReportGyroscopeUncalibrated gyroscopeUncalibrated; 196 | 197 | IMUReportMagneticField rawMagneticField; 198 | IMUReportMagneticFieldUncalibrated magneticFieldUncalibrated; 199 | 200 | IMUReportRotationVector gameRotationVector; 201 | IMUReportRotationVectorWAcc geoMagRotationVector; 202 | 203 | IMUReportRotationVectorWAcc arvrStabilizedRotationVector; 204 | IMUReportRotationVector arvrStabilizedGameRotationVector; 205 | IMUReportGyroIntegratedRV gyroIntegratedRotationVector; 206 | #endif 207 | }; 208 | 209 | DEPTHAI_SERIALIZE_EXT(IMUPacket, acceleroMeter, gyroscope, magneticField, rotationVector); 210 | 211 | struct RawIMUData : public RawBuffer { 212 | std::vector packets; 213 | 214 | void serialize(std::vector& metadata, DatatypeEnum& datatype) const override { 215 | metadata = utility::serialize(*this); 216 | datatype = DatatypeEnum::IMUData; 217 | }; 218 | 219 | DatatypeEnum getType() const override { 220 | return DatatypeEnum::IMUData; 221 | } 222 | 223 | DEPTHAI_SERIALIZE(RawIMUData, packets, RawBuffer::sequenceNum, RawBuffer::ts, RawBuffer::tsDevice); 224 | }; 225 | 226 | } // namespace dai 227 | -------------------------------------------------------------------------------- /include/depthai-shared/datatype/RawImageAlignConfig.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | #include "RawImgFrame.hpp" 6 | #include "depthai-shared/datatype/DatatypeEnum.hpp" 7 | #include "depthai-shared/datatype/RawBuffer.hpp" 8 | #include "depthai-shared/utility/Serialization.hpp" 9 | 10 | namespace dai { 11 | 12 | /// RawImageAlignConfig configuration structure 13 | struct RawImageAlignConfig : public RawBuffer { 14 | /** 15 | * Optional static depth plane to align to, in depth units, by default millimeters 16 | */ 17 | uint16_t staticDepthPlane = 0; 18 | 19 | void serialize(std::vector& metadata, DatatypeEnum& datatype) const override { 20 | metadata = utility::serialize(*this); 21 | datatype = DatatypeEnum::ImageAlignConfig; 22 | }; 23 | 24 | DEPTHAI_SERIALIZE(RawImageAlignConfig, staticDepthPlane); 25 | }; 26 | 27 | } // namespace dai -------------------------------------------------------------------------------- /include/depthai-shared/datatype/RawImageManipConfig.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | #include "RawImgFrame.hpp" 6 | #include "depthai-shared/datatype/DatatypeEnum.hpp" 7 | #include "depthai-shared/datatype/RawBuffer.hpp" 8 | 9 | // shared 10 | #include "depthai-shared/common/Colormap.hpp" 11 | #include "depthai-shared/common/Interpolation.hpp" 12 | #include "depthai-shared/common/Point2f.hpp" 13 | #include "depthai-shared/common/RotatedRect.hpp" 14 | #include "depthai-shared/common/Size2f.hpp" 15 | #include "depthai-shared/utility/Serialization.hpp" 16 | 17 | namespace dai { 18 | 19 | /// RawImageManipConfig structure 20 | struct RawImageManipConfig : public RawBuffer { 21 | // NNData data is in PoBuf 22 | struct CropRect { 23 | // Normalized range 0-1 24 | float xmin = 0.0f, ymin = 0.0f, xmax = 0.0f, ymax = 0.0f; 25 | 26 | DEPTHAI_SERIALIZE(CropRect, xmin, ymin, xmax, ymax); 27 | }; 28 | 29 | struct CropConfig { 30 | CropRect cropRect; 31 | RotatedRect cropRotatedRect; 32 | 33 | bool enableCenterCropRectangle = false; 34 | // if enableCenterCropRectangle -> automatically calculated crop parameters 35 | float cropRatio = 1.0f, widthHeightAspectRatio = 1.0f; 36 | 37 | bool enableRotatedRect = false; 38 | 39 | // Range 0..1 by default. Set 'false' to specify in pixels 40 | bool normalizedCoords = true; 41 | 42 | DEPTHAI_SERIALIZE( 43 | CropConfig, cropRect, cropRotatedRect, enableCenterCropRectangle, cropRatio, widthHeightAspectRatio, enableRotatedRect, normalizedCoords); 44 | }; 45 | 46 | struct ResizeConfig { 47 | int width = 0, height = 0; 48 | bool lockAspectRatioFill = false; 49 | char bgRed = 0, bgGreen = 0, bgBlue = 0; 50 | 51 | // clockwise order, pt[0] is mapped to the top-left output corner 52 | std::vector warpFourPoints; 53 | bool normalizedCoords = true; 54 | bool enableWarp4pt = false; 55 | 56 | std::vector warpMatrix3x3; 57 | bool enableWarpMatrix = false; 58 | 59 | // Warp background / border mode: replicates pixels if true, 60 | // otherwise fills with a constant color defined by: bgRed, bgGreen, bgBlue 61 | bool warpBorderReplicate = false; 62 | 63 | // clockwise 64 | float rotationAngleDeg; 65 | bool enableRotation = false; 66 | 67 | /** 68 | * Whether to keep aspect ratio of input or not 69 | */ 70 | bool keepAspectRatio = true; 71 | 72 | DEPTHAI_SERIALIZE(ResizeConfig, 73 | width, 74 | height, 75 | lockAspectRatioFill, 76 | bgRed, 77 | bgGreen, 78 | bgBlue, 79 | warpFourPoints, 80 | normalizedCoords, 81 | enableWarp4pt, 82 | warpMatrix3x3, 83 | enableWarpMatrix, 84 | warpBorderReplicate, 85 | rotationAngleDeg, 86 | enableRotation, 87 | keepAspectRatio); 88 | }; 89 | 90 | struct FormatConfig { 91 | RawImgFrame::Type type = RawImgFrame::Type::NONE; 92 | bool flipHorizontal = false; 93 | bool flipVertical = false; 94 | Colormap colormap = Colormap::NONE; 95 | int colormapMin = 0; 96 | int colormapMax = 255; 97 | 98 | DEPTHAI_SERIALIZE(FormatConfig, type, flipHorizontal, flipVertical, colormap, colormapMin, colormapMax); 99 | }; 100 | 101 | CropConfig cropConfig; 102 | ResizeConfig resizeConfig; 103 | FormatConfig formatConfig; 104 | 105 | bool enableCrop = false; 106 | bool enableResize = false; 107 | bool enableFormat = false; 108 | 109 | // Usable with runtime config only, 110 | // when ImageManipProperties.inputConfig.setWaitForMessage(true) is set 111 | bool reusePreviousImage = false; 112 | bool skipCurrentImage = false; 113 | 114 | /// Interpolation type to use 115 | Interpolation interpolation = Interpolation::AUTO; 116 | 117 | void serialize(std::vector& metadata, DatatypeEnum& datatype) const override { 118 | metadata = utility::serialize(*this); 119 | datatype = DatatypeEnum::ImageManipConfig; 120 | }; 121 | 122 | DatatypeEnum getType() const override { 123 | return DatatypeEnum::ImageManipConfig; 124 | } 125 | 126 | DEPTHAI_SERIALIZE(RawImageManipConfig, 127 | cropConfig, 128 | resizeConfig, 129 | formatConfig, 130 | enableCrop, 131 | enableResize, 132 | enableFormat, 133 | reusePreviousImage, 134 | skipCurrentImage, 135 | interpolation); 136 | }; 137 | 138 | } // namespace dai 139 | -------------------------------------------------------------------------------- /include/depthai-shared/datatype/RawImgDetections.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "depthai-shared/common/Point3f.hpp" 4 | #include "depthai-shared/datatype/RawBuffer.hpp" 5 | #include "depthai-shared/utility/Serialization.hpp" 6 | 7 | namespace dai { 8 | 9 | /// ImgDetection structure 10 | struct ImgDetection { 11 | uint32_t label = 0; 12 | float confidence = 0.f; 13 | float xmin = 0.f; 14 | float ymin = 0.f; 15 | float xmax = 0.f; 16 | float ymax = 0.f; 17 | }; 18 | 19 | DEPTHAI_SERIALIZE_EXT(ImgDetection, label, confidence, xmin, ymin, xmax, ymax); 20 | 21 | /// RawImgDetections structure 22 | struct RawImgDetections : public RawBuffer { 23 | std::vector detections; 24 | 25 | void serialize(std::vector& metadata, DatatypeEnum& datatype) const override { 26 | metadata = utility::serialize(*this); 27 | datatype = DatatypeEnum::ImgDetections; 28 | }; 29 | 30 | DatatypeEnum getType() const override { 31 | return DatatypeEnum::ImgDetections; 32 | } 33 | 34 | DEPTHAI_SERIALIZE(RawImgDetections, detections, RawBuffer::sequenceNum, RawBuffer::ts, RawBuffer::tsDevice); 35 | }; 36 | 37 | } // namespace dai 38 | -------------------------------------------------------------------------------- /include/depthai-shared/datatype/RawImgFrame.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "depthai-shared/common/FrameEvent.hpp" 6 | #include "depthai-shared/datatype/RawBuffer.hpp" 7 | #include "depthai-shared/utility/Serialization.hpp" 8 | 9 | namespace dai { 10 | 11 | /// RawImgFrame structure 12 | struct RawImgFrame : public RawBuffer { 13 | enum class Type { 14 | YUV422i, // interleaved 8 bit 15 | YUV444p, // planar 4:4:4 format 16 | YUV420p, // planar 4:2:0 format 17 | YUV422p, // planar 8 bit 18 | YUV400p, // 8-bit greyscale 19 | RGBA8888, // RGBA interleaved stored in 32 bit word 20 | RGB161616, // Planar 16 bit RGB data 21 | RGB888p, // Planar 8 bit RGB data 22 | BGR888p, // Planar 8 bit BGR data 23 | RGB888i, // Interleaved 8 bit RGB data 24 | BGR888i, // Interleaved 8 bit BGR data 25 | LUT2, // 1 bit per pixel, Lookup table (used for graphics layers) 26 | LUT4, // 2 bits per pixel, Lookup table (used for graphics layers) 27 | LUT16, // 4 bits per pixel, Lookup table (used for graphics layers) 28 | RAW16, // save any raw type (8, 10, 12bit) on 16 bits 29 | RAW14, // 14bit value in 16bit storage 30 | RAW12, // 12bit value in 16bit storage 31 | RAW10, // 10bit value in 16bit storage 32 | RAW8, 33 | PACK10, // SIPP 10bit packed format 34 | PACK12, // SIPP 12bit packed format 35 | YUV444i, 36 | NV12, 37 | NV21, 38 | BITSTREAM, // used for video encoder bitstream 39 | HDR, 40 | RGBF16F16F16p, // Planar FP16 RGB data 41 | BGRF16F16F16p, // Planar FP16 BGR data 42 | RGBF16F16F16i, // Interleaved FP16 RGB data 43 | BGRF16F16F16i, // Interleaved FP16 BGR data 44 | GRAY8, // 8 bit grayscale (1 plane) 45 | GRAYF16, // FP16 grayscale (normalized) 46 | NONE 47 | }; 48 | 49 | static constexpr int typeToBpp(Type type) { 50 | switch(type) { 51 | case Type::YUV422i: 52 | return 1; 53 | break; 54 | case Type::YUV444p: 55 | return 1; 56 | break; 57 | case Type::YUV420p: 58 | return 1; 59 | break; 60 | case Type::YUV422p: 61 | return 1; 62 | break; 63 | case Type::YUV400p: 64 | return 1; 65 | break; 66 | case Type::RGBA8888: 67 | return 1; 68 | break; 69 | case Type::RGB161616: 70 | return 2; 71 | break; 72 | case Type::RGB888p: 73 | return 1; 74 | break; 75 | case Type::BGR888p: 76 | return 1; 77 | break; 78 | case Type::RGB888i: 79 | return 1; 80 | break; 81 | case Type::BGR888i: 82 | return 1; 83 | break; 84 | case Type::RGBF16F16F16p: 85 | return 2; 86 | break; 87 | case Type::BGRF16F16F16p: 88 | return 2; 89 | break; 90 | case Type::RGBF16F16F16i: 91 | return 2; 92 | break; 93 | case Type::BGRF16F16F16i: 94 | return 2; 95 | break; 96 | case Type::GRAY8: 97 | return 1; 98 | break; 99 | case Type::GRAYF16: 100 | return 2; 101 | break; 102 | case Type::LUT2: 103 | return 1; 104 | break; 105 | case Type::LUT4: 106 | return 1; 107 | break; 108 | case Type::LUT16: 109 | return 1; 110 | break; 111 | case Type::RAW16: 112 | return 2; 113 | break; 114 | case Type::RAW14: 115 | return 2; 116 | break; 117 | case Type::RAW12: 118 | return 2; 119 | break; 120 | case Type::RAW10: 121 | return 2; 122 | break; 123 | case Type::RAW8: 124 | return 1; 125 | break; 126 | case Type::PACK10: 127 | return 2; 128 | break; 129 | case Type::PACK12: 130 | return 2; 131 | break; 132 | case Type::YUV444i: 133 | return 1; 134 | break; 135 | case Type::NV12: 136 | return 1; 137 | break; 138 | case Type::NV21: 139 | return 1; 140 | break; 141 | case Type::BITSTREAM: 142 | return 1; 143 | break; 144 | case Type::HDR: 145 | return 1; 146 | break; 147 | case Type::NONE: 148 | return 0; 149 | break; 150 | } 151 | return 0; 152 | } 153 | 154 | struct Specs { 155 | Type type = Type::NONE; 156 | unsigned int width; // width in pixels 157 | unsigned int height; // height in pixels 158 | unsigned int stride; // defined as distance in bytes from pix(y,x) to pix(y+1,x) 159 | unsigned int bytesPP; // bytes per pixel (for LUT types 1) 160 | unsigned int p1Offset; // Offset to first plane 161 | unsigned int p2Offset; // Offset to second plane 162 | unsigned int p3Offset; // Offset to third plane 163 | 164 | DEPTHAI_SERIALIZE(Specs, type, width, height, stride, bytesPP, p1Offset, p2Offset, p3Offset); 165 | }; 166 | struct CameraSettings { 167 | int32_t exposureTimeUs; 168 | int32_t sensitivityIso; 169 | int32_t lensPosition; 170 | int32_t wbColorTemp; 171 | float lensPositionRaw; 172 | 173 | DEPTHAI_SERIALIZE(CameraSettings, exposureTimeUs, sensitivityIso, lensPosition, wbColorTemp, lensPositionRaw); 174 | }; 175 | 176 | Specs fb = {}; 177 | CameraSettings cam; 178 | uint32_t category = 0; // 179 | uint32_t instanceNum = 0; // Which source created this frame (color, mono, ...) 180 | dai::FrameEvent event = dai::FrameEvent::NONE; 181 | 182 | void serialize(std::vector& metadata, DatatypeEnum& datatype) const override { 183 | metadata = utility::serialize(*this); 184 | datatype = DatatypeEnum::ImgFrame; 185 | }; 186 | 187 | DatatypeEnum getType() const override { 188 | return DatatypeEnum::ImgFrame; 189 | } 190 | 191 | DEPTHAI_SERIALIZE(RawImgFrame, fb, cam, category, instanceNum, RawBuffer::sequenceNum, RawBuffer::ts, RawBuffer::tsDevice); 192 | }; 193 | 194 | } // namespace dai 195 | -------------------------------------------------------------------------------- /include/depthai-shared/datatype/RawMessageGroup.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "depthai-shared/datatype/DatatypeEnum.hpp" 6 | #include "depthai-shared/datatype/RawBuffer.hpp" 7 | 8 | namespace dai { 9 | 10 | struct RawGroupMessage { 11 | std::shared_ptr buffer; 12 | uint32_t index = 0; 13 | 14 | DEPTHAI_SERIALIZE(RawGroupMessage, index); 15 | }; 16 | 17 | } // namespace dai 18 | 19 | namespace dai { 20 | 21 | struct RawMessageGroup : public RawBuffer { 22 | std::unordered_map group; 23 | 24 | public: 25 | void serialize(std::vector& metadata, DatatypeEnum& datatype) const override { 26 | metadata = utility::serialize(*this); 27 | datatype = DatatypeEnum::MessageGroup; 28 | }; 29 | 30 | DatatypeEnum getType() const override { 31 | return DatatypeEnum::MessageGroup; 32 | } 33 | 34 | DEPTHAI_SERIALIZE(RawMessageGroup, group, RawBuffer::ts, RawBuffer::tsDevice, RawBuffer::sequenceNum); 35 | }; 36 | 37 | } // namespace dai 38 | -------------------------------------------------------------------------------- /include/depthai-shared/datatype/RawNNData.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "depthai-shared/common/TensorInfo.hpp" 4 | #include "depthai-shared/datatype/RawBuffer.hpp" 5 | #include "depthai-shared/utility/Serialization.hpp" 6 | 7 | namespace dai { 8 | 9 | /// RawNNData structure 10 | struct RawNNData : public RawBuffer { 11 | // NNData data is in PoBuf 12 | std::vector tensors; 13 | unsigned int batchSize; 14 | 15 | void serialize(std::vector& metadata, DatatypeEnum& datatype) const override { 16 | metadata = utility::serialize(*this); 17 | datatype = DatatypeEnum::NNData; 18 | }; 19 | 20 | DatatypeEnum getType() const override { 21 | return DatatypeEnum::NNData; 22 | } 23 | 24 | DEPTHAI_SERIALIZE(RawNNData, tensors, batchSize, RawBuffer::sequenceNum, RawBuffer::ts, RawBuffer::tsDevice); 25 | }; 26 | 27 | } // namespace dai 28 | -------------------------------------------------------------------------------- /include/depthai-shared/datatype/RawPointCloudConfig.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | #include "RawImgFrame.hpp" 7 | #include "depthai-shared/datatype/DatatypeEnum.hpp" 8 | #include "depthai-shared/datatype/RawBuffer.hpp" 9 | #include "depthai-shared/utility/Serialization.hpp" 10 | 11 | namespace dai { 12 | 13 | /// RawPointCloudConfig configuration structure 14 | struct RawPointCloudConfig : public RawBuffer { 15 | bool sparse = false; 16 | 17 | std::array, 4> transformationMatrix = {{{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}}}; 18 | 19 | void serialize(std::vector& metadata, DatatypeEnum& datatype) const override { 20 | metadata = utility::serialize(*this); 21 | datatype = DatatypeEnum::PointCloudConfig; 22 | }; 23 | 24 | DatatypeEnum getType() const override { 25 | return DatatypeEnum::PointCloudConfig; 26 | } 27 | 28 | DEPTHAI_SERIALIZE(RawPointCloudConfig, sparse, transformationMatrix); 29 | }; 30 | 31 | } // namespace dai 32 | -------------------------------------------------------------------------------- /include/depthai-shared/datatype/RawPointCloudData.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "depthai-shared/datatype/DatatypeEnum.hpp" 6 | #include "depthai-shared/datatype/RawBuffer.hpp" 7 | 8 | namespace dai { 9 | 10 | struct RawPointCloudData : public RawBuffer { 11 | unsigned int width; // width in pixels 12 | unsigned int height; // height in pixels 13 | uint32_t instanceNum = 0; // Which source created this frame (color, mono, ...) 14 | float minx, miny, minz; 15 | float maxx, maxy, maxz; 16 | bool sparse = false; 17 | 18 | public: 19 | void serialize(std::vector& metadata, DatatypeEnum& datatype) const override { 20 | metadata = utility::serialize(*this); 21 | datatype = DatatypeEnum::PointCloudData; 22 | }; 23 | 24 | DatatypeEnum getType() const override { 25 | return DatatypeEnum::PointCloudData; 26 | } 27 | 28 | DEPTHAI_SERIALIZE( 29 | RawPointCloudData, width, height, minx, miny, minz, maxx, maxy, maxz, sparse, instanceNum, RawBuffer::ts, RawBuffer::tsDevice, RawBuffer::sequenceNum); 30 | }; 31 | 32 | } // namespace dai 33 | -------------------------------------------------------------------------------- /include/depthai-shared/datatype/RawSpatialImgDetections.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "RawImgDetections.hpp" 4 | #include "depthai-shared/common/Point3f.hpp" 5 | #include "depthai-shared/datatype/RawSpatialLocationCalculatorConfig.hpp" 6 | #include "depthai-shared/utility/Serialization.hpp" 7 | 8 | namespace dai { 9 | 10 | /** 11 | * SpatialImgDetection structure 12 | * 13 | * Contains image detection results together with spatial location data. 14 | */ 15 | struct SpatialImgDetection : public ImgDetection { 16 | Point3f spatialCoordinates; 17 | SpatialLocationCalculatorConfigData boundingBoxMapping; 18 | }; 19 | 20 | DEPTHAI_SERIALIZE_EXT(SpatialImgDetection, label, confidence, xmin, ymin, xmax, ymax, spatialCoordinates, boundingBoxMapping); 21 | 22 | /// RawSpatialImgDetections structure 23 | struct RawSpatialImgDetections : public RawBuffer { 24 | std::vector detections; 25 | 26 | void serialize(std::vector& metadata, DatatypeEnum& datatype) const override { 27 | metadata = utility::serialize(*this); 28 | datatype = DatatypeEnum::SpatialImgDetections; 29 | }; 30 | 31 | DatatypeEnum getType() const override { 32 | return DatatypeEnum::SpatialImgDetections; 33 | } 34 | 35 | DEPTHAI_SERIALIZE(RawSpatialImgDetections, detections, RawBuffer::sequenceNum, RawBuffer::ts, RawBuffer::tsDevice); 36 | }; 37 | 38 | } // namespace dai 39 | -------------------------------------------------------------------------------- /include/depthai-shared/datatype/RawSpatialLocationCalculatorConfig.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | #include "RawImgFrame.hpp" 6 | #include "depthai-shared/common/Rect.hpp" 7 | #include "depthai-shared/datatype/DatatypeEnum.hpp" 8 | #include "depthai-shared/datatype/RawBuffer.hpp" 9 | #include "depthai-shared/utility/Serialization.hpp" 10 | 11 | namespace dai { 12 | 13 | /** 14 | * SpatialLocation configuration thresholds structure 15 | * 16 | * Contains configuration data for lower and upper threshold in depth units (millimeter by default) for ROI. 17 | * Values outside of threshold range will be ignored when calculating spatial coordinates from depth map. 18 | */ 19 | struct SpatialLocationCalculatorConfigThresholds { 20 | /** 21 | * Values less or equal than this threshold are not taken into calculation. 22 | */ 23 | uint32_t lowerThreshold = 0; 24 | /** 25 | * Values greater or equal than this threshold are not taken into calculation. 26 | */ 27 | uint32_t upperThreshold = 65535; 28 | }; 29 | DEPTHAI_SERIALIZE_EXT(SpatialLocationCalculatorConfigThresholds, lowerThreshold, upperThreshold); 30 | 31 | /** 32 | * SpatialLocationCalculatorAlgorithm configuration modes 33 | * 34 | * Contains calculation method used to obtain spatial locations. 35 | */ 36 | enum class SpatialLocationCalculatorAlgorithm : uint32_t { AVERAGE = 0, MEAN = AVERAGE, MIN, MAX, MODE, MEDIAN }; 37 | 38 | /// SpatialLocation configuration data structure 39 | struct SpatialLocationCalculatorConfigData { 40 | static constexpr std::int32_t AUTO = -1; 41 | 42 | /** 43 | * Region of interest for spatial location calculation. 44 | */ 45 | Rect roi; 46 | /** 47 | * Upper and lower thresholds for depth values to take into consideration. 48 | */ 49 | SpatialLocationCalculatorConfigThresholds depthThresholds; 50 | /** 51 | * Calculation method used to obtain spatial locations 52 | * Average/mean: the average of ROI is used for calculation. 53 | * Min: the minimum value inside ROI is used for calculation. 54 | * Max: the maximum value inside ROI is used for calculation. 55 | * Mode: the most frequent value inside ROI is used for calculation. 56 | * Median: the median value inside ROI is used for calculation. 57 | * Default: median. 58 | */ 59 | SpatialLocationCalculatorAlgorithm calculationAlgorithm = SpatialLocationCalculatorAlgorithm::MEDIAN; 60 | /** 61 | * Step size for calculation. 62 | * Step size 1 means that every pixel is taken into calculation, size 2 means every second etc. 63 | * Default value AUTO: for AVERAGE, MIN, MAX step size is 1; for MODE/MEDIAN it's 2. 64 | */ 65 | std::int32_t stepSize = AUTO; 66 | }; 67 | DEPTHAI_SERIALIZE_EXT(SpatialLocationCalculatorConfigData, roi, depthThresholds, calculationAlgorithm, stepSize); 68 | 69 | /// RawSpatialLocation configuration structure 70 | struct RawSpatialLocationCalculatorConfig : public RawBuffer { 71 | std::vector config; 72 | 73 | void serialize(std::vector& metadata, DatatypeEnum& datatype) const override { 74 | metadata = utility::serialize(*this); 75 | datatype = DatatypeEnum::SpatialLocationCalculatorConfig; 76 | }; 77 | 78 | DatatypeEnum getType() const override { 79 | return DatatypeEnum::SpatialLocationCalculatorConfig; 80 | } 81 | 82 | DEPTHAI_SERIALIZE(RawSpatialLocationCalculatorConfig, config); 83 | }; 84 | 85 | } // namespace dai 86 | -------------------------------------------------------------------------------- /include/depthai-shared/datatype/RawSpatialLocations.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | #include "RawSpatialLocationCalculatorConfig.hpp" 6 | #include "depthai-shared/common/Point3f.hpp" 7 | #include "depthai-shared/common/Rect.hpp" 8 | #include "depthai-shared/datatype/DatatypeEnum.hpp" 9 | #include "depthai-shared/datatype/RawBuffer.hpp" 10 | #include "depthai-shared/utility/Serialization.hpp" 11 | 12 | namespace dai { 13 | 14 | /** 15 | * SpatialLocations structure 16 | * 17 | * Contains configuration data, average depth for the calculated ROI on depth map. 18 | * Together with spatial coordinates: x,y,z relative to the center of depth map. 19 | * Units are in depth units (millimeter by default). 20 | */ 21 | struct SpatialLocations { 22 | /** 23 | * Configuration for selected ROI 24 | */ 25 | SpatialLocationCalculatorConfigData config; 26 | /** 27 | * Average of depth values inside the ROI between the specified thresholds in config. 28 | * Calculated only if calculation method is set to AVERAGE or MIN oR MAX. 29 | */ 30 | float depthAverage = 0.f; 31 | /** 32 | * Most frequent of depth values inside the ROI between the specified thresholds in config. 33 | * Calculated only if calculation method is set to MODE. 34 | */ 35 | float depthMode = 0.f; 36 | /** 37 | * Median of depth values inside the ROI between the specified thresholds in config. 38 | * Calculated only if calculation method is set to MEDIAN. 39 | */ 40 | float depthMedian = 0.f; 41 | /** 42 | * Minimum of depth values inside the ROI between the specified thresholds in config. 43 | * Calculated only if calculation method is set to AVERAGE or MIN oR MAX. 44 | */ 45 | std::uint16_t depthMin = 0; 46 | /** 47 | * Maximum of depth values inside the ROI between the specified thresholds in config. 48 | * Calculated only if calculation method is set to AVERAGE or MIN oR MAX. 49 | */ 50 | std::uint16_t depthMax = 0; 51 | /** 52 | * Number of depth values used in calculations. 53 | */ 54 | std::uint32_t depthAveragePixelCount = 0; 55 | /** 56 | * Spatial coordinates - x,y,z; x,y are the relative positions of the center of ROI to the center of depth map 57 | */ 58 | Point3f spatialCoordinates; 59 | }; 60 | DEPTHAI_SERIALIZE_EXT(SpatialLocations, config, depthAverage, depthMode, depthMedian, depthMin, depthMax, depthAveragePixelCount, spatialCoordinates); 61 | 62 | /// RawSpatialLocations structure 63 | struct RawSpatialLocations : public RawBuffer { 64 | std::vector spatialLocations; 65 | 66 | void serialize(std::vector& metadata, DatatypeEnum& datatype) const override { 67 | metadata = utility::serialize(*this); 68 | datatype = DatatypeEnum::SpatialLocationCalculatorData; 69 | }; 70 | 71 | DatatypeEnum getType() const override { 72 | return DatatypeEnum::SpatialLocationCalculatorData; 73 | } 74 | 75 | DEPTHAI_SERIALIZE(RawSpatialLocations, spatialLocations, RawBuffer::sequenceNum, RawBuffer::ts, RawBuffer::tsDevice); 76 | }; 77 | 78 | } // namespace dai 79 | -------------------------------------------------------------------------------- /include/depthai-shared/datatype/RawSystemInformation.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | #include "depthai-shared/common/ChipTemperature.hpp" 6 | #include "depthai-shared/common/CpuUsage.hpp" 7 | #include "depthai-shared/common/MemoryInfo.hpp" 8 | #include "depthai-shared/datatype/DatatypeEnum.hpp" 9 | #include "depthai-shared/datatype/RawBuffer.hpp" 10 | #include "depthai-shared/utility/Serialization.hpp" 11 | 12 | namespace dai { 13 | /** 14 | * System information of device 15 | * 16 | * Memory usage, cpu usage and chip temperature 17 | */ 18 | struct RawSystemInformation : public RawBuffer { 19 | /// DDR memory usage 20 | MemoryInfo ddrMemoryUsage; 21 | /// CMX memory usage 22 | MemoryInfo cmxMemoryUsage; 23 | /// LeonCss heap usage 24 | MemoryInfo leonCssMemoryUsage; 25 | /// LeonMss heap usage 26 | MemoryInfo leonMssMemoryUsage; 27 | /// LeonCss cpu usage 28 | CpuUsage leonCssCpuUsage; 29 | /// LeonMss cpu usage 30 | CpuUsage leonMssCpuUsage; 31 | /// Chip temperatures 32 | ChipTemperature chipTemperature; 33 | 34 | void serialize(std::vector& metadata, DatatypeEnum& datatype) const override { 35 | metadata = utility::serialize(*this); 36 | datatype = DatatypeEnum::SystemInformation; 37 | }; 38 | 39 | DatatypeEnum getType() const override { 40 | return DatatypeEnum::SystemInformation; 41 | } 42 | 43 | DEPTHAI_SERIALIZE( 44 | RawSystemInformation, ddrMemoryUsage, cmxMemoryUsage, leonCssMemoryUsage, leonMssMemoryUsage, leonCssCpuUsage, leonMssCpuUsage, chipTemperature); 45 | }; 46 | 47 | } // namespace dai 48 | -------------------------------------------------------------------------------- /include/depthai-shared/datatype/RawToFConfig.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | #include "depthai-shared/common/MedianFilter.hpp" 7 | #include "depthai-shared/datatype/DatatypeEnum.hpp" 8 | #include "depthai-shared/datatype/RawBuffer.hpp" 9 | #include "depthai-shared/utility/Serialization.hpp" 10 | 11 | namespace dai { 12 | 13 | /// RawToFConfig configuration structure 14 | struct RawToFConfig : public RawBuffer { 15 | /** 16 | * Set kernel size for depth median filtering, or disable 17 | */ 18 | MedianFilter median = MedianFilter::MEDIAN_OFF; 19 | 20 | /* 21 | * Phase unwrapping level. 22 | */ 23 | int phaseUnwrappingLevel = 4; 24 | 25 | /* 26 | * Phase unwrapping error threshold. 27 | */ 28 | uint16_t phaseUnwrapErrorThreshold = 100; 29 | 30 | /* 31 | * Enable phase shuffle temporal filter. 32 | * Temporal filter that averages the shuffle and non-shuffle frequencies. 33 | */ 34 | bool enablePhaseShuffleTemporalFilter = true; 35 | 36 | /* 37 | * Enable burst mode. 38 | * Decoding is performed on a series of 4 frames. 39 | * Output fps will be 4 times lower, but reduces motion blur artifacts. 40 | */ 41 | bool enableBurstMode = false; 42 | 43 | /* 44 | * Enable distortion correction for intensity, amplitude and depth output, if calibration is present. 45 | */ 46 | bool enableDistortionCorrection = true; 47 | 48 | /* 49 | * Enable FPN correction. Used for debugging. 50 | */ 51 | tl::optional enableFPPNCorrection; 52 | /* 53 | * Enable optical correction. Used for debugging. 54 | */ 55 | tl::optional enableOpticalCorrection; 56 | /* 57 | * Enable temperature correction. Used for debugging. 58 | */ 59 | tl::optional enableTemperatureCorrection; 60 | /* 61 | * Enable wiggle correction. Used for debugging. 62 | */ 63 | tl::optional enableWiggleCorrection; 64 | /* 65 | * Enable phase unwrapping. Used for debugging. 66 | */ 67 | tl::optional enablePhaseUnwrapping; 68 | 69 | void serialize(std::vector& metadata, DatatypeEnum& datatype) const override { 70 | metadata = utility::serialize(*this); 71 | datatype = DatatypeEnum::ToFConfig; 72 | }; 73 | 74 | DatatypeEnum getType() const override { 75 | return DatatypeEnum::ToFConfig; 76 | } 77 | 78 | DEPTHAI_SERIALIZE(RawToFConfig, 79 | median, 80 | enablePhaseShuffleTemporalFilter, 81 | enableBurstMode, 82 | enableDistortionCorrection, 83 | enableFPPNCorrection, 84 | enableOpticalCorrection, 85 | enableTemperatureCorrection, 86 | enableWiggleCorrection, 87 | enablePhaseUnwrapping, 88 | phaseUnwrappingLevel, 89 | phaseUnwrapErrorThreshold); 90 | }; 91 | 92 | } // namespace dai 93 | -------------------------------------------------------------------------------- /include/depthai-shared/datatype/RawTrackedFeatures.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | #include "RawFeatureTrackerConfig.hpp" 6 | #include "depthai-shared/common/Point2f.hpp" 7 | #include "depthai-shared/datatype/DatatypeEnum.hpp" 8 | #include "depthai-shared/datatype/RawBuffer.hpp" 9 | #include "depthai-shared/utility/Serialization.hpp" 10 | 11 | namespace dai { 12 | 13 | /** 14 | * TrackedFeature structure 15 | * 16 | */ 17 | struct TrackedFeature { 18 | /** 19 | * x, y position of the detected feature 20 | */ 21 | Point2f position; 22 | 23 | /** 24 | * Feature ID. Persistent between frames if motion estimation is enabled. 25 | */ 26 | uint32_t id = 0; 27 | 28 | /** 29 | * Feature age in frames 30 | */ 31 | uint32_t age = 0; 32 | 33 | /** 34 | * Feature harris score 35 | */ 36 | float harrisScore = 0.f; 37 | 38 | /** 39 | * Feature tracking error 40 | */ 41 | float trackingError = 0.f; 42 | }; 43 | DEPTHAI_SERIALIZE_EXT(TrackedFeature, position, id, age, harrisScore, trackingError); 44 | 45 | /// RawTrackedFeatures structure 46 | struct RawTrackedFeatures : public RawBuffer { 47 | std::vector trackedFeatures; 48 | 49 | void serialize(std::vector& metadata, DatatypeEnum& datatype) const override { 50 | metadata = utility::serialize(*this); 51 | datatype = DatatypeEnum::TrackedFeatures; 52 | }; 53 | 54 | DatatypeEnum getType() const override { 55 | return DatatypeEnum::TrackedFeatures; 56 | } 57 | 58 | DEPTHAI_SERIALIZE(RawTrackedFeatures, trackedFeatures, RawBuffer::sequenceNum, RawBuffer::ts, RawBuffer::tsDevice); 59 | }; 60 | 61 | } // namespace dai 62 | -------------------------------------------------------------------------------- /include/depthai-shared/datatype/RawTracklets.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "depthai-shared/common/Point3f.hpp" 6 | #include "depthai-shared/common/Rect.hpp" 7 | #include "depthai-shared/datatype/RawBuffer.hpp" 8 | #include "depthai-shared/datatype/RawImgDetections.hpp" 9 | #include "depthai-shared/utility/Serialization.hpp" 10 | 11 | namespace dai { 12 | 13 | /** 14 | * Tracklet structure 15 | * 16 | * Contains tracklets from object tracker output. 17 | */ 18 | struct Tracklet { 19 | enum class TrackingStatus : std::int32_t { 20 | NEW, /**< The object is newly added. */ 21 | TRACKED, /**< The object is being tracked. */ 22 | LOST, /**< The object gets lost now. The object can be tracked again automatically(long term tracking) or by specifying detected object manually(short 23 | term and zero term tracking). */ 24 | REMOVED /**< The object is removed. */ 25 | }; 26 | /** 27 | * Tracked region of interest. 28 | */ 29 | Rect roi; 30 | /** 31 | * Tracklet's ID. 32 | */ 33 | std::int32_t id = 0; 34 | /** 35 | * Tracklet's label ID. 36 | */ 37 | std::int32_t label = 0; 38 | /** 39 | * Number of frames it is being tracked for. 40 | */ 41 | std::int32_t age = 0; 42 | /** 43 | * Status of tracklet. 44 | */ 45 | TrackingStatus status = TrackingStatus::LOST; 46 | 47 | /** 48 | * Image detection that is tracked. 49 | */ 50 | ImgDetection srcImgDetection; 51 | /** 52 | * Spatial coordinates of tracklet. 53 | */ 54 | Point3f spatialCoordinates; 55 | DEPTHAI_SERIALIZE(Tracklet, roi, id, label, age, status, srcImgDetection, spatialCoordinates); 56 | }; 57 | 58 | /// RawTracklets structure 59 | struct RawTracklets : public RawBuffer { 60 | std::vector tracklets; 61 | 62 | void serialize(std::vector& metadata, DatatypeEnum& datatype) const override { 63 | metadata = utility::serialize(*this); 64 | datatype = DatatypeEnum::Tracklets; 65 | }; 66 | 67 | DatatypeEnum getType() const override { 68 | return DatatypeEnum::Tracklets; 69 | } 70 | 71 | DEPTHAI_SERIALIZE(RawTracklets, tracklets, RawBuffer::sequenceNum, RawBuffer::ts, RawBuffer::tsDevice); 72 | }; 73 | 74 | } // namespace dai 75 | -------------------------------------------------------------------------------- /include/depthai-shared/device/BoardConfig.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // std 4 | #include 5 | #include 6 | 7 | // project 8 | #include "depthai-shared/common/CameraBoardSocket.hpp" 9 | #include "depthai-shared/common/CameraImageOrientation.hpp" 10 | #include "depthai-shared/common/CameraSensorType.hpp" 11 | #include "depthai-shared/common/UsbSpeed.hpp" 12 | #include "depthai-shared/common/optional.hpp" 13 | #include "depthai-shared/datatype/RawImgFrame.hpp" 14 | #include "depthai-shared/log/LogLevel.hpp" 15 | #include "depthai-shared/utility/Serialization.hpp" 16 | #include "depthai-shared/xlink/XLinkConstants.hpp" 17 | 18 | namespace dai { 19 | 20 | constexpr static uint32_t BOARD_CONFIG_MAGIC1 = 0x78010000U; 21 | constexpr static uint32_t BOARD_CONFIG_MAGIC2 = 0x21ea17e6U; 22 | 23 | struct BoardConfig { 24 | /// USB related config 25 | struct USB { 26 | uint16_t vid = 0x03e7, pid = 0xf63b; 27 | uint16_t flashBootedVid = 0x03e7, flashBootedPid = 0xf63d; 28 | UsbSpeed maxSpeed = UsbSpeed::SUPER; 29 | std::string productName, manufacturer; 30 | }; 31 | 32 | USB usb; 33 | 34 | /// Network configuration 35 | struct Network { 36 | /// Network MTU, 0 is auto (usually 1500 for Ethernet) or forwarded 37 | /// from bootloader (not yet implemented there). 38 | /// Note: not advised to increase past 1500 for now 39 | uint16_t mtu = 0; 40 | /// Sets the `TCP_NODELAY` option for XLink TCP sockets (disable Nagle's algorithm), 41 | /// reducing latency at the expense of a small hit for max throughput. Default is `true` 42 | bool xlinkTcpNoDelay = true; 43 | }; 44 | 45 | Network network; 46 | 47 | /// Optional list of FreeBSD sysctl parameters to be set (system, network, etc.). 48 | /// For example: "net.inet.tcp.delayed_ack=0" (this one is also set by default) 49 | std::vector sysctl; 50 | 51 | /// Watchdog config 52 | tl::optional watchdogTimeoutMs; 53 | tl::optional watchdogInitialDelayMs; 54 | 55 | /// GPIO config 56 | struct GPIO { 57 | enum Mode : std::int8_t { ALT_MODE_0 = 0, ALT_MODE_1, ALT_MODE_2, ALT_MODE_3, ALT_MODE_4, ALT_MODE_5, ALT_MODE_6, DIRECT }; 58 | Mode mode = Mode::DIRECT; 59 | enum Direction : std::int8_t { INPUT = 0, OUTPUT = 1 }; 60 | Direction direction = Direction::INPUT; 61 | enum Level : std::int8_t { LOW = 0, HIGH = 1 }; 62 | Level level = Level::LOW; 63 | enum Pull : std::int8_t { NO_PULL = 0, PULL_UP = 1, PULL_DOWN = 2, BUS_KEEPER = 3 }; 64 | Pull pull = Pull::NO_PULL; 65 | /// Drive strength in mA (2, 4, 8 and 12mA) 66 | enum Drive : std::int8_t { MA_2 = 2, MA_4 = 4, MA_8 = 8, MA_12 = 12 }; 67 | Drive drive = MA_2; 68 | bool schmitt = false, slewFast = false; 69 | GPIO() = default; 70 | GPIO(Direction direction) : direction(direction) {} 71 | GPIO(Direction direction, Level level) : direction(direction), level(level) {} 72 | GPIO(Direction direction, Level level, Pull pull) : direction(direction), level(level), pull(pull) {} 73 | GPIO(Direction direction, Mode mode) : mode(mode), direction(direction) {} 74 | GPIO(Direction direction, Mode mode, Pull pull) : mode(mode), direction(direction), pull(pull) {} 75 | }; 76 | std::unordered_map gpio; 77 | 78 | // Uart config 79 | 80 | /// UART instance config 81 | struct UART { 82 | // TBD 83 | // std::int8_t tx, rx; 84 | std::int8_t tmp; 85 | }; 86 | /// UART instance map 87 | std::unordered_map uart; 88 | 89 | /// PCIe config 90 | tl::optional pcieInternalClock; 91 | 92 | /// USB3 phy config 93 | tl::optional usb3PhyInternalClock; 94 | 95 | /// MIPI 4Lane RGB config 96 | tl::optional mipi4LaneRgb; 97 | 98 | /// eMMC config 99 | tl::optional emmc; 100 | 101 | /// log path 102 | tl::optional logPath; 103 | 104 | /// Max log size 105 | tl::optional logSizeMax; 106 | 107 | /// log verbosity 108 | tl::optional logVerbosity; 109 | 110 | /// log device prints 111 | tl::optional logDevicePrints; 112 | 113 | bool nonExclusiveMode = false; 114 | 115 | // TODO(themarpe) - add later when applicable 116 | // // Socket description 117 | // struct Socket { 118 | // int i2cBus; 119 | // int mipiStart, mipiEnd; // inclusive 120 | // int gpioPwr, gpioRst; 121 | // float voltageCore, voltageAnalog, voltageInterface; 122 | // // TODO(themarpe) - tbd if better placed here 123 | // // tl::optional syncTo; 124 | // }; 125 | // std::unordered_map socket; 126 | 127 | /// Camera description 128 | struct Camera { 129 | std::string name; 130 | // TODO(themarpe) - add later when applicable 131 | // std::vector sensorName; 132 | tl::optional sensorType; 133 | // std::vector vcm; 134 | // tl::optional syncTo; 135 | tl::optional orientation; 136 | }; 137 | std::unordered_map camera; 138 | 139 | struct IMU { 140 | IMU() : bus(0), interrupt(53), wake(34), csGpio(8), boot(46), reset(45) {} 141 | int8_t bus, interrupt, wake, csGpio, boot, reset; 142 | }; 143 | tl::optional imu; 144 | 145 | /// UVC configuration for USB descriptor 146 | struct UVC { 147 | std::string cameraName; 148 | uint16_t width, height; 149 | RawImgFrame::Type frameType; 150 | bool enable; 151 | UVC(uint16_t width, uint16_t height) : width(width), height(height), frameType(RawImgFrame::Type::NV12), enable(true) {} 152 | UVC() : UVC(1920, 1080) {} 153 | }; 154 | tl::optional uvc; 155 | }; 156 | 157 | DEPTHAI_SERIALIZE_EXT(BoardConfig::USB, vid, pid, flashBootedVid, flashBootedPid, maxSpeed, productName, manufacturer); 158 | DEPTHAI_SERIALIZE_EXT(BoardConfig::Network, mtu, xlinkTcpNoDelay); 159 | DEPTHAI_SERIALIZE_EXT(BoardConfig::GPIO, mode, direction, level, pull, drive, schmitt, slewFast); 160 | DEPTHAI_SERIALIZE_EXT(BoardConfig::UART, tmp); 161 | DEPTHAI_SERIALIZE_EXT(BoardConfig::Camera, name, sensorType, orientation); 162 | DEPTHAI_SERIALIZE_EXT(BoardConfig::IMU, bus, interrupt, wake, csGpio, boot, reset); 163 | DEPTHAI_SERIALIZE_EXT(BoardConfig::UVC, cameraName, width, height, frameType, enable); 164 | DEPTHAI_SERIALIZE_EXT(BoardConfig, 165 | usb, 166 | network, 167 | sysctl, 168 | watchdogTimeoutMs, 169 | watchdogInitialDelayMs, 170 | gpio, 171 | uart, 172 | pcieInternalClock, 173 | usb3PhyInternalClock, 174 | emmc, 175 | logPath, 176 | logSizeMax, 177 | logVerbosity, 178 | logDevicePrints, 179 | nonExclusiveMode, 180 | camera, 181 | imu, 182 | uvc); 183 | 184 | } // namespace dai 185 | -------------------------------------------------------------------------------- /include/depthai-shared/device/CrashDump.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // std 4 | #include 5 | #include 6 | 7 | // project 8 | #include "depthai-shared/common/ProcessorType.hpp" 9 | #include "depthai-shared/common/optional.hpp" 10 | #include "depthai-shared/utility/Serialization.hpp" 11 | 12 | namespace dai { 13 | 14 | struct CrashDump { 15 | struct CrashReport { 16 | ProcessorType processor; 17 | std::string errorSource; 18 | uint32_t crashedThreadId = 0; 19 | 20 | struct ErrorSourceInfo { 21 | struct AssertContext { 22 | std::string fileName; 23 | std::string functionName; 24 | uint32_t line = 0; 25 | DEPTHAI_SERIALIZE(AssertContext, fileName, functionName, line); 26 | }; 27 | 28 | AssertContext assertContext; 29 | 30 | struct TrapContext { 31 | uint32_t trapNumber = 0; 32 | uint32_t trapAddress = 0; 33 | std::string trapName; 34 | DEPTHAI_SERIALIZE(TrapContext, trapNumber, trapAddress, trapName); 35 | }; 36 | 37 | TrapContext trapContext; 38 | 39 | uint32_t errorId = 0; 40 | 41 | DEPTHAI_SERIALIZE(ErrorSourceInfo, assertContext, trapContext, errorId); 42 | }; 43 | 44 | ErrorSourceInfo errorSourceInfo; 45 | 46 | struct ThreadCallstack { 47 | uint32_t threadId = 0; 48 | std::string threadName; 49 | std::string threadStatus; 50 | uint32_t stackBottom = 0; 51 | uint32_t stackTop = 0; 52 | uint32_t stackPointer = 0; 53 | uint32_t instructionPointer = 0; 54 | 55 | struct CallstackContext { 56 | uint32_t callSite = 0; 57 | uint32_t calledTarget = 0; 58 | uint32_t framePointer = 0; 59 | std::string context; 60 | DEPTHAI_SERIALIZE(CallstackContext, callSite, calledTarget, framePointer, context); 61 | }; 62 | 63 | std::vector callStack; 64 | 65 | DEPTHAI_SERIALIZE(ThreadCallstack, threadId, threadName, threadStatus, stackBottom, stackTop, stackPointer, instructionPointer, callStack); 66 | }; 67 | 68 | std::vector threadCallstack; 69 | DEPTHAI_SERIALIZE(CrashReport, processor, errorSource, crashedThreadId, errorSourceInfo, threadCallstack); 70 | }; 71 | 72 | std::vector crashReports; 73 | std::string depthaiCommitHash; 74 | std::string deviceId; 75 | 76 | nlohmann::json serializeToJson() const { 77 | std::vector data; 78 | utility::serialize(*this, data); 79 | return nlohmann::json::parse(data); 80 | } 81 | }; 82 | 83 | DEPTHAI_SERIALIZE_EXT(CrashDump, crashReports, depthaiCommitHash, deviceId); 84 | 85 | } // namespace dai 86 | -------------------------------------------------------------------------------- /include/depthai-shared/log/LogConstants.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace dai { 4 | 5 | static constexpr const char* LOG_DEFAULT_PATTERN = "[%E.%e] [%n] [%^%l%$] %v"; 6 | 7 | } // namespace dai 8 | -------------------------------------------------------------------------------- /include/depthai-shared/log/LogLevel.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // std 4 | #include 5 | 6 | // project 7 | #include "depthai-shared/utility/Serialization.hpp" 8 | 9 | namespace dai { 10 | 11 | // Follows spdlog levels 12 | enum class LogLevel : std::int32_t { TRACE = 0, DEBUG, INFO, WARN, ERR, CRITICAL, OFF }; 13 | 14 | } // namespace dai 15 | -------------------------------------------------------------------------------- /include/depthai-shared/log/LogMessage.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // std 4 | #include 5 | 6 | // project 7 | #include "LogLevel.hpp" 8 | #include "depthai-shared/common/Timestamp.hpp" 9 | #include "depthai-shared/utility/Serialization.hpp" 10 | 11 | namespace dai { 12 | 13 | struct LogMessage { 14 | std::string nodeIdName; 15 | LogLevel level{LogLevel::TRACE}; 16 | Timestamp time; 17 | size_t colorRangeStart{0}; 18 | size_t colorRangeEnd{0}; 19 | std::string payload; 20 | }; 21 | 22 | DEPTHAI_SERIALIZE_EXT(LogMessage, nodeIdName, level, time, colorRangeStart, colorRangeEnd, payload); 23 | 24 | } // namespace dai 25 | -------------------------------------------------------------------------------- /include/depthai-shared/pipeline/Assets.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // standard 4 | #include 5 | #include 6 | #include 7 | 8 | // project 9 | #include "depthai-shared/utility/Serialization.hpp" 10 | 11 | namespace dai { 12 | 13 | // This class represent a single asset 14 | struct AssetView { 15 | std::uint8_t* data; 16 | std::uint32_t size; 17 | std::uint32_t alignment = 1; 18 | AssetView(std::uint8_t* d, std::uint32_t s, std::uint32_t a = 1) : data(d), size(s), alignment(a) {} 19 | }; 20 | 21 | // This is a serializable class, which acts as readonly access to assets 22 | class Assets { 23 | protected: 24 | std::uint8_t* pStorageStart = nullptr; 25 | 26 | struct AssetInternal { 27 | std::uint32_t offset, size, alignment; 28 | DEPTHAI_SERIALIZE(AssetInternal, offset, size, alignment); 29 | }; 30 | 31 | // maps string to Asset 32 | std::unordered_map map; 33 | 34 | public: 35 | void setStorage(std::uint8_t* ps) { 36 | pStorageStart = ps; 37 | } 38 | 39 | bool has(const std::string& key) { 40 | return (map.count(key) > 0); 41 | } 42 | 43 | AssetView get(const std::string& key) { 44 | AssetInternal internal = map.at(key); 45 | return {pStorageStart + internal.offset, internal.size, internal.alignment}; 46 | } 47 | 48 | std::vector> getAll() { 49 | std::vector> allAssets; 50 | for(const auto& kv : map) { 51 | allAssets.emplace_back(kv.first, get(kv.first)); 52 | } 53 | return allAssets; 54 | } 55 | 56 | DEPTHAI_SERIALIZE(Assets, map); 57 | }; 58 | 59 | } // namespace dai 60 | -------------------------------------------------------------------------------- /include/depthai-shared/pipeline/NodeConnectionSchema.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "depthai-shared/utility/Serialization.hpp" 4 | 5 | namespace dai { 6 | 7 | /** 8 | * Specifies a connection between nodes IOs 9 | */ 10 | struct NodeConnectionSchema { 11 | int64_t node1Id = -1; 12 | std::string node1OutputGroup; 13 | std::string node1Output; 14 | int64_t node2Id = -1; 15 | std::string node2InputGroup; 16 | std::string node2Input; 17 | 18 | bool operator==(const NodeConnectionSchema& rhs) const { 19 | return node1Id == rhs.node1Id && node1OutputGroup == rhs.node1OutputGroup && node1Output == rhs.node1Output && node2Id == rhs.node2Id 20 | && node2InputGroup == rhs.node2InputGroup && node2Input == rhs.node2Input; 21 | } 22 | }; 23 | 24 | DEPTHAI_SERIALIZE_EXT(NodeConnectionSchema, node1Id, node1OutputGroup, node1Output, node2Id, node2InputGroup, node2Input); 25 | 26 | } // namespace dai 27 | -------------------------------------------------------------------------------- /include/depthai-shared/pipeline/NodeIoInfo.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "depthai-shared/utility/Serialization.hpp" 4 | 5 | namespace dai { 6 | 7 | /// NodeIo informations such as name, type, ... 8 | struct NodeIoInfo { 9 | enum class Type { MSender, SSender, MReceiver, SReceiver }; 10 | 11 | std::string group; 12 | std::string name; 13 | Type type = Type::SReceiver; 14 | bool blocking = true; 15 | int queueSize = 8; 16 | bool waitForMessage = false; 17 | uint32_t id; 18 | }; 19 | 20 | DEPTHAI_SERIALIZE_EXT(NodeIoInfo, group, name, type, blocking, queueSize, waitForMessage, id); 21 | 22 | } // namespace dai 23 | -------------------------------------------------------------------------------- /include/depthai-shared/pipeline/NodeObjInfo.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "NodeIoInfo.hpp" 6 | #include "depthai-shared/utility/Serialization.hpp" 7 | 8 | namespace dai { 9 | 10 | /// NodeObj information structure 11 | struct NodeObjInfo { 12 | int64_t id = -1; 13 | std::string name; 14 | 15 | std::vector properties; 16 | 17 | struct IoInfoKey { 18 | std::size_t operator()(const std::tuple& k) const { 19 | return std::hash()(std::get<0>(k) + std::get<1>(k)); 20 | } 21 | }; 22 | std::unordered_map, NodeIoInfo, IoInfoKey> ioInfo; 23 | }; 24 | 25 | DEPTHAI_SERIALIZE_EXT(NodeObjInfo, id, name, properties, ioInfo); 26 | 27 | } // namespace dai 28 | -------------------------------------------------------------------------------- /include/depthai-shared/pipeline/PipelineSchema.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "NodeConnectionSchema.hpp" 4 | #include "NodeObjInfo.hpp" 5 | #include "depthai-shared/properties/GlobalProperties.hpp" 6 | #include "depthai-shared/utility/Serialization.hpp" 7 | 8 | namespace dai { 9 | 10 | /** 11 | * Specifies whole pipeline, nodes, properties and connections between nodes IOs 12 | */ 13 | struct PipelineSchema { 14 | std::vector connections; 15 | GlobalProperties globalProperties; 16 | std::unordered_map nodes; 17 | }; 18 | 19 | DEPTHAI_SERIALIZE_EXT(PipelineSchema, connections, globalProperties, nodes); 20 | 21 | } // namespace dai 22 | -------------------------------------------------------------------------------- /include/depthai-shared/pipeline/TraceEvent.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace dai { 6 | 7 | struct TraceEvent { 8 | enum Event : std::uint8_t { 9 | SEND, 10 | RECEIVE, 11 | // PULL, 12 | }; 13 | enum class Status : std::uint8_t { 14 | START, 15 | END, 16 | TIMEOUT, 17 | }; 18 | Event event; 19 | Status status; 20 | uint32_t srcId; 21 | uint32_t dstId; 22 | Timestamp timestamp; 23 | }; 24 | 25 | } // namespace dai 26 | -------------------------------------------------------------------------------- /include/depthai-shared/properties/AprilTagProperties.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "depthai-shared/properties/Properties.hpp" 7 | 8 | namespace dai { 9 | 10 | /** 11 | * Specify properties for AprilTag 12 | */ 13 | struct AprilTagProperties : PropertiesSerializable { 14 | RawAprilTagConfig initialConfig; 15 | 16 | /// Whether to wait for config at 'inputConfig' IO 17 | bool inputConfigSync = false; 18 | }; 19 | 20 | DEPTHAI_SERIALIZE_EXT(AprilTagProperties, initialConfig, inputConfigSync); 21 | 22 | } // namespace dai 23 | -------------------------------------------------------------------------------- /include/depthai-shared/properties/CameraProperties.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "depthai-shared/common/CameraBoardSocket.hpp" 4 | #include "depthai-shared/common/CameraImageOrientation.hpp" 5 | #include "depthai-shared/common/CameraSensorType.hpp" 6 | #include "depthai-shared/common/optional.hpp" 7 | #include "depthai-shared/datatype/RawCameraControl.hpp" 8 | #include "depthai-shared/properties/Properties.hpp" 9 | 10 | namespace dai { 11 | 12 | /** 13 | * Specify properties for ColorCamera such as camera ID, ... 14 | */ 15 | struct CameraProperties : PropertiesSerializable { 16 | static constexpr int AUTO = -1; 17 | 18 | struct IspScale { 19 | int32_t horizNumerator = 0; 20 | int32_t horizDenominator = 0; 21 | int32_t vertNumerator = 0; 22 | int32_t vertDenominator = 0; 23 | 24 | DEPTHAI_SERIALIZE(IspScale, horizNumerator, horizDenominator, vertNumerator, vertDenominator); 25 | }; 26 | 27 | /** 28 | * For 24 bit color these can be either RGB or BGR 29 | */ 30 | enum class ColorOrder : int32_t { BGR, RGB }; 31 | 32 | /** 33 | * Initial controls applied to ColorCamera node 34 | */ 35 | RawCameraControl initialControl; 36 | 37 | /** 38 | * Which socket will color camera use 39 | */ 40 | CameraBoardSocket boardSocket = CameraBoardSocket::AUTO; 41 | 42 | /** 43 | * Which camera name will color camera use 44 | */ 45 | std::string cameraName = ""; 46 | 47 | /** 48 | * Camera sensor image orientation / pixel readout 49 | */ 50 | CameraImageOrientation imageOrientation = CameraImageOrientation::AUTO; 51 | 52 | /** 53 | * For 24 bit color these can be either RGB or BGR 54 | */ 55 | ColorOrder colorOrder = ColorOrder::BGR; 56 | /** 57 | * Are colors interleaved (R1G1B1, R2G2B2, ...) or planar (R1R2..., G1G2..., B1B2) 58 | */ 59 | bool interleaved = true; 60 | /** 61 | * Are values FP16 type (0.0 - 255.0) 62 | */ 63 | bool fp16 = false; 64 | 65 | static constexpr uint32_t DEFAULT_PREVIEW_HEIGHT = 300; 66 | static constexpr uint32_t DEFAULT_PREVIEW_WIDTH = 300; 67 | 68 | /** 69 | * Preview frame output height 70 | */ 71 | uint32_t previewHeight = DEFAULT_PREVIEW_HEIGHT; 72 | /** 73 | * Preview frame output width 74 | */ 75 | uint32_t previewWidth = DEFAULT_PREVIEW_WIDTH; 76 | 77 | /** 78 | * Preview frame output width 79 | */ 80 | int32_t videoWidth = AUTO; 81 | 82 | /** 83 | * Preview frame output height 84 | */ 85 | int32_t videoHeight = AUTO; 86 | 87 | /** 88 | * Preview frame output width 89 | */ 90 | int32_t stillWidth = AUTO; 91 | 92 | /** 93 | * Preview frame output height 94 | */ 95 | int32_t stillHeight = AUTO; 96 | 97 | /** 98 | * Select the camera sensor width 99 | */ 100 | int32_t resolutionWidth = AUTO; 101 | /** 102 | * Select the camera sensor height 103 | */ 104 | int32_t resolutionHeight = AUTO; 105 | 106 | /** 107 | * Camera sensor FPS 108 | */ 109 | float fps = 30.0; 110 | 111 | /** 112 | * Isp 3A rate (auto focus, auto exposure, auto white balance, camera controls etc.). 113 | * Default (0) matches the camera FPS, meaning that 3A is running on each frame. 114 | * Reducing the rate of 3A reduces the CPU usage on CSS, but also increases the convergence rate of 3A. 115 | * Note that camera controls will be processed at this rate. E.g. if camera is running at 30 fps, and camera control is sent at every frame, 116 | * but 3A fps is set to 15, the camera control messages will be processed at 15 fps rate, which will lead to queueing. 117 | 118 | */ 119 | int isp3aFps = 0; 120 | 121 | /** 122 | * Initial sensor crop, -1 signifies center crop 123 | */ 124 | float sensorCropX = AUTO; 125 | float sensorCropY = AUTO; 126 | 127 | /** 128 | * Whether to keep aspect ratio of input (video/preview size) or not 129 | */ 130 | bool previewKeepAspectRatio = false; 131 | 132 | /** 133 | * Configure scaling for `isp` output. 134 | */ 135 | IspScale ispScale; 136 | 137 | /// Type of sensor, specifies what kind of postprocessing is performed 138 | CameraSensorType sensorType = CameraSensorType::AUTO; 139 | 140 | /** 141 | * Pool sizes 142 | */ 143 | int numFramesPoolRaw = 3; 144 | int numFramesPoolIsp = 3; 145 | int numFramesPoolVideo = 4; 146 | int numFramesPoolPreview = 4; 147 | int numFramesPoolStill = 4; 148 | 149 | /** 150 | * Warp mesh source 151 | */ 152 | enum class WarpMeshSource { AUTO = -1, NONE, CALIBRATION, URI }; 153 | WarpMeshSource warpMeshSource = WarpMeshSource::AUTO; 154 | std::string warpMeshUri = ""; 155 | int warpMeshWidth, warpMeshHeight; 156 | /** 157 | * Free scaling parameter between 0 (when all the pixels in the undistorted image are valid) 158 | * and 1 (when all the source image pixels are retained in the undistorted image). 159 | * On some high distortion lenses, and/or due to rectification (image rotated) invalid areas may appear even with alpha=0, 160 | * in these cases alpha < 0.0 helps removing invalid areas. 161 | * See getOptimalNewCameraMatrix from opencv for more details. 162 | */ 163 | tl::optional calibAlpha; 164 | int warpMeshStepWidth = 32; 165 | int warpMeshStepHeight = 32; 166 | 167 | /** 168 | * Configures whether the camera `raw` frames are saved as MIPI-packed to memory. 169 | * The packed format is more efficient, consuming less memory on device, and less data 170 | * to send to host: RAW10: 4 pixels saved on 5 bytes, RAW12: 2 pixels saved on 3 bytes. 171 | * When packing is disabled (`false`), data is saved lsb-aligned, e.g. a RAW10 pixel 172 | * will be stored as uint16, on bits 9..0: 0b0000'00pp'pppp'pppp. 173 | * Default is auto: enabled for standard color/monochrome cameras where ISP can work 174 | * with both packed/unpacked, but disabled for other cameras like ToF. 175 | */ 176 | tl::optional rawPacked; 177 | }; 178 | 179 | DEPTHAI_SERIALIZE_EXT(CameraProperties, 180 | initialControl, 181 | boardSocket, 182 | cameraName, 183 | imageOrientation, 184 | colorOrder, 185 | interleaved, 186 | fp16, 187 | previewHeight, 188 | previewWidth, 189 | videoWidth, 190 | videoHeight, 191 | stillWidth, 192 | stillHeight, 193 | resolutionWidth, 194 | resolutionHeight, 195 | fps, 196 | isp3aFps, 197 | sensorCropX, 198 | sensorCropY, 199 | previewKeepAspectRatio, 200 | ispScale, 201 | sensorType, 202 | numFramesPoolRaw, 203 | numFramesPoolIsp, 204 | numFramesPoolVideo, 205 | numFramesPoolPreview, 206 | numFramesPoolStill, 207 | warpMeshSource, 208 | warpMeshUri, 209 | warpMeshWidth, 210 | warpMeshHeight, 211 | calibAlpha, 212 | warpMeshStepWidth, 213 | warpMeshStepHeight, 214 | rawPacked); 215 | 216 | } // namespace dai 217 | -------------------------------------------------------------------------------- /include/depthai-shared/properties/CastProperties.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "depthai-shared/common/optional.hpp" 6 | #include "depthai-shared/datatype/RawImgFrame.hpp" 7 | #include "depthai-shared/properties/Properties.hpp" 8 | 9 | namespace dai { 10 | 11 | /** 12 | * Specify properties for Cast 13 | */ 14 | struct CastProperties : PropertiesSerializable { 15 | dai::RawImgFrame::Type outputType = dai::RawImgFrame::Type::RAW8; 16 | tl::optional scale; 17 | tl::optional offset; 18 | int numFramesPool = 4; 19 | }; 20 | 21 | DEPTHAI_SERIALIZE_EXT(CastProperties, numFramesPool, outputType, scale, offset); 22 | 23 | } // namespace dai 24 | -------------------------------------------------------------------------------- /include/depthai-shared/properties/ColorCameraProperties.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "depthai-shared/common/CameraBoardSocket.hpp" 6 | #include "depthai-shared/common/CameraImageOrientation.hpp" 7 | #include "depthai-shared/common/FrameEvent.hpp" 8 | #include "depthai-shared/common/optional.hpp" 9 | #include "depthai-shared/datatype/RawCameraControl.hpp" 10 | #include "depthai-shared/properties/Properties.hpp" 11 | 12 | namespace dai { 13 | 14 | /** 15 | * Specify properties for ColorCamera such as camera ID, ... 16 | */ 17 | struct ColorCameraProperties : PropertiesSerializable { 18 | static constexpr int AUTO = -1; 19 | 20 | struct IspScale { 21 | int32_t horizNumerator = 0; 22 | int32_t horizDenominator = 0; 23 | int32_t vertNumerator = 0; 24 | int32_t vertDenominator = 0; 25 | 26 | DEPTHAI_SERIALIZE(IspScale, horizNumerator, horizDenominator, vertNumerator, vertDenominator); 27 | }; 28 | 29 | /** 30 | * Select the camera sensor resolution 31 | */ 32 | enum class SensorResolution : int32_t { 33 | /// 1920 × 1080 34 | THE_1080_P, 35 | /// 3840 × 2160 36 | THE_4_K, 37 | /// 4056 × 3040 38 | THE_12_MP, 39 | /// 4208 × 3120 40 | THE_13_MP, 41 | /// 1280 × 720 42 | THE_720_P, 43 | /// 1280 × 800 44 | THE_800_P, 45 | /// 1920 × 1200 46 | THE_1200_P, 47 | /// 2592 × 1944 48 | THE_5_MP, 49 | /// 4000 × 3000 50 | THE_4000X3000, 51 | /// 5312 × 6000 52 | THE_5312X6000, 53 | /// 8000 × 6000 54 | THE_48_MP, 55 | /// 1440 × 1080 56 | THE_1440X1080, 57 | /// 1352 × 1012 58 | THE_1352X1012, 59 | /// 2024 × 1520 60 | THE_2024X1520, 61 | }; 62 | 63 | /** 64 | * For 24 bit color these can be either RGB or BGR 65 | */ 66 | enum class ColorOrder : int32_t { BGR, RGB }; 67 | 68 | /* 69 | * Initial controls applied to ColorCamera node 70 | */ 71 | RawCameraControl initialControl; 72 | 73 | /** 74 | * Which socket will color camera use 75 | */ 76 | CameraBoardSocket boardSocket = CameraBoardSocket::AUTO; 77 | 78 | /** 79 | * Which camera name will color camera use 80 | */ 81 | std::string cameraName = ""; 82 | 83 | /** 84 | * Camera sensor image orientation / pixel readout 85 | */ 86 | CameraImageOrientation imageOrientation = CameraImageOrientation::AUTO; 87 | 88 | /** 89 | * For 24 bit color these can be either RGB or BGR 90 | */ 91 | ColorOrder colorOrder = ColorOrder::BGR; 92 | /** 93 | * Are colors interleaved (R1G1B1, R2G2B2, ...) or planar (R1R2..., G1G2..., B1B2) 94 | */ 95 | bool interleaved = true; 96 | /** 97 | * Are values FP16 type (0.0 - 255.0) 98 | */ 99 | bool fp16 = false; 100 | 101 | /** 102 | * Preview frame output height 103 | */ 104 | uint32_t previewHeight = 300; 105 | /** 106 | * Preview frame output width 107 | */ 108 | uint32_t previewWidth = 300; 109 | 110 | /** 111 | * Preview frame output width 112 | */ 113 | int32_t videoWidth = AUTO; 114 | 115 | /** 116 | * Preview frame output height 117 | */ 118 | int32_t videoHeight = AUTO; 119 | 120 | /** 121 | * Preview frame output width 122 | */ 123 | int32_t stillWidth = AUTO; 124 | 125 | /** 126 | * Preview frame output height 127 | */ 128 | int32_t stillHeight = AUTO; 129 | 130 | /** 131 | * Select the camera sensor resolution 132 | */ 133 | SensorResolution resolution = SensorResolution::THE_1080_P; 134 | /** 135 | * Camera sensor FPS 136 | */ 137 | float fps = 30.0; 138 | 139 | /** 140 | * Isp 3A rate (auto focus, auto exposure, auto white balance, camera controls etc.). 141 | * Default (0) matches the camera FPS, meaning that 3A is running on each frame. 142 | * Reducing the rate of 3A reduces the CPU usage on CSS, but also increases the convergence rate of 3A. 143 | * Note that camera controls will be processed at this rate. E.g. if camera is running at 30 fps, and camera control is sent at every frame, 144 | * but 3A fps is set to 15, the camera control messages will be processed at 15 fps rate, which will lead to queueing. 145 | 146 | */ 147 | int isp3aFps = 0; 148 | 149 | /** 150 | * Initial sensor crop, -1 signifies center crop 151 | */ 152 | float sensorCropX = AUTO; 153 | float sensorCropY = AUTO; 154 | 155 | /** 156 | * Whether to keep aspect ratio of input (video size) or not 157 | */ 158 | bool previewKeepAspectRatio = true; 159 | 160 | /** 161 | * Configure scaling for `isp` output. 162 | */ 163 | IspScale ispScale; 164 | 165 | /** 166 | * Pool sizes 167 | */ 168 | int numFramesPoolRaw = 3; 169 | int numFramesPoolIsp = 3; 170 | int numFramesPoolVideo = 4; 171 | int numFramesPoolPreview = 4; 172 | int numFramesPoolStill = 4; 173 | 174 | /** 175 | * List of events to receive, the rest will be ignored 176 | */ 177 | std::vector eventFilter = {dai::FrameEvent::READOUT_START}; 178 | 179 | /** 180 | * Configures whether the camera `raw` frames are saved as MIPI-packed to memory. 181 | * The packed format is more efficient, consuming less memory on device, and less data 182 | * to send to host: RAW10: 4 pixels saved on 5 bytes, RAW12: 2 pixels saved on 3 bytes. 183 | * When packing is disabled (`false`), data is saved lsb-aligned, e.g. a RAW10 pixel 184 | * will be stored as uint16, on bits 9..0: 0b0000'00pp'pppp'pppp. 185 | * Default is auto: enabled for standard color/monochrome cameras where ISP can work 186 | * with both packed/unpacked, but disabled for other cameras like ToF. 187 | */ 188 | tl::optional rawPacked; 189 | }; 190 | 191 | DEPTHAI_SERIALIZE_EXT(ColorCameraProperties, 192 | initialControl, 193 | boardSocket, 194 | cameraName, 195 | imageOrientation, 196 | colorOrder, 197 | interleaved, 198 | fp16, 199 | previewHeight, 200 | previewWidth, 201 | videoWidth, 202 | videoHeight, 203 | stillWidth, 204 | stillHeight, 205 | resolution, 206 | fps, 207 | isp3aFps, 208 | sensorCropX, 209 | sensorCropY, 210 | previewKeepAspectRatio, 211 | ispScale, 212 | numFramesPoolRaw, 213 | numFramesPoolIsp, 214 | numFramesPoolVideo, 215 | numFramesPoolPreview, 216 | numFramesPoolStill, 217 | rawPacked); 218 | 219 | } // namespace dai 220 | -------------------------------------------------------------------------------- /include/depthai-shared/properties/DetectionNetworkProperties.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // std 4 | #include 5 | 6 | // project 7 | #include "NeuralNetworkProperties.hpp" 8 | #include "depthai-shared/common/DetectionParserOptions.hpp" 9 | #include "depthai-shared/common/optional.hpp" 10 | 11 | namespace dai { 12 | 13 | /** 14 | * Specify properties for DetectionNetwork 15 | */ 16 | struct DetectionNetworkProperties : PropertiesSerializable { 17 | DetectionParserOptions parser; 18 | }; 19 | 20 | DEPTHAI_SERIALIZE_EXT(DetectionNetworkProperties, blobSize, blobUri, numFrames, numThreads, numNCEPerThread, parser); 21 | 22 | } // namespace dai 23 | -------------------------------------------------------------------------------- /include/depthai-shared/properties/DetectionParserProperties.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "depthai-shared/common/DetectionParserOptions.hpp" 6 | #include "depthai-shared/common/TensorInfo.hpp" 7 | #include "depthai-shared/common/optional.hpp" 8 | #include "depthai-shared/datatype/RawEdgeDetectorConfig.hpp" 9 | #include "depthai-shared/properties/Properties.hpp" 10 | 11 | namespace dai { 12 | 13 | /** 14 | * Specify properties for DetectionParser 15 | */ 16 | struct DetectionParserProperties : PropertiesSerializable { 17 | /// Num frames in output pool 18 | int numFramesPool = 8; 19 | 20 | /// Network inputs 21 | std::unordered_map networkInputs; 22 | 23 | /// Options for parser 24 | DetectionParserOptions parser; 25 | }; 26 | 27 | DEPTHAI_SERIALIZE_EXT(DetectionParserProperties, numFramesPool, networkInputs, parser); 28 | 29 | } // namespace dai 30 | -------------------------------------------------------------------------------- /include/depthai-shared/properties/EdgeDetectorProperties.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "depthai-shared/common/optional.hpp" 6 | #include "depthai-shared/datatype/RawEdgeDetectorConfig.hpp" 7 | #include "depthai-shared/properties/Properties.hpp" 8 | 9 | namespace dai { 10 | 11 | /** 12 | * Specify properties for EdgeDetector 13 | */ 14 | struct EdgeDetectorProperties : PropertiesSerializable { 15 | /// Initial edge detector config 16 | RawEdgeDetectorConfig initialConfig; 17 | 18 | /** 19 | * Maximum output frame size in bytes (eg: 300x300 BGR image -> 300*300*3 bytes) 20 | */ 21 | int outputFrameSize = 1 * 1024 * 1024; 22 | 23 | /// Num frames in output pool 24 | int numFramesPool = 4; 25 | }; 26 | 27 | DEPTHAI_SERIALIZE_EXT(EdgeDetectorProperties, initialConfig, outputFrameSize, numFramesPool); 28 | 29 | } // namespace dai 30 | -------------------------------------------------------------------------------- /include/depthai-shared/properties/FeatureTrackerProperties.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "depthai-shared/common/optional.hpp" 6 | #include "depthai-shared/datatype/RawFeatureTrackerConfig.hpp" 7 | #include "depthai-shared/properties/Properties.hpp" 8 | 9 | namespace dai { 10 | 11 | /** 12 | * Specify properties for FeatureTracker 13 | */ 14 | struct FeatureTrackerProperties : PropertiesSerializable { 15 | /** 16 | * Initial feature tracker config 17 | */ 18 | RawFeatureTrackerConfig initialConfig; 19 | 20 | /** 21 | * Number of shaves reserved for feature tracking. 22 | * Optical flow can use 1 or 2 shaves, while for corner detection only 1 is enough. 23 | * Hardware motion estimation doesn't require shaves. 24 | * Maximum 2, minimum 1. 25 | */ 26 | std::int32_t numShaves = 1; 27 | 28 | /** 29 | * Number of memory slices reserved for feature tracking. 30 | * Optical flow can use 1 or 2 memory slices, while for corner detection only 1 is enough. 31 | * Maximum number of features depends on the number of allocated memory slices. 32 | * Hardware motion estimation doesn't require memory slices. 33 | * Maximum 2, minimum 1. 34 | */ 35 | std::int32_t numMemorySlices = 1; 36 | }; 37 | 38 | DEPTHAI_SERIALIZE_EXT(FeatureTrackerProperties, initialConfig, numShaves, numMemorySlices); 39 | 40 | } // namespace dai 41 | -------------------------------------------------------------------------------- /include/depthai-shared/properties/GlobalProperties.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "depthai-shared/common/EepromData.hpp" 4 | #include "depthai-shared/common/optional.hpp" 5 | #include "depthai-shared/properties/Properties.hpp" 6 | 7 | namespace dai { 8 | 9 | /** 10 | * Specify properties which apply for whole pipeline 11 | */ 12 | struct GlobalProperties : PropertiesSerializable { 13 | constexpr static uint32_t SIPP_BUFFER_DEFAULT_SIZE = 18 * 1024; 14 | constexpr static uint32_t SIPP_DMA_BUFFER_DEFAULT_SIZE = 16 * 1024; 15 | 16 | /** 17 | * Set frequency of Leon OS - Increasing can improve performance, at the cost of higher power 18 | * draw 19 | */ 20 | double leonCssFrequencyHz = 700 * 1000 * 1000; 21 | /** 22 | * Set frequency of Leon RT - Increasing can improve performance, at the cost of higher power 23 | * draw 24 | */ 25 | double leonMssFrequencyHz = 700 * 1000 * 1000; 26 | tl::optional pipelineName; 27 | tl::optional pipelineVersion; 28 | /** 29 | * Calibration data sent through pipeline 30 | */ 31 | 32 | tl::optional calibData; 33 | 34 | /** 35 | * Camera tuning blob size in bytes 36 | */ 37 | tl::optional cameraTuningBlobSize; 38 | /** 39 | * Uri which points to camera tuning blob 40 | */ 41 | std::string cameraTuningBlobUri; 42 | 43 | /** 44 | * Chunk size for splitting device-sent XLink packets, in bytes. A larger value could 45 | * increase performance, with 0 disabling chunking. A negative value won't modify the 46 | * device defaults - configured per protocol, currently 64*1024 for both USB and Ethernet. 47 | */ 48 | int32_t xlinkChunkSize = -1; 49 | 50 | /** 51 | * SIPP (Signal Image Processing Pipeline) internal memory pool. 52 | * SIPP is a framework used to schedule HW filters, e.g. ISP, Warp, Median filter etc. 53 | * Changing the size of this pool is meant for advanced use cases, pushing the limits of the HW. 54 | * By default memory is allocated in high speed CMX memory. Setting to 0 will allocate in DDR 256 kilobytes. 55 | * Units are bytes. 56 | */ 57 | uint32_t sippBufferSize = SIPP_BUFFER_DEFAULT_SIZE; 58 | /** 59 | * SIPP (Signal Image Processing Pipeline) internal DMA memory pool. 60 | * SIPP is a framework used to schedule HW filters, e.g. ISP, Warp, Median filter etc. 61 | * Changing the size of this pool is meant for advanced use cases, pushing the limits of the HW. 62 | * Memory is allocated in high speed CMX memory 63 | * Units are bytes. 64 | */ 65 | uint32_t sippDmaBufferSize = SIPP_DMA_BUFFER_DEFAULT_SIZE; 66 | }; 67 | 68 | DEPTHAI_SERIALIZE_EXT(GlobalProperties, 69 | leonCssFrequencyHz, 70 | leonMssFrequencyHz, 71 | pipelineName, 72 | pipelineVersion, 73 | cameraTuningBlobSize, 74 | cameraTuningBlobUri, 75 | calibData, 76 | xlinkChunkSize, 77 | sippBufferSize, 78 | sippDmaBufferSize); 79 | 80 | } // namespace dai 81 | -------------------------------------------------------------------------------- /include/depthai-shared/properties/IMUProperties.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "depthai-shared/common/optional.hpp" 4 | #include "depthai-shared/datatype/RawIMUData.hpp" 5 | #include "depthai-shared/properties/Properties.hpp" 6 | 7 | namespace dai { 8 | 9 | /** 10 | * Available IMU sensors. 11 | * More details about each sensor can be found in the datasheet: 12 | * 13 | * https://www.ceva-dsp.com/wp-content/uploads/2019/10/BNO080_085-Datasheet.pdf 14 | */ 15 | enum class IMUSensor : std::int32_t { 16 | /** 17 | * Section 2.1.1 18 | * 19 | * Acceleration of the device without any postprocessing, straight from the sensor. 20 | * Units are [m/s^2] 21 | */ 22 | ACCELEROMETER_RAW = 0x14, 23 | /** 24 | * Section 2.1.1 25 | * 26 | * Acceleration of the device including gravity. 27 | * Units are [m/s^2] 28 | */ 29 | ACCELEROMETER = 0x01, 30 | /** 31 | * Section 2.1.1 32 | * 33 | * Acceleration of the device with gravity removed. 34 | * Units are [m/s^2] 35 | */ 36 | LINEAR_ACCELERATION = 0x04, 37 | /** 38 | * Section 2.1.1 39 | * 40 | * Gravity. 41 | * Units are [m/s^2] 42 | */ 43 | GRAVITY = 0x06, 44 | /** 45 | * Section 2.1.2 46 | * 47 | * The angular velocity of the device without any postprocessing, straight from the sensor. 48 | * Units are [rad/s] 49 | */ 50 | GYROSCOPE_RAW = 0x15, 51 | /** 52 | * Section 2.1.2 53 | * 54 | * The angular velocity of the device. 55 | * Units are [rad/s] 56 | */ 57 | GYROSCOPE_CALIBRATED = 0x02, 58 | /** 59 | * Section 2.1.2 60 | * 61 | * Angular velocity without bias compensation. 62 | * Units are [rad/s] 63 | */ 64 | GYROSCOPE_UNCALIBRATED = 0x07, 65 | /** 66 | * Section 2.1.3 67 | * 68 | * Magnetic field measurement without any postprocessing, straight from the sensor. 69 | * Units are [uTesla] 70 | */ 71 | MAGNETOMETER_RAW = 0x16, 72 | /** 73 | * Section 2.1.3 74 | * 75 | * The fully calibrated magnetic field measurement. 76 | * Units are [uTesla] 77 | */ 78 | MAGNETOMETER_CALIBRATED = 0x03, 79 | /** 80 | * Section 2.1.3 81 | * 82 | * The magnetic field measurement without hard-iron offset applied. 83 | * Units are [uTesla] 84 | */ 85 | MAGNETOMETER_UNCALIBRATED = 0x0f, 86 | /** 87 | * Section 2.2 88 | * 89 | * The rotation vector provides an orientation output that is expressed as a quaternion referenced to magnetic north 90 | * and gravity. It is produced by fusing the outputs of the accelerometer, gyroscope and magnetometer. The rotation 91 | * vector is the most accurate orientation estimate available. The magnetometer provides correction in yaw to 92 | * reduce drift and the gyroscope enables the most responsive performance. 93 | */ 94 | ROTATION_VECTOR = 0x05, 95 | /** 96 | * Section 2.2 97 | * 98 | * The game rotation vector is an orientation output that is expressed as a quaternion with no specific reference for 99 | * heading, while roll and pitch are referenced against gravity. It is produced by fusing the outputs of the 100 | * accelerometer and the gyroscope (i.e. no magnetometer). The game rotation vector does not use the 101 | * magnetometer to correct the gyroscopes drift in yaw. This is a deliberate omission (as specified by Google) to 102 | * allow gaming applications to use a smoother representation of the orientation without the jumps that an 103 | * instantaneous correction provided by a magnetic field update could provide. Long term the output will likely drift in 104 | * yaw due to the characteristics of gyroscopes, but this is seen as preferable for this output versus a corrected output. 105 | */ 106 | GAME_ROTATION_VECTOR = 0x08, 107 | /** 108 | * Section 2.2 109 | * 110 | * The geomagnetic rotation vector is an orientation output that is expressed as a quaternion referenced to magnetic 111 | * north and gravity. It is produced by fusing the outputs of the accelerometer and magnetometer. The gyroscope is 112 | * specifically excluded in order to produce a rotation vector output using less power than is required to produce the 113 | * rotation vector of section 2.2.4. The consequences of removing the gyroscope are: 114 | * Less responsive output since the highly dynamic outputs of the gyroscope are not used 115 | * More errors in the presence of varying magnetic fields. 116 | */ 117 | GEOMAGNETIC_ROTATION_VECTOR = 0x09, 118 | /** 119 | * Section 2.2 120 | * 121 | * Estimates of the magnetic field and the roll/pitch of the device can create a potential correction in the rotation 122 | * vector produced. For applications (typically augmented or virtual reality applications) where a sudden jump can be 123 | * disturbing, the output is adjusted to prevent these jumps in a manner that takes account of the velocity of the 124 | * sensor system. 125 | */ 126 | ARVR_STABILIZED_ROTATION_VECTOR = 0x28, 127 | /** 128 | * Section 2.2 129 | * 130 | * While the magnetometer is removed from the calculation of the game rotation vector, the accelerometer itself can 131 | * create a potential correction in the rotation vector produced (i.e. the estimate of gravity changes). For applications 132 | * (typically augmented or virtual reality applications) where a sudden jump can be disturbing, the output is adjusted 133 | * to prevent these jumps in a manner that takes account of the velocity of the sensor system. This process is called 134 | * AR/VR stabilization. 135 | */ 136 | ARVR_STABILIZED_GAME_ROTATION_VECTOR = 0x29, 137 | // GYRO_INTEGRATED_ROTATION_VECTOR = 0x2A, 138 | }; 139 | 140 | struct IMUSensorConfig { 141 | /* Sensitivity enabled */ 142 | bool sensitivityEnabled = false; 143 | 144 | /* Change sensitivity - true if relative; false if absolute */ 145 | bool sensitivityRelative = false; /**< @brief Change reports relative (vs absolute) */ 146 | 147 | // TODO write utility function to convert float to Q point notation, sensor specific 148 | /* 16-bit signed fixed point integer. 149 | * In case of absolute sensitivity represents the value a 150 | * sensor output must exceed in order to trigger another input 151 | * report. 152 | * In case of relative sensitivity represents the the amount 153 | * by which a sensor output must change from the previous 154 | * input report in order to trigger another input report 155 | * A setting of 0 causes all reports to be sent. 156 | */ 157 | uint16_t changeSensitivity = 0; /**< @brief Report-on-change threshold */ 158 | 159 | /* Rate of reports per second. (hertz) 160 | * 0 means disabled 161 | */ 162 | uint32_t reportRate = 100; 163 | 164 | IMUSensor sensorId = IMUSensor::ACCELEROMETER; 165 | }; 166 | DEPTHAI_SERIALIZE_EXT(IMUSensorConfig, sensitivityEnabled, sensitivityRelative, changeSensitivity, reportRate, sensorId); 167 | 168 | struct IMUProperties : PropertiesSerializable { 169 | /* Enabled IMU sensors */ 170 | std::vector imuSensors; 171 | /* Above this packet threshold data will be sent to host, if queue is not blocked */ 172 | std::int32_t batchReportThreshold = 1; 173 | /* Maximum number of IMU packets in a batch. Maximum 5. */ 174 | std::int32_t maxBatchReports = 5; 175 | /* 176 | * Whether to perform firmware update or not. 177 | * Default value: false. 178 | */ 179 | tl::optional enableFirmwareUpdate = false; 180 | }; 181 | 182 | DEPTHAI_SERIALIZE_EXT(IMUProperties, imuSensors, batchReportThreshold, maxBatchReports, enableFirmwareUpdate); 183 | 184 | } // namespace dai 185 | -------------------------------------------------------------------------------- /include/depthai-shared/properties/ImageAlignProperties.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "depthai-shared/common/Interpolation.hpp" 6 | #include "depthai-shared/common/optional.hpp" 7 | #include "depthai-shared/datatype/RawImageAlignConfig.hpp" 8 | #include "depthai-shared/properties/Properties.hpp" 9 | 10 | namespace dai { 11 | 12 | /** 13 | * Specify properties for ImageAlign 14 | */ 15 | struct ImageAlignProperties : PropertiesSerializable { 16 | RawImageAlignConfig initialConfig; 17 | 18 | /// Num frames in output pool 19 | int numFramesPool = 4; 20 | 21 | /** 22 | * Optional output width 23 | */ 24 | int alignWidth = 0; 25 | /** 26 | * Optional output height 27 | */ 28 | int alignHeight = 0; 29 | 30 | /// Warp HW IDs to use, if empty, use auto/default 31 | std::vector warpHwIds; 32 | using Interpolation = dai::Interpolation; 33 | /// Interpolation type to use 34 | Interpolation interpolation = Interpolation::AUTO; 35 | /** 36 | * Whether to keep aspect ratio of the input or not 37 | */ 38 | bool outKeepAspectRatio = true; 39 | 40 | /** 41 | * Number of shaves reserved. 42 | */ 43 | std::int32_t numShaves = 2; 44 | }; 45 | 46 | DEPTHAI_SERIALIZE_EXT(ImageAlignProperties, initialConfig, numFramesPool, alignWidth, alignHeight, warpHwIds, interpolation, outKeepAspectRatio, numShaves); 47 | 48 | } // namespace dai 49 | -------------------------------------------------------------------------------- /include/depthai-shared/properties/ImageManipProperties.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "depthai-shared/common/optional.hpp" 4 | #include "depthai-shared/datatype/RawImageManipConfig.hpp" 5 | #include "depthai-shared/properties/Properties.hpp" 6 | 7 | namespace dai { 8 | 9 | /** 10 | * Specify properties for ImageManip 11 | */ 12 | struct ImageManipProperties : PropertiesSerializable { 13 | /// Initial configuration for ImageManip node 14 | RawImageManipConfig initialConfig; 15 | 16 | /// Maximum output frame size in bytes (eg: 300x300 BGR image -> 300*300*3 bytes) 17 | int outputFrameSize = 1 * 1024 * 1024; 18 | 19 | /// Num frames in output pool 20 | int numFramesPool = 4; 21 | 22 | /// Custom warp mesh width. Set to zero to disable 23 | int meshWidth = 0; 24 | /// Custom warp mesh height. Set to zero to disable. 25 | int meshHeight = 0; 26 | /// Custom warp mesh uri. Set to empty string to disable. 27 | std::string meshUri = ""; 28 | }; 29 | 30 | DEPTHAI_SERIALIZE_EXT(ImageManipProperties, initialConfig, outputFrameSize, numFramesPool, meshWidth, meshHeight, meshUri); 31 | 32 | } // namespace dai 33 | -------------------------------------------------------------------------------- /include/depthai-shared/properties/MessageDemuxProperties.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "depthai-shared/properties/Properties.hpp" 4 | 5 | namespace dai { 6 | 7 | /** 8 | * MessageDemux does not have any properties to set 9 | */ 10 | struct MessageDemuxProperties : PropertiesSerializable { 11 | // Needed for serialization 12 | char dummy = 0; 13 | }; 14 | 15 | DEPTHAI_SERIALIZE_EXT(MessageDemuxProperties, dummy); 16 | 17 | } // namespace dai 18 | -------------------------------------------------------------------------------- /include/depthai-shared/properties/MonoCameraProperties.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "depthai-shared/common/CameraBoardSocket.hpp" 6 | #include "depthai-shared/common/CameraImageOrientation.hpp" 7 | #include "depthai-shared/common/FrameEvent.hpp" 8 | #include "depthai-shared/common/optional.hpp" 9 | #include "depthai-shared/datatype/RawCameraControl.hpp" 10 | #include "depthai-shared/properties/Properties.hpp" 11 | 12 | namespace dai { 13 | 14 | /** 15 | * Specify properties for MonoCamera such as camera ID, ... 16 | */ 17 | struct MonoCameraProperties : PropertiesSerializable { 18 | static constexpr int AUTO = -1; 19 | 20 | /** 21 | * Select the camera sensor resolution: 1280×720, 1280×800, 640×400, 640×480, 1920×1200 22 | */ 23 | enum class SensorResolution : int32_t { THE_720_P, THE_800_P, THE_400_P, THE_480_P, THE_1200_P }; 24 | 25 | /* 26 | * Initial controls applied to MonoCamera node 27 | */ 28 | RawCameraControl initialControl; 29 | 30 | /** 31 | * Which socket will mono camera use 32 | */ 33 | CameraBoardSocket boardSocket = CameraBoardSocket::AUTO; 34 | 35 | /** 36 | * Which camera name will mono camera use 37 | */ 38 | std::string cameraName = ""; 39 | 40 | /** 41 | * Camera sensor image orientation / pixel readout 42 | */ 43 | CameraImageOrientation imageOrientation = CameraImageOrientation::AUTO; 44 | 45 | /** 46 | * Select the camera sensor resolution 47 | */ 48 | SensorResolution resolution = SensorResolution::THE_720_P; 49 | /** 50 | * Camera sensor FPS 51 | */ 52 | float fps = 30.0; 53 | /** 54 | * Isp 3A rate (auto focus, auto exposure, auto white balance, camera controls etc.). 55 | * Default (0) matches the camera FPS, meaning that 3A is running on each frame. 56 | * Reducing the rate of 3A reduces the CPU usage on CSS, but also increases the convergence rate of 3A. 57 | * Note that camera controls will be processed at this rate. E.g. if camera is running at 30 fps, and camera control is sent at every frame, 58 | * but 3A fps is set to 15, the camera control messages will be processed at 15 fps rate, which will lead to queueing. 59 | 60 | */ 61 | int isp3aFps = 0; 62 | /** 63 | * Frame pool size for the main output, ISP processed 64 | */ 65 | int numFramesPool = 3; 66 | /** 67 | * Frame pool size for the `raw` output 68 | */ 69 | int numFramesPoolRaw = 3; 70 | /** 71 | * List of events to receive, the rest will be ignored 72 | */ 73 | std::vector eventFilter = {dai::FrameEvent::READOUT_START}; 74 | 75 | /** 76 | * Configures whether the camera `raw` frames are saved as MIPI-packed to memory. 77 | * The packed format is more efficient, consuming less memory on device, and less data 78 | * to send to host: RAW10: 4 pixels saved on 5 bytes, RAW12: 2 pixels saved on 3 bytes. 79 | * When packing is disabled (`false`), data is saved lsb-aligned, e.g. a RAW10 pixel 80 | * will be stored as uint16, on bits 9..0: 0b0000'00pp'pppp'pppp. 81 | * Default is auto: enabled for standard color/monochrome cameras where ISP can work 82 | * with both packed/unpacked, but disabled for other cameras like ToF. 83 | */ 84 | tl::optional rawPacked; 85 | }; 86 | 87 | DEPTHAI_SERIALIZE_EXT( 88 | MonoCameraProperties, initialControl, boardSocket, cameraName, imageOrientation, resolution, fps, isp3aFps, numFramesPool, numFramesPoolRaw, rawPacked); 89 | 90 | } // namespace dai 91 | -------------------------------------------------------------------------------- /include/depthai-shared/properties/NeuralNetworkProperties.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "depthai-shared/common/optional.hpp" 4 | #include "depthai-shared/properties/Properties.hpp" 5 | 6 | namespace dai { 7 | 8 | /** 9 | * Specify properties for NeuralNetwork such as blob path, ... 10 | */ 11 | struct NeuralNetworkProperties : PropertiesSerializable { 12 | /** 13 | * Blob binary size in bytes 14 | */ 15 | tl::optional blobSize; 16 | /** 17 | * Uri which points to blob 18 | */ 19 | std::string blobUri; 20 | /** 21 | * Number of available output tensors in pool 22 | */ 23 | std::uint32_t numFrames = 8; 24 | /** 25 | * Number of threads to create for running inference. 0 = auto 26 | */ 27 | std::uint32_t numThreads = 0; 28 | /** 29 | * Number of NCE (Neural Compute Engine) per inference thread. 0 = auto 30 | */ 31 | std::uint32_t numNCEPerThread = 0; 32 | }; 33 | 34 | DEPTHAI_SERIALIZE_EXT(NeuralNetworkProperties, blobSize, blobUri, numFrames, numThreads, numNCEPerThread); 35 | 36 | } // namespace dai 37 | -------------------------------------------------------------------------------- /include/depthai-shared/properties/ObjectTrackerProperties.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // std 4 | #include 5 | 6 | // project 7 | #include "depthai-shared/common/optional.hpp" 8 | #include "depthai-shared/properties/Properties.hpp" 9 | 10 | namespace dai { 11 | 12 | enum class TrackerType : std::int32_t { 13 | /// Kernelized Correlation Filter tracking 14 | SHORT_TERM_KCF = 1, 15 | /// Short term tracking without using image data 16 | SHORT_TERM_IMAGELESS = 3, 17 | /// Ability to track the objects without accessing image data. 18 | ZERO_TERM_IMAGELESS = 5, 19 | /// Tracking using image data too. 20 | ZERO_TERM_COLOR_HISTOGRAM = 6 21 | }; 22 | 23 | enum class TrackerIdAssignmentPolicy : std::int32_t { 24 | /// Always take a new, unique ID 25 | UNIQUE_ID, 26 | /// Take the smallest available ID 27 | SMALLEST_ID 28 | }; 29 | 30 | /** 31 | * Specify properties for ObjectTracker 32 | */ 33 | struct ObjectTrackerProperties : PropertiesSerializable { 34 | /** 35 | * Confidence threshold for tracklets. 36 | * Above this threshold detections will be tracked. 37 | * Default 0, all detections are tracked. 38 | */ 39 | float trackerThreshold = 0.0; 40 | /** 41 | * Maximum number of objects to track. 42 | * Maximum 60 for SHORT_TERM_KCF, maximum 1000 for other tracking methods. 43 | * Default 60. 44 | */ 45 | std::int32_t maxObjectsToTrack = 60; 46 | /** 47 | * Which detections labels to track. 48 | * Default all labels are tracked. 49 | */ 50 | std::vector detectionLabelsToTrack; 51 | /** 52 | * Tracking method. 53 | */ 54 | TrackerType trackerType = TrackerType::ZERO_TERM_IMAGELESS; 55 | /** 56 | * New ID assignment policy. 57 | */ 58 | TrackerIdAssignmentPolicy trackerIdAssignmentPolicy = TrackerIdAssignmentPolicy::UNIQUE_ID; 59 | /** 60 | * Whether tracker should take into consideration class label for tracking. 61 | */ 62 | bool trackingPerClass = true; 63 | }; 64 | 65 | DEPTHAI_SERIALIZE_EXT( 66 | ObjectTrackerProperties, trackerThreshold, maxObjectsToTrack, detectionLabelsToTrack, trackerType, trackerIdAssignmentPolicy, trackingPerClass); 67 | 68 | } // namespace dai 69 | -------------------------------------------------------------------------------- /include/depthai-shared/properties/PointCloudProperties.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "depthai-shared/common/optional.hpp" 6 | #include "depthai-shared/datatype/RawPointCloudConfig.hpp" 7 | #include "depthai-shared/properties/Properties.hpp" 8 | 9 | namespace dai { 10 | 11 | /** 12 | * Specify properties for PointCloud 13 | */ 14 | struct PointCloudProperties : PropertiesSerializable { 15 | RawPointCloudConfig initialConfig; 16 | 17 | int numFramesPool = 4; 18 | }; 19 | 20 | DEPTHAI_SERIALIZE_EXT(PointCloudProperties, initialConfig, numFramesPool); 21 | 22 | } // namespace dai 23 | -------------------------------------------------------------------------------- /include/depthai-shared/properties/Properties.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "depthai-shared/utility/Serialization.hpp" 4 | 5 | namespace dai { 6 | 7 | /// Base Properties structure 8 | struct Properties { 9 | virtual void serialize(std::vector& data, SerializationType type) const = 0; 10 | virtual std::unique_ptr clone() const = 0; 11 | virtual ~Properties() = default; 12 | }; 13 | 14 | /// Serializable properties 15 | template 16 | struct PropertiesSerializable : Base { 17 | virtual void serialize(std::vector& data, SerializationType type = SerializationType::LIBNOP) const override { 18 | utility::serialize(static_cast(*this), data, type); 19 | } 20 | 21 | virtual std::unique_ptr clone() const override { 22 | return std::make_unique(static_cast(*this)); 23 | } 24 | }; 25 | 26 | } // namespace dai -------------------------------------------------------------------------------- /include/depthai-shared/properties/SPIInProperties.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "depthai-shared/properties/Properties.hpp" 4 | #include "depthai-shared/xlink/XLinkConstants.hpp" 5 | 6 | namespace dai { 7 | 8 | /** 9 | * Properties for SPIIn node 10 | */ 11 | struct SPIInProperties : PropertiesSerializable { 12 | /** 13 | * Name of stream 14 | */ 15 | std::string streamName; 16 | 17 | /** 18 | * SPI bus to use 19 | */ 20 | int busId = 0; 21 | 22 | /** 23 | * Maximum input data size 24 | */ 25 | std::uint32_t maxDataSize = dai::device::XLINK_USB_BUFFER_MAX_SIZE; 26 | 27 | /** 28 | * Number of frames in pool 29 | */ 30 | std::uint32_t numFrames = 4; 31 | }; 32 | 33 | DEPTHAI_SERIALIZE_EXT(SPIInProperties, streamName, busId, maxDataSize, numFrames); 34 | 35 | } // namespace dai 36 | -------------------------------------------------------------------------------- /include/depthai-shared/properties/SPIOutProperties.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "depthai-shared/properties/Properties.hpp" 4 | 5 | namespace dai { 6 | 7 | /** 8 | * Specify properties for SPIOut node 9 | */ 10 | struct SPIOutProperties : PropertiesSerializable { 11 | /** 12 | * Name of stream 13 | */ 14 | std::string streamName; 15 | 16 | /** 17 | * SPI bus to use 18 | */ 19 | int busId = 0; 20 | }; 21 | 22 | DEPTHAI_SERIALIZE_EXT(SPIOutProperties, streamName, busId); 23 | 24 | } // namespace dai 25 | -------------------------------------------------------------------------------- /include/depthai-shared/properties/ScriptProperties.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "depthai-shared/common/ProcessorType.hpp" 4 | #include "depthai-shared/common/optional.hpp" 5 | #include "depthai-shared/properties/Properties.hpp" 6 | 7 | namespace dai { 8 | 9 | /** 10 | * Specify ScriptProperties options such as script uri, script name, ... 11 | */ 12 | struct ScriptProperties : PropertiesSerializable { 13 | /** 14 | * Uri which points to actual script 15 | */ 16 | std::string scriptUri; 17 | 18 | /** 19 | * Name of script 20 | */ 21 | std::string scriptName = "