MCPcopy Create free account
hub / github.com/SpectacularAI/sdk / serializeVioOutput

Method serializeVioOutput

cpp/common/visualization/serialization.cpp:126–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

124}
125
126void Serializer::serializeVioOutput(spectacularAI::VioOutputPtr vioOutput) {
127 const spectacularAI::Camera &camera = *vioOutput->getCameraPose(0).camera;
128 const Matrix4d &cameraToWorld = vioOutput->getCameraPose(0).getCameraToWorldMatrix();
129
130 // Only properties used in current visualization are serialized, i.e. add more stuff if needed.
131 nlohmann::json json;
132 json["cameraPoses"] = {
133 {
134 {"camera", serializeCamera(camera)},
135 {"cameraToWorld", cameraToWorld}
136 }
137 };
138 json["trackingStatus"] = static_cast<int32_t>(vioOutput->status);
139
140 std::string jsonStr = json.dump();
141 uint32_t jsonLength = jsonStr.length();
142
143 MessageHeader header = {
144 .magicBytes = MAGIC_BYTES,
145 .messageId = messageIdCounter,
146 .jsonSize = jsonLength,
147 .binarySize = 0
148 };
149
150 std::lock_guard<std::mutex> lock(outputMutex);
151 outputStream.write(reinterpret_cast<char*>(&header), sizeof(MessageHeader));
152 outputStream.write(jsonStr.c_str(), jsonStr.size());
153 outputStream.flush();
154 messageIdCounter++;
155}
156
157void Serializer::serializeMappingOutput(spectacularAI::mapping::MapperOutputPtr mapperOutput) {
158 std::map<std::string, nlohmann::json> jsonKeyFrames;

Callers 1

onVioOutputMethod · 0.80

Calls 4

serializeCameraFunction · 0.85
getCameraPoseMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected