HoviTron Video Pipeline
RenderingParameters.h
1/* ----------------------
2* Copyright 2023 Université Libre de Bruxelles(ULB), Universidad Politécnica de Madrid(UPM), CREAL, Deutsches Zentrum für Luft - und Raumfahrt(DLR)
3
4* Licensed under the Apache License, Version 2.0 (the "License");
5* you may not use this file except in compliance with the License.
6* You may obtain a copy of the License at < http://www.apache.org/licenses/LICENSE-2.0>
7
8* Unless required by applicable law or agreed to in writing, software
9* distributed under the License is distributed on an "AS IS" BASIS,
10* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11* See the License for the specific language governing permissionsand
12* limitations under the License.
13---------------------- */
14
15
16
17#pragma once
18
19#include "commonVulkan.h"
20#include "InputProvider.h"
21
22#ifdef HVT_UDP_CONTROL
23#include <thread>
24#ifdef WIN32
25#include <winsock2.h>
26#include <thread>
27#include <mutex>
28#else
29//TODO
30#endif
31#endif //
32
33
34
35class WindowAbstract;
36class VulkanWrapper;
42enum class StartingPosition {
43 Zero,
44 Average
45};
46
53enum class VirtualMode{ Tracking, Static1, Static2};
54
55
56#ifdef HVT_UDP_CONTROL
62struct UDPMessage {
64 alignas(4) float magic;
66 alignas(4) float mode;
68 alignas(4) float viewTransx;
70 alignas(4) float viewTransy;
72 alignas(4) float viewTransz;
74 alignas(4) float viewRotx;
76 alignas(4) float viewRoty;
78 alignas(4) float viewRotz;
80 alignas(4) float viewRotw;
82 alignas(4) float cameras;
84 alignas(4) float reset;
86 alignas(4) float initTransx;
88 alignas(4) float initTransy;
90 alignas(4) float initTransz;
92 alignas(4) float initRotx;
94 alignas(4) float initRoty;
96 alignas(4) float initRotz;
98 alignas(4) float initRotw;
99};
100#endif
101
109public:
110#ifdef HVT_UDP_CONTROL
112 void init(int view, WindowAbstract* window, VulkanWrapper* wraps, unsigned short portNumber);
113#else
115 void init(int view, WindowAbstract* window, VulkanWrapper * wraps);
116#endif // HVT_UDP_CONTROL
117
120
122 float blendingFactor = 5.0;
124 float pixelThreshold = 30;
126 const glm::mat3x3 conversionToOMAF = { 0,-1,0, 0,0,1, -1,0,0 }; //column major representation of glm
127
129 float maxMult = 10;
131 float scaleFactor = 1.0;
132 /*
133 * //version for opencv below (because opencv use row major representation and glm use column-major
134 { 0,0,-1,
135 -1,0,0,
136 0,1,0 }; */// conversion matrice when the space for the virtual camera isn't OMAF
137
138
140 std::vector<glm::vec2> virtualViewDef; //glm::vec2 or vk::Extent2D
142 InputProvider::ProjectionType projectionType = InputProvider::ProjectionType::PROJECTION_INVALID; //init at invalid
143
145 float max_depth = 0.0;
147 float min_depth = FLT_MAX;
148
150 float farPlaneHeadset = 10;
152 float nearPlaneHeadset = 0.1;
153
154
156 void updateSpaceTransform(glm::vec3 translation, glm::vec3 rotation);
158 void updateSpaceTransform(glm::vec3 translation, glm::vec3 rotation, glm::vec4 fov, int view);
159
164
166 void setStartingPt(glm::vec3 startPos, glm::vec3 startRot);
167
169 const glm::vec3 getStartingPosition();
171 const glm::vec3 getStartingRotation();
172
173private:
175 WindowAbstract* window = nullptr;
177 VulkanWrapper* wrapper = nullptr;
178
180 glm::vec3 startingPosition = { 0,0,0 };
182 glm::vec3 startingRotation = { 0,0,0 };
183
185 const int staticPoses = 2;
187 std::vector<glm::vec3> staticPosition;
189 std::vector<glm::quat> staticQuaternion;
190
192 std::vector<InputProvider::Extrinsics> virtualExtrinsics;
194 std::vector<InputProvider::Intrinsics> virtualIntrasics;
195
197 VirtualMode virtualMode = VirtualMode::Tracking;
198
199#ifdef HVT_UDP_CONTROL
200 //--- Related to the UDP server
201
203 unsigned short portNumber = 0;
205 const float magicNb = 456123;
206
208 void setupUDPServer();
210 void mainLoop();
211
213 std::thread serverThread;
215 int s;
217 int namelen;
219 int client_address_size;
221 sockaddr_in client;
223 sockaddr_in server;
225 UDPMessage udpMsg;
226
228 bool serverIsActive = true;
229
231 std::mutex mutex;
233 std::mutex startPosMut;
234#endif
235
236};
std::variant< PerspectiveIntrinsics, EquirectangularIntrinsics > Intrinsics
Union of possible intrinsics types data.
Definition: InputProvider.h:67
Class that encapsulates the rendering parameters (RVS internal parameters + virtual camera parameters...
void setStartingPt(glm::vec3 startPos, glm::vec3 startRot)
const InputProvider::Extrinsics getVirtualExtrinsics(int view)
const glm::mat3x3 conversionToOMAF
const glm::vec3 getStartingPosition()
const glm::vec3 getStartingRotation()
std::vector< glm::vec2 > virtualViewDef
void updateSpaceTransform(glm::vec3 translation, glm::vec3 rotation)
InputProvider::ProjectionType projectionType
void init(int view, WindowAbstract *window, VulkanWrapper *wraps)
const InputProvider::Intrinsics getVirtualIntrinsics(int view)
Class that manages the classes related to Vulkan code and act as a wrapper around them.
Definition: VulkanWrapper.h:66
Abstraction of the way of the result is displayed (screen or HMD).
file that contains the common include for the Vulkan part