Ocean
PanoramaFrame.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef META_OCEAN_CV_ADVANCED_PANORAMA_FRAME_H
9 #define META_OCEAN_CV_ADVANCED_PANORAMA_FRAME_H
10 
13 
14 #include "ocean/base/Frame.h"
15 #include "ocean/base/Worker.h"
16 
17 #include "ocean/cv/FramePyramid.h"
18 #include "ocean/cv/PixelPosition.h"
19 
20 #include "ocean/math/Lookup2.h"
21 #include "ocean/math/Numeric.h"
24 
25 namespace Ocean
26 {
27 
28 namespace CV
29 {
30 
31 namespace Advanced
32 {
33 
34 /**
35  * This class implements a panorama frame with spherical projection model.
36  * The resolution of the panorama frame is clamped by a maximal number of pixels.<br>
37  * However, internally a sub-frame of the panorama frame is stored and iteratively extended if necessary.<br>
38  * The resulting panorama frame is a combination of several camera frames which have been projected into the inner side of a sphere.<br>
39  * The default camera orientation is looking into the negative z-axis and has the y-axis as up-vector.<br>
40  * An horizontal orientation is a rotation around the y-axis.<br>
41  * A frame with default orientation is mapped to the center position of the panorama frame.<br>
42  * The maximal possible panorama frame covers an horizontal angle of [-180, 180) degrees (from left to right),<br>
43  * and a vertical angle of [90, -90) degrees from top to bottom).<br>
44  * @ingroup cvadvanced
45  */
46 class OCEAN_CV_ADVANCED_EXPORT PanoramaFrame
47 {
48  public:
49 
50  /**
51  * Definition of individual frame update modes.
52  */
54  {
55  /// Invalid update mode.
57  /// Sets only pixels in the panorama frame which haven't been set before.
59  /// Overwrites all pixels in the panorama frame.
61  /// Updates all pixels in the panorama frame by averaging the current pixel value with the new pixel value.
63  /// Updates all pixels in the panorama frame by averaging all pixel values.
64  UM_AVERAGE_GLOBAL
65  };
66 
67  protected:
68 
69  /**
70  * Definition of a lookup table for 2D vectors.
71  */
73 
74  public:
75 
76  /**
77  * Creates an invalid panorama frame instance.
78  */
79  PanoramaFrame() = default;
80 
81  /**
82  * Creates a new panorama frame instance.
83  * @param width The width of the entire panorama frame (the maximal possible size) representing horizontal 360 degrees, in pixel with range [1, infinity)
84  * @param height The height of the entire panorama frame (the maximal possible size) representing vertical 180 degrees, in pixel with range [1, infinity)
85  * @param maskValue The mask value defining the 8 bit pixel value of valid pixels
86  * @param updateMode The update mode of this panorama frame
87  */
88  inline PanoramaFrame(const unsigned int width, const unsigned int height, const uint8_t maskValue, const UpdateMode updateMode);
89 
90  /**
91  * Creates a new panorama frame instance by an already existing (entire) panorama frame.
92  * @param frame The already known (entire) panorama frame covering the visual content of the entire sphere, must be valid
93  * @param mask The mask corresponding to the given frame, with same frame dimension and pixel orientation, must be valid
94  * @param maskValue The mask value defining the 8 bit pixel value of valid pixels
95  * @param updateMode The update mode of this panorama frame
96  * @param worker Optional worker to distribute the computation, necessary for UM_AVERAGE_GLOBAL update mode only
97  */
98  PanoramaFrame(const Frame& frame, const Frame& mask, const uint8_t maskValue, const UpdateMode updateMode, Worker* worker = nullptr);
99 
100  /**
101  * Creates a new panorama frame instance by an already existing (entire) panorama frame.
102  * @param frame The already known (entire) panorama frame covering the visual content of the entire sphere, will be moved, must be valid
103  * @param mask The mask corresponding to the given frame, with same frame dimension and pixel orientation, will be moved, must be valid
104  * @param maskValue The mask value defining the 8 bit pixel value of valid pixels
105  * @param updateMode The update mode of this panorama frame
106  * @param worker Optional worker to distribute the computation, necessary for UM_AVERAGE_GLOBAL update mode only
107  */
108  PanoramaFrame(Frame&& frame, Frame&& mask, const uint8_t maskValue, const UpdateMode updateMode, Worker* worker = nullptr);
109 
110  /**
111  * Default destructor
112  */
113  virtual ~PanoramaFrame() = default;
114 
115  /**
116  * Returns the mask value defining the 8 bit pixel value of valid pixels.
117  * @return The mask value of this panorama frame.
118  */
119  inline uint8_t maskValue() const;
120 
121  /**
122  * Returns the update mode of this panorama frame.
123  * @return The update mode
124  */
125  inline UpdateMode updateMode() const;
126 
127  /**
128  * Returns the current panorama sub-frame (not the maximal possible panorama frame).
129  * @return The current panorama frame
130  * @see frameTopLeft().
131  */
132  inline const Frame& frame() const;
133 
134  /**
135  * Returns the mask of the current panorama frame.
136  * @return The panorama frame mask
137  */
138  inline const Frame& mask() const;
139 
140  /**
141  * Returns the top left position of the current panorama sub-frame.
142  * @return the current top left position of the panorama sub-frame, with range [0, dimensionWidth())x[0, dimensionHeight())
143  */
144  inline const PixelPosition& frameTopLeft() const;
145 
146  /**
147  * Returns the maximal possible width of the entire panorama frame representing horizontal 360 degrees, in pixel.
148  * @return The maximal width of the panorama frame (if the entire frame is covered with pixel information), with range [1, infinity)
149  */
150  inline unsigned int dimensionWidth() const;
151 
152  /**
153  * Returns the maximal possible height of the entire panorama frame representing vertical 180 degrees, in pixel.
154  * @return The maximal height of the panorama frame (if the entire frame is covered with pixel information), with range [1, infinity)
155  */
156  inline unsigned int dimensionHeight() const;
157 
158  /**
159  * Sets or resets the panorama sub-frame (not the maximal possible panorama frame).
160  * @param topLeft The top left position of the given panorama sub-frame, with range [0, dimensionWidth() - frame.width())x[0, dimensionHeight() - frame.height())
161  * @param frame The current panorama sub-frame to be set
162  * @param mask Optional mask defining valid and invalid pixels in the given frame, must have the same frame dimension as the given frame if valid, a default mask defines all pixels in the given panorama sub-frame as valid
163  * @param worker Optional worker object to distribute the computation
164  * @return True, if succeeded
165  */
166  bool setFrame(const PixelPosition& topLeft, const Frame& frame, const Frame& mask = Frame(), Worker* worker = nullptr);
167 
168  /**
169  * Adds a new camera frame to the panorama frame for which the orientation is known.
170  * @param pinholeCamera The pinhole camera profile of the given frame
171  * @param orientation The orientation of the given frame
172  * @param frame The frame to be added
173  * @param mask Optional mask frame defining valid and invalid pixels in the given frame
174  * @param approximationBinSize Optional width of a bin in a lookup table to speedup the in interpolation in pixel, 0u to avoid the application of a lookup table
175  * @param worker Optional worker object to distribute the computation
176  * @return True, if succeeded
177  */
178  bool addFrame(const PinholeCamera& pinholeCamera, const SquareMatrix3& orientation, const Frame& frame, const Frame& mask, const unsigned int approximationBinSize = 20u, Worker* worker = nullptr);
179 
180  /**
181  * Extracts a camera frame from the panorama frame.
182  * @param pinholeCamera The pinhole camera profile to be used
183  * @param orientation The orientation of the camera
184  * @param frame The resulting camera frame, will receive the frame dimension as provided by the camera profile
185  * @param mask The resulting camera mask, will receive the frame dimension as provided by the camera profile
186  * @param approximationBinSize Optional width of a bin in a lookup table to speedup the in interpolation in pixel, 0u to avoid the application of a lookup table
187  * @param worker Optional worker object to distribute the computation
188  * @param fineAdjustment Optional transformation lookup table with relative offsets providing a fine adjustment for the extracted frame
189  * @return True, if succeeded
190  */
191  inline bool extractFrame(const PinholeCamera& pinholeCamera, const SquareMatrix3& orientation, Frame& frame, Frame& mask, const unsigned int approximationBinSize = 20u, Worker* worker = nullptr, const LookupTable* fineAdjustment = nullptr) const;
192 
193  /**
194  * Converts a given pixel position defined in the current camera frame into the pixel position defined in the entire (maximal possible) panorama frame.
195  * @param pinholeCamera The pinhole camera profile matching with the given pixel position
196  * @param orientation The orientation of the camera frame, must be valid
197  * @param cameraPixel The pixel position in the camera frame, with range (-infinity, infinity)x(-infinity, infinity)
198  * @param referenceAngle The reference angle to which the resulting position will be adjusted (so that the position can be located outside the actual panorama frame), with range (-infinity, infinity)x(-infinity, infinity)
199  * @see cameraPixel2panoramaPixelStrict().
200  */
201  inline Vector2 cameraPixel2panoramaPixel(const PinholeCamera& pinholeCamera, const SquareMatrix3& orientation, const Vector2& cameraPixel, const Vector2& referenceAngle) const;
202 
203  /**
204  * Converts a given pixel position defined in the current camera frame into the pixel position defined in the entire (maximal possible) panorama frame.
205  * @param pinholeCamera The pinhole camera profile matching with the given pixel position
206  * @param orientation The orientation of the camera frame,
207  * @param cameraPixel The pixel position in the camera frame, with range [0, camera.width())x[0, camera.height())
208  * @see cameraPixel2panoramaPixel().
209  */
210  inline Vector2 cameraPixel2panoramaPixelStrict(const PinholeCamera& pinholeCamera, const SquareMatrix3& orientation, const Vector2& cameraPixel) const;
211 
212  /**
213  * Converts a given pixel position defined in the entire (maximal possible) panorama frame into the pixel position defined in a camera frame.
214  * @param pinholeCamera The pinhole camera profile matching with the resulting pixel position
215  * @param iOrientation The inverted orientation of the camera frame
216  * @param panoramaPixel The pixel position defined in the entire panorama frame, with range [0, dimensionWidth())x[0, dimensionHeight())
217  */
218  inline Vector2 panoramaPixel2cameraPixel(const PinholeCamera& pinholeCamera, const SquareMatrix3& iOrientation, const Vector2& panoramaPixel) const;
219 
220  /**
221  * Converts an angle in the entire (maximal possible) panorama frame to the corresponding pixel position in the entire panorama frame.
222  * @param angle The horizontal and vertical angle to be converted, with range [-PI, PI)x[PI/2, -PI/2)
223  * @return The resulting pixel position, with range [0, dimensionWidth())[0, dimensionHeight())
224  */
225  inline Vector2 angle2pixel(const Vector2& angle) const;
226 
227  /**
228  * Converts the pixel position in the entire (maximal possible) panorama frame to the corresponding angle in the entire panorama frame.
229  * @param position The position in the panorama frame, with range [0, dimensionWidth())x[0, dimensionHeight())
230  * @return The resulting angle, with range [-PI, PI)x(PI/2, -PI/2)
231  */
232  inline Vector2 pixel2angle(const Vector2& position) const;
233 
234  /**
235  * Copies (interpolates) the entire area of a camera frame with specified camera orientation to a sub-frame of an entire panorama frame.
236  * @param pinholeCamera The pinhole camera profile of the resulting camera frame
237  * @param frame The camera frame to be copied
238  * @param mask Optional 8 bit mask frame specifying valid and invalid pixels, a default frame sets all pixels valid
239  * @param orientation The orientation of the given camera frame
240  * @param panoramaSubFrame The resulting sub-frame of the entire panorama frame
241  * @param panoramaSubMask The mask corresponding with the resulting panorama sub frame
242  * @param subFrameTopLeft The top left position of the resulting panorama frame, with range (-infinity, infinity)x(-infinity, infinity)
243  * @param approximationBinSize Optional width of a bin in a lookup table to speedup the in interpolation in pixel, 0u to avoid the application of a lookup table
244  * @param worker Optional worker object to distribute the computation
245  * @param fineAdjustment Optional transformation lookup table with relative offsets providing a fine adjustment for the given camera frame
246  * @return True, if succeeded
247  */
248  bool cameraFrame2panoramaSubFrame(const PinholeCamera& pinholeCamera, const Frame& frame, const Frame& mask, const SquareMatrix3& orientation, Frame& panoramaSubFrame, Frame& panoramaSubMask, PixelPositionI& subFrameTopLeft, const unsigned int approximationBinSize = 20u, Worker* worker = nullptr, const LookupTable* fineAdjustment = nullptr);
249 
250  /**
251  * Clears the panorama frame and allows to set a new first camera frame.
252  */
253  virtual void clear();
254 
255  /**
256  * Returns whether this panorama frame holds valid configuration parameters and thus can be used.
257  * @return True, if so
258  */
259  inline bool isValid() const;
260 
261  /**
262  * Returns whether this panorama frame holds valid configuration parameters and thus can be used.
263  * @return True, if so
264  */
265  explicit inline operator bool() const;
266 
267  /**
268  * Checks whether two camera frames have a guaranteed intersection.
269  * This function uses the inner field of view (the smallest of either the horizontal or vertical field of view)
270  * and checks whether the angular distance between both camera's principal points is smaller than half of the sum of both field of views.
271  * @param pinholeCamera0 The pinhole camera profile of the first camera frame, must be valid
272  * @param orientation0 The orientation of the first camera frame
273  * @param pinholeCamera1 The pinhole camera profile of the second camera frame, must be valid
274  * @param orientation1 The orientation of the second camera frame
275  * @param overlappingPercent Optional resulting overlapping percentage, the larger the closer both frames are located together, with range [0, 1]
276  * @return True, if both camera frames have a guaranteed intersection
277  */
278  static bool haveIntersectionByInnerFov(const PinholeCamera& pinholeCamera0, const SquareMatrix3& orientation0, const PinholeCamera& pinholeCamera1, const SquareMatrix3& orientation1, Scalar* overlappingPercent = nullptr);
279 
280  /**
281  * Checks whether two camera frames have a guaranteed intersection.
282  * This function shoots rays though the four corners of the camera frame, and through the four center points between neighboring corners.
283  * Thus, for each camera eight rays are given and composed into one viewing frustum.
284  * This function simply counts the number of rays intersecting the viewing frustum of the other camera frame.
285  * Additionally, the viewing frustum can be narrowed by the definition of a border factor to ensure that the intersection area has a specific size.
286  * @param pinholeCamera0 The pinhole camera profile of the first camera frame, must be valid
287  * @param orientation0 The orientation of the first camera frame
288  * @param pinholeCamera1 The pinhole camera profile of the second camera frame, must be valid
289  * @param orientation1 The orientation of the second camera frame
290  * @param borderFactor The border factor allowing to narrow the viewing frustums, a border factor of 0.1 narrows each frustum by 10% on each side, with range [0, 0.5)
291  * @param minimalIntersections The minimal number of rays that must intersect the other camera frustum to count both frames as overlapping, with range [1, 8]
292  * @return True, if the specified number of rays intersect with the other viewing frustum
293  */
294  static bool haveIntersectionByRays(const PinholeCamera& pinholeCamera0, const SquareMatrix3& orientation0, const PinholeCamera& pinholeCamera1, const SquareMatrix3& orientation1, const Scalar borderFactor = Scalar(0.1), const unsigned int minimalIntersections = 2u);
295 
296  /**
297  * Approximate the area of the intersection of two frames
298  * @param pinholeCamera0 The pinhole camera profile of the first camera frame, must be valid
299  * @param orientation0 The orientation of the first camera frame
300  * @param pinholeCamera1 The pinhole camera profile of the second camera frame, must be valid
301  * @param orientation1 The orientation of the second camera frame
302  * @param intersectionRatio If specified, this is the ratio of the intersection area divided by the resolution (height x width) of camera0, otherwise this parameter will be ignored, range: [0, 1]
303  * @return The area of the intersection, range: [0, min(area(camera0), area(camera1))]
304  */
305  static Scalar approximateIntersectionArea(const PinholeCamera& pinholeCamera0, const SquareMatrix3& orientation0, const PinholeCamera& pinholeCamera1, const SquareMatrix3& orientation1, Scalar* intersectionRatio = nullptr);
306 
307  /**
308  * Converts an angle in the entire (maximal possible) panorama frame to the corresponding pixel position in the entire panorama frame.
309  * @param angle The horizontal and vertical angle to be converted, with range (-infinity, infinity)x(-infinity, infinity)
310  * @param panoramaDimensionWidth The width of the maximal possible panorama frame in pixel, [1, infinity)
311  * @param panoramaDimensionHeight THe height of the maximal possible panorama frame in pixel, [1, infinity)
312  * @return The resulting pixel position, with range (-infinity, infinity)x(-infinity, infinity)
313  * @see angle2pixelStrict().
314  */
315  static inline Vector2 angle2pixel(const Vector2& angle, const unsigned int panoramaDimensionWidth, const unsigned int panoramaDimensionHeight);
316 
317  /**
318  * Converts an angle in the entire (maximal possible) panorama frame to the corresponding pixel position in the entire panorama frame.
319  * @param angle The horizontal and vertical angle to be converted, with range [-PI, PI)x[PI/2, -PI/2)
320  * @param panoramaDimensionWidth The width of the maximal possible panorama frame in pixel, [1, infinity)
321  * @param panoramaDimensionHeight THe height of the maximal possible panorama frame in pixel, [1, infinity)
322  * @return The resulting pixel position, with range [0, panoramaDimensionWidth)[0, panoramaDimensionHeight)
323  * @see angle2pixel().
324  */
325  static inline Vector2 angle2pixelStrict(const Vector2& angle, const unsigned int panoramaDimensionWidth, const unsigned int panoramaDimensionHeight);
326 
327  /**
328  * Converts a pixel position in the entire (maximal possible) panorama frame (or outside this panorama frame) to the corresponding angle in the entire panorama frame.
329  * @param position The pixel position in the entire maximal possible panorama frame in pixel, with range (-infinity, infinity)x(-infinity, infinity)
330  * @param invPanoramaDimensionWidth The inverse of the width of the maximal possible panorama frame in pixel, with range (0, 1]
331  * @param invPanoramaDimensionHeight The inverse of the height of the maximal possible panorama frame in pixel, with range (0, 1]
332  * @return The resulting angle, with range (-infinity, infinity)x(-infinity, infinity)
333  * @see pixel2angleStrict().
334  */
335  static inline Vector2 pixel2angle(const Vector2& position, const Scalar invPanoramaDimensionWidth, const Scalar invPanoramaDimensionHeight);
336 
337  /**
338  * Converts a pixel position in the entire (maximal possible) panorama frame to the corresponding angle in the entire panorama frame.
339  * @param position The pixel position in the entire maximal possible panorama frame in pixel, with range [0, panoramaDimensionWidth)x[0, panoramaDimensionHeight)
340  * @param invPanoramaDimensionWidth The inverse of the width of the maximal possible panorama frame in pixel, with range (0, 1]
341  * @param invPanoramaDimensionHeight The inverse of the height of the maximal possible panorama frame in pixel, with range (0, 1]
342  * @return The resulting angle, with range [-PI, PI)x(PI/2, -PI/2)
343  * @see pixel2angle().
344  */
345  static inline Vector2 pixel2angleStrict(const Vector2& position, const Scalar invPanoramaDimensionWidth, const Scalar invPanoramaDimensionHeight);
346 
347  /**
348  * Converts a unit ray starting at the panorama frame's center to the corresponding angle.
349  * @param ray The 3D ray to be transformed
350  * @param referenceAngle The reference angle to which the resulting angle will be adjusted, with range (-infinity, infinity)x(-infinity, infinity)
351  * @return The corresponding angle, with range (-infinity, infinity)x(-infinity, infinity)
352  * @see ray2angleStrict().
353  */
354  static inline Vector2 ray2angle(const Vector3& ray, const Vector2& referenceAngle);
355 
356  /**
357  * Converts a unit ray starting at the panorama frame's center to the corresponding angle.
358  * @param ray The 3D ray to be transformed
359  * @return The corresponding angle, with range [-PI, PI)x(PI/2, -PI/2)
360  * @see ray2angle().
361  */
362  static inline Vector2 ray2angleStrict(const Vector3& ray);
363 
364  /**
365  * Converts an angle in the panorama frame to a unit ray starting at the panorama frame's center.
366  * @param angle The angle to be transformed, with range [-infinity, infinity)x(-infinity, -infinity)
367  * @return The corresponding unit ray in the panorama frame
368  * @see angle2rayStrict().
369  */
370  static inline Vector3 angle2ray(const Vector2& angle);
371 
372  /**
373  * Converts an angle in the panorama frame to a unit ray starting at the panorama frame's center.
374  * @param angle The angle to be transformed, with range [-PI, PI)x(PI/2, -PI/2)
375  * @return The corresponding unit ray in the panorama frame
376  * @see angle2ray().
377  */
378  static inline Vector3 angle2rayStrict(const Vector2& angle);
379 
380  /**
381  * Converts a camera pixel position defined in one frame into a camera pixel position defined in another frame.
382  * @param inputCamera The camera profile of the input camera in which the pixel position is given
383  * @param inputOrientation The orientation of the input camera
384  * @param inputPosition The pixel position defined in the input camera which will be converted to the corresponding pixel position in the output camera
385  * @param outputCamera The camera profile of the output camera
386  * @param outputOrientation The orientation of the output camera
387  * @return Resulting pixel position in the output camera which corresponds to the given input pixel position
388  */
389  static Vector2 cameraPixel2cameraPixel(const PinholeCamera& inputCamera, const SquareMatrix3& inputOrientation, const Vector2& inputPosition, const PinholeCamera& outputCamera, const SquareMatrix3& outputOrientation);
390 
391  /**
392  * Converts a given input camera frame captured with a given orientation into a corresponding camera frame with different orientation.
393  * @param inputCamera The camera profile of the given input frame
394  * @param inputOrientation The orientation of the given input frame (and input camera)
395  * @param inputFrame The input frame which will be converted, the frame dimension must match with the given camera profile
396  * @param inputMask Optional mask defining valid and invalid pixels in the input frame, a default frame sets all pixels as valid
397  * @param outputCamera The camera profile of the resulting output frame
398  * @param outputOrientation The orientation of the resulting output frame
399  * @param outputFrame The resulting output frame, the frame dimension will be set to the given output camera profile
400  * @param outputMask The resulting mask of the output frame defining valid and invalid pixels
401  * @param maskValue The mask value defining valid pixels in the mask frames
402  * @param approximationBinSize Optional width of a bin in a lookup table to speedup the in interpolation in pixel, 0u to avoid the application of a lookup table
403  * @param worker Optional worker object to distribute the computation
404  * @return True, if succeeded
405  */
406  static bool cameraFrame2cameraFrame(const PinholeCamera& inputCamera, const SquareMatrix3& inputOrientation, const Frame& inputFrame, const Frame& inputMask, const PinholeCamera& outputCamera, const SquareMatrix3& outputOrientation, Frame& outputFrame, Frame& outputMask, const uint8_t maskValue, const unsigned int approximationBinSize, Worker* worker);
407 
408  /**
409  * Copies (interpolates) a section from the entire panorama frame to a camera frame with specified camera orientation.
410  * @param pinholeCamera The pinhole camera profile of the resulting camera frame
411  * @param panoramaFrame The sub-frame of the entire (possible maximal) panorama frame from which the resulting camera frame is created
412  * @param panoramaMask The mask frame corresponding with the given panorama frame (with same dimension)
413  * @param panoramaDimensionWidth The maximal width of the entire maximal possible panorama frame, in pixel
414  * @param panoramaDimensionHeight The maximal height of the entire maximal possible panorama frame, in pixel
415  * @param panoramaFrameTopLeft The top left position of the given sub-frame of the panorama frame
416  * @param orientation The orientation of the resulting camera frame
417  * @param cameraFrame The resulting camera frame, will receive the frame dimension as provided by the camera profile
418  * @param cameraMask The resulting camera mask, will receive the frame dimension as provided by the camera profile
419  * @param maskValue The mask value defining a valid mask pixel
420  * @param approximationBinSize Optional width/height of a bin in a lookup table to speedup the in interpolation in pixel, 0u to avoid the application of a lookup table
421  * @param worker Optional worker object to distribute the computation
422  * @param fineAdjustment Optional transformation lookup table with relative offsets providing a fine adjustment for the camera frame
423  * @return True, if succeeded
424  */
425  static bool panoramaFrame2cameraFrame(const PinholeCamera& pinholeCamera, const Frame& panoramaFrame, const Frame& panoramaMask, const unsigned int panoramaDimensionWidth, const unsigned int panoramaDimensionHeight, const PixelPosition& panoramaFrameTopLeft, const SquareMatrix3& orientation, Frame& cameraFrame, Frame& cameraMask, const uint8_t maskValue = 0xFFu, const unsigned int approximationBinSize = 20u, Worker* worker = nullptr, const LookupTable* fineAdjustment = nullptr);
426 
427  /**
428  * Copies (interpolates) the entire area of a camera frame with specified camera orientation to a section of an entire panorama frame.
429  * @param pinholeCamera The pinhole camera profile of the resulting camera frame
430  * @param cameraFrame The camera frame to be copied
431  * @param orientation The orientation of the given camera frame
432  * @param panoramaDimensionWidth The maximal width of the entire maximal possible panorama frame, in pixel
433  * @param panoramaDimensionHeight The maximal height of the entire maximal possible panorama frame, in pixel
434  * @param panoramaFrameTopLeft The top left position of the resulting sub-frame of the panorama frame
435  * @param panoramaFrame The resulting sub-frame of the entire (possible maximal) panorama frame
436  * @param panoramaMask The mask frame corresponding with the resulting panorama frame (with same dimension)
437  * @param maskValue The mask value defining a valid mask pixel
438  * @param approximationBinSize Optional width/height of a bin in a lookup table to speedup the in interpolation in pixel, 0u to avoid the application of a lookup table
439  * @param worker Optional worker object to distribute the computation
440  * @param fineAdjustment Optional transformation lookup table with relative offsets providing a fine adjustment for the given camera frame
441  * @return True, if succeeded
442  */
443  static bool cameraFrame2panoramaFrame(const PinholeCamera& pinholeCamera, const Frame& cameraFrame, const SquareMatrix3& orientation, const unsigned int panoramaDimensionWidth, const unsigned int panoramaDimensionHeight, const PixelPositionI& panoramaFrameTopLeft, Frame& panoramaFrame, Frame& panoramaMask, const uint8_t maskValue = 0xFFu, const unsigned int approximationBinSize = 20u, Worker* worker = nullptr, const LookupTable* fineAdjustment = nullptr);
444 
445  /**
446  * Copies (interpolates) the a subset of a camera frame (specified by a mask) with specified camera orientation to a section of an entire panorama frame.
447  * @param pinholeCamera The pinhole camera profile of the resulting camera frame
448  * @param cameraFrame The camera frame to be copied
449  * @param cameraMask The mask frame corresponding with the camera frame specifying all valid pixels
450  * @param orientation The orientation of the given camera frame
451  * @param panoramaDimensionWidth The maximal width of the entire maximal possible panorama frame, in pixel
452  * @param panoramaDimensionHeight The maximal height of the entire maximal possible panorama frame, in pixel
453  * @param panoramaFrameTopLeft The top left position of the resulting sub-frame of the panorama frame
454  * @param panoramaFrame The resulting sub-frame of the entire (possible maximal) panorama frame
455  * @param panoramaMask The mask frame corresponding with the resulting panorama frame (with same dimension)
456  * @param maskValue The mask value defining a valid mask pixel
457  * @param approximationBinSize Optional width/height of a bin in a lookup table to speedup the in interpolation in pixel, 0u to avoid the application of a lookup table
458  * @param worker Optional worker object to distribute the computation
459  * @param fineAdjustment Optional transformation lookup table with relative offsets providing a fine adjustment for the given camera frame
460  * @return True, if succeeded
461  */
462  static bool cameraFrame2panoramaFrame(const PinholeCamera& pinholeCamera, const Frame& cameraFrame, const Frame& cameraMask, const SquareMatrix3& orientation, const unsigned int panoramaDimensionWidth, const unsigned int panoramaDimensionHeight, const PixelPositionI& panoramaFrameTopLeft, Frame& panoramaFrame, Frame& panoramaMask, const uint8_t maskValue = 0xFFu, const unsigned int approximationBinSize = 20u, Worker* worker = nullptr, const LookupTable* fineAdjustment = nullptr);
463 
464  /**
465  * Converts a given input camera frame with 8 bit per channel captured with a given orientation into a corresponding camera frame with different orientation.
466  * @param inputCamera The camera profile of the given input frame
467  * @param inputOrientation The orientation of the given input frame (and input camera)
468  * @param inputFrame The input frame which will be converted, the frame dimension must match with the given camera profile
469  * @param inputMask Optional mask defining valid and invalid pixels in the input frame, a default frame sets all pixels as valid
470  * @param inputFramePaddingElements The number of padding elements of the input frame, range: [0, infinity)
471  * @param inputMaskPaddingElements The number of padding elements of the input mask, range: [0, infinity)
472  * @param outputCamera The camera profile of the resulting output frame
473  * @param outputOrientation The orientation of the resulting output frame
474  * @param outputFrame The resulting output frame
475  * @param outputMask The resulting mask of the output frame defining valid and invalid pixels
476  * @param outputFramePaddingElements The number of padding elements of the output frame, range: [0, infinity)
477  * @param outputMaskPaddingElements The number of padding elements of the output mask, range: [0, infinity)
478  * @param maskValue The mask value defining valid pixels in the mask frames
479  * @param approximationBinSize Optional width of a bin in a lookup table to speedup the in interpolation in pixel, 0u to avoid the application of a lookup table
480  * @param worker Optional worker object to distribute the computation
481  * @tparam tChannels The number of frame data channels
482  */
483  template <unsigned int tChannels>
484  static inline void cameraFrame2cameraFrame8BitPerChannel(const PinholeCamera& inputCamera, const SquareMatrix3& inputOrientation, const uint8_t* inputFrame, const uint8_t* inputMask, const unsigned int inputFramePaddingElements, const unsigned int inputMaskPaddingElements, const PinholeCamera& outputCamera, const SquareMatrix3& outputOrientation, uint8_t* outputFrame, uint8_t* outputMask, const unsigned int outputFramePaddingElements, const unsigned int outputMaskPaddingElements, const uint8_t maskValue, const unsigned int approximationBinSize, Worker* worker);
485 
486  /**
487  * Copies (interpolates) a section from the entire panorama frame with 8 bit per data channel to a camera frame with specified camera orientation.
488  * @param pinholeCamera The pinhole camera profile of the resulting camera frame
489  * @param panoramaFrame The sub-frame of the entire (possible maximal) panorama frame from which the resulting camera frame is created
490  * @param panoramaMask The mask frame corresponding with the given panorama frame (with same dimension)
491  * @param panoramaFrameWidth The width of the given panorama frame in pixel, with range [1, panoramaDimensionWidth]
492  * @param panoramaFrameHeight The height of the given panorama frame in pixel, with range [1, panoramaDimensionHeight]
493  * @param panoramaFramePaddingElements The number of padding elements at the end of each panorama frame row, in elements, with range [0, infinity)
494  * @param panoramaMaskPaddingElements The number of padding elements at the end of each panorama mask row, in elements, with range [0, infinity)
495  * @param panoramaDimensionWidth The maximal width of the entire maximal possible panorama frame, in pixel
496  * @param panoramaDimensionHeight The maximal height of the entire maximal possible panorama frame, in pixel
497  * @param panoramaFrameTopLeft The top left position of the given sub-frame of the panorama frame
498  * @param orientation The orientation of the resulting camera frame
499  * @param cameraFrame The resulting camera frame with frame dimension as provided by the camera profile
500  * @param cameraMask The resulting camera mask with frame dimension as provided by the camera profile
501  * @param cameraFramePaddingElements The number of padding elements at the end of each camera frame row, in elements, with range [0, infinity)
502  * @param cameraMaskPaddingElements The number of padding elements at the end of each camera mask row, in elements, with range [0, infinity)
503  * @param maskValue The mask value defining a valid mask pixel
504  * @param approximationBinSize Optional width/height of a bin in a lookup table to speedup the in interpolation in pixel, 0u to avoid the application of a lookup table
505  * @param worker Optional worker object to distribute the computation
506  * @param fineAdjustment Optional transformation lookup table with relative offsets providing a fine adjustment for the camera frame
507  * @tparam tChannels The number of frame data channels
508  */
509  template <unsigned int tChannels>
510  static inline void panoramaFrame2cameraFrame8BitPerChannel(const PinholeCamera& pinholeCamera, const uint8_t* panoramaFrame, const uint8_t* panoramaMask, const unsigned int panoramaFrameWidth, const unsigned int panoramaFrameHeight, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const unsigned int panoramaDimensionWidth, const unsigned int panoramaDimensionHeight, const PixelPosition& panoramaFrameTopLeft, const SquareMatrix3& orientation, uint8_t* cameraFrame, uint8_t* cameraMask, const unsigned int cameraFramePaddingElements, const unsigned int cameraMaskPaddingElements, const uint8_t maskValue = 0xFFu, const unsigned int approximationBinSize = 20u, Worker* worker = nullptr, const LookupTable* fineAdjustment = nullptr);
511 
512  /**
513  * Copies (interpolates) the entire area of an 8 bit per data channel camera frame with specified camera orientation to a section of an entire panorama frame.
514  * @param pinholeCamera The pinhole camera profile of the resulting camera frame
515  * @param cameraFrame The camera frame to be copied
516  * @param cameraFramePaddingElements The number of padding elements at the end of each camera frame row, in elements, with range [0, infinity)
517  * @param orientation The orientation of the given camera frame
518  * @param panoramaDimensionWidth The maximal width of the entire maximal possible panorama frame, in pixel
519  * @param panoramaDimensionHeight The maximal height of the entire maximal possible panorama frame, in pixel
520  * @param panoramaFrameTopLeft The top left position of the resulting sub-frame of the panorama frame
521  * @param panoramaFrame The resulting sub-frame of the entire (possible maximal) panorama frame
522  * @param panoramaMask The mask frame corresponding with the resulting panorama frame (with same dimension)
523  * @param panoramaFrameWidth The width of the resulting panorama frame in pixel, with range [1, panoramaDimensionWidth]
524  * @param panoramaFrameHeight The height of the resulting panorama frame in pixel, with range [1, panoramaDimensionHeight]
525  * @param panoramaFramePaddingElements The number of padding elements at the end of each panorama frame row, in elements, with range [0, infinity)
526  * @param panoramaMaskPaddingElements The number of padding elements at the end of each panorama mask row, in elements, with range [0, infinity)
527  * @param maskValue The mask value defining a valid mask pixel
528  * @param approximationBinSize Optional width/height of a bin in a lookup table to speedup the in interpolation in pixel, 0u to avoid the application of a lookup table
529  * @param worker Optional worker object to distribute the computation
530  * @param fineAdjustment Optional transformation lookup table with relative offsets providing a fine adjustment for the given camera frame
531  * @tparam tChannels The number of frame data channels
532  */
533  template <unsigned int tChannels>
534  static inline void cameraFrame2panoramaFrame8BitPerChannel(const PinholeCamera& pinholeCamera, const uint8_t* cameraFrame, const unsigned int cameraFramePaddingElements, const SquareMatrix3& orientation, const unsigned int panoramaDimensionWidth, const unsigned int panoramaDimensionHeight, const PixelPositionI& panoramaFrameTopLeft, uint8_t* panoramaFrame, uint8_t* panoramaMask, const unsigned int panoramaFrameWidth, const unsigned int panoramaFrameHeight, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const uint8_t maskValue = 0xFFu, const unsigned int approximationBinSize = 20u, Worker* worker = nullptr, const LookupTable* fineAdjustment = nullptr);
535 
536  /**
537  * Copies (interpolates) a subset of an 8 bit per data channel camera frame (specified by a mask) with specified camera orientation to a section of an entire panorama frame.
538  * @param pinholeCamera The pinhole camera profile of the resulting camera frame
539  * @param cameraFrame The camera frame to be copied
540  * @param cameraMask The mask of camera frame specifying valid pixels
541  * @param cameraFramePaddingElements The number of padding elements at the end of each camera frame row, in elements, with range [0, infinity)
542  * @param cameraMaskPaddingElements The number of padding elements at the end of each camera mask row, in elements, with range [0, infinity)
543  * @param orientation The orientation of the given camera frame
544  * @param panoramaDimensionWidth The maximal width of the entire maximal possible panorama frame, in pixel
545  * @param panoramaDimensionHeight The maximal height of the entire maximal possible panorama frame, in pixel
546  * @param panoramaFrameTopLeft The top left position of the resulting sub-frame of the panorama frame
547  * @param panoramaFrame The resulting sub-frame of the entire (possible maximal) panorama frame
548  * @param panoramaMask The mask frame corresponding with the resulting panorama frame (with same dimension)
549  * @param panoramaFrameWidth The width of the resulting panorama frame in pixel, with range [1, panoramaDimensionWidth]
550  * @param panoramaFrameHeight The height of the resulting panorama frame in pixel, with range [1, panoramaDimensionHeight]
551  * @param panoramaFramePaddingElements The number of padding elements at the end of each panorama frame row, in elements, with range [0, infinity)
552  * @param panoramaMaskPaddingElements The number of padding elements at the end of each panorama mask row, in elements, with range [0, infinity)
553  * @param maskValue The mask value defining a valid mask pixel
554  * @param approximationBinSize Optional width/height of a bin in a lookup table to speedup the in interpolation in pixel, 0u to avoid the application of a lookup table
555  * @param worker Optional worker object to distribute the computation
556  * @param fineAdjustment Optional transformation lookup table with relative offsets providing a fine adjustment for the given camera frame
557  * @tparam tChannels The number of frame data channels
558  */
559  template <unsigned int tChannels>
560  static inline void cameraFrame2panoramaFrameMask8BitPerChannel(const PinholeCamera& pinholeCamera, const uint8_t* cameraFrame, const uint8_t* cameraMask, const unsigned int cameraFramePaddingElements, const unsigned int cameraMaskPaddingElements, const SquareMatrix3& orientation, const unsigned int panoramaDimensionWidth, const unsigned int panoramaDimensionHeight, const PixelPositionI& panoramaFrameTopLeft, uint8_t* panoramaFrame, uint8_t* panoramaMask, const unsigned int panoramaFrameWidth, const unsigned int panoramaFrameHeight, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const uint8_t maskValue = 0xFFu, const unsigned int approximationBinSize = 20u, Worker* worker = nullptr, const LookupTable* fineAdjustment = nullptr);
561 
562  protected:
563 
564  /**
565  * Determines the bounding box for a camera frame with given orientation in the panorama frame.
566  * @param pinholeCamera The pinhole camera profile (also defining the dimension of the camera frame)
567  * @param orientation The orientation of the camera frame
568  * @return The resulting bounding box of the camera frame projected in the panorama frame, may be located outside the entire panorama frame
569  */
570  Box2 panoramaSubFrameBoundingBox(const PinholeCamera& pinholeCamera, const SquareMatrix3& orientation) const;
571 
572  /**
573  * Updates the panorama frame data with a new camera frame.
574  * @param pinholeCamera The pinhole camera profile of the camera frame
575  * @param frame The camera frame to update the panorama frame
576  * @param mask Optional mask frame specifying valid and invalid pixels, a default frame sets all pixels as valid
577  * @param orientation The orientation of the camera frame
578  * @param approximationBinSize Optional width/height of a bin in a lookup table to speedup the in interpolation in pixel, 0u to avoid the application of a lookup table
579  * @param worker Optional worker object to distribute the computation
580  * @param fineAdjustment Optional transformation lookup table with relative offsets providing a fine adjustment for the given camera frame, with size identical to the camera dimension
581  */
582  bool update(const PinholeCamera& pinholeCamera, const Frame& frame, const Frame& mask, const SquareMatrix3& orientation, const unsigned int approximationBinSize = 20u, Worker* worker = nullptr, const LookupTable* fineAdjustment = nullptr);
583 
584  /**
585  * Resets the panorama frame of this object by one new single camera frame.
586  * @param pinholeCamera The pinhole camera profile of the camera frame
587  * @param frame The new camera frame which will define the new panorama frame
588  * @param orientation The orientation of the given camera frame
589  * @param approximationBinSize Optional width/height of a bin in a lookup table to speedup the in interpolation in pixel, 0u to avoid the application of a lookup table
590  * @param worker Optional worker object to distribute the computation
591  * @return True, if succeeded
592  */
593  bool reset(const PinholeCamera& pinholeCamera, const Frame& frame, const SquareMatrix3& orientation, const unsigned int approximationBinSize = 20u, Worker* worker = nullptr);
594 
595  /**
596  * Resets the panorama frame of this object by one new panorama sub-frame.
597  * @param topLeft The top left position of the given panorama sub frame
598  * @param frame The new panorama sub-frame to be set
599  * @param mask Optional the mask defining valid and invalid pixels in the given sub-frame, must match the dimension of the panoramaFrame if valid, a default frame set all panorama pixels valid
600  * @param worker Optional worker object to distribute the computation
601  * @return True, if succeeded
602  */
603  bool reset(const PixelPosition& topLeft, const Frame& frame, const Frame& mask, Worker* worker = nullptr);
604 
605  /**
606  * Resizes the internal panorama sub-frame.
607  * @param topLeft The new top left position of the panorama sub-frame
608  * @param width The new width of the panorama sub-frame, with range [1, dimensionWidth() - topLeft.x())
609  * @param height The new height of the panorama sub-frame, with range [1, dimensionHeight() - topLeft.y())
610  */
611  void resize(const PixelPosition& topLeft, const unsigned int width, const unsigned int height);
612 
613  /**
614  * Merges a given panorama sub-frame with given top left start position with the panorama frame of this object by application of the update mode of this object.
615  * @param panoramaSubFrame The panorama sub-frame which will be merged with the current panorama frame
616  * @param panoramaSubMask The mask matching with the given sub-frame specifying valid pixels
617  * @param subTopLeft The top left position of the given panorama sub-frame
618  * @param worker Optional worker object to distribute the computation
619  * @return True, if succeeded
620  */
621  bool merge(const Frame& panoramaSubFrame, const Frame& panoramaSubMask, const PixelPosition& subTopLeft, Worker* worker = nullptr);
622 
623  /**
624  * Creates a 2D lookup table allowing to interpolate pixel locations defined in one camera frame to pixel locations defined in another camera frame.
625  * @param inputCamera The camera profile of the input camera frame, must be valid
626  * @param world_R_input The orientation between the input camera and world, must be valid
627  * @param outputCamera The camera profile of the output camera frame, must be valid
628  * @param world_R_output The orientation between the output camera and world, must be valid
629  * @param input_LT_output The resulting lookup table transforming output locations to input locations
630  */
631  static void cameraFrame2cameraFrameLookupTable(const PinholeCamera& inputCamera, const SquareMatrix3& world_R_input, const PinholeCamera& outputCamera, const SquareMatrix3& world_R_output, LookupTable& input_LT_output);
632 
633  /**
634  * Creates a 2D lookup table allowing to interpolate positions defined in the camera frame to positions defined in the panorama sub-frame.
635  * @param pinholeCamera The pinhole camera profile of the camera frame
636  * @param orientation The orientation of the camera
637  * @param panoramaDimensionWidth The maximal width of the entire maximal possible panorama frame, in pixel
638  * @param panoramaDimensionHeight The maximal height of the entire maximal possible panorama frame, in pixel
639  * @param panoramaFrameTopLeft The top left position of the panorama sub-frame
640  * @param lookupTable The resulting lookup table
641  * @param fineAdjustment Optional transformation lookup table with relative offsets providing a fine adjustment for the camera frame
642  */
643  static void panoramaFrame2cameraFrameLookupTable(const PinholeCamera& pinholeCamera, const SquareMatrix3& orientation, const unsigned int panoramaDimensionWidth, const unsigned int panoramaDimensionHeight, const PixelPosition& panoramaFrameTopLeft, LookupTable& lookupTable, const LookupTable* fineAdjustment);
644 
645  /**
646  * Creates a 2D lookup table allowing to interpolate positions defined in the entire panorama frame to positions defined in the camera frame.
647  * @param pinholeCamera The pinhole camera profile of the camera frame
648  * @param orientation The orientation of the camera
649  * @param panoramaDimensionWidth The maximal width of the entire maximal possible panorama frame, in pixel
650  * @param panoramaDimensionHeight The maximal height of the entire maximal possible panorama frame, in pixel
651  * @param panoramaFrameTopLeft The top left position of the panorama sub-frame within the entire panorama frame, with range (-infinity, infinity)x(-infinity, infinity)
652  * @param lookupTable The resulting lookup table
653  * @param fineAdjustment Optional transformation lookup table with relative offsets providing a fine adjustment for the given camera frame
654  */
655  static void cameraFrame2panoramaFrameLookupTable(const PinholeCamera& pinholeCamera, const SquareMatrix3& orientation, const unsigned int panoramaDimensionWidth, const unsigned int panoramaDimensionHeight, const PixelPositionI& panoramaFrameTopLeft, LookupTable& lookupTable, const LookupTable* fineAdjustment);
656 
657  /**
658  * Merges a given panorama sub frame with the already existing panorama frame by setting all valid pixels of the sub frame.
659  * @param panoramaSubFrame The panorama sub frame which will be merged with the existing panorama frame
660  * @param panoramaSubMask The mask of the panorama sub frame defining valid and invalid pixels
661  * @param subFrameWidth The width of the panorama sub frame in pixel, with range [1, panoramaWidth - subTopLeft.x()]
662  * @param subFrameHeight The height of the panorama sub frame in pixel, with range [1, panoramaHeight - subTopLeft.y()]
663  * @param panoramaSubFramePaddingElements The number of padding elements at the end of each sub frame row, in elements, with range [0, infinity)
664  * @param panoramaSubMaskPaddingElements The number of padding elements at the end of each sub mask row, in elements, with range [0, infinity)
665  * @param subTopLeft The top left position of the sub frame, with range [0, panoramaTopLeft.x() + panoramaWidth)x[0, panoramaTopLeft.y() + panoramaHeight)
666  * @param panoramaFrame The existing panorama frame which will receive the new image information
667  * @param panoramaMask The mask of the existing panorama frame
668  * @param panoramaWidth The width of the panorama frame in pixel
669  * @param panoramaFramePaddingElements The number of padding elements at the end of each panorama frame row, in elements, with range [0, infinity)
670  * @param panoramaMaskPaddingElements The number of padding elements at the end of each panorama mask row, in elements, with range [0, infinity)
671  * @param panoramaTopLeft The top left position of the panorama frame
672  * @param maskValue The mask value defining valid pixels
673  * @param worker Optional worker object to distribute the computation
674  * @tparam tChannels The number of frame data channels
675  * @see mergeSetAll8BitPerChannelSubset().
676  */
677  template <unsigned int tChannels>
678  static inline void mergeSetAll8BitPerChannel(const uint8_t* panoramaSubFrame, const uint8_t* panoramaSubMask, const unsigned int subFrameWidth, const unsigned int subFrameHeight, const unsigned int panoramaSubFramePaddingElements, const unsigned panoramaSubMaskPaddingElements, const PixelPosition& subTopLeft, uint8_t* panoramaFrame, uint8_t* panoramaMask, const unsigned int panoramaWidth, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const PixelPosition& panoramaTopLeft, const uint8_t maskValue, Worker* worker = nullptr);
679 
680  /**
681  * Merges a given panorama sub frame with the already existing panorama frame by setting only pixels which haven't been set before.
682  * @param panoramaSubFrame The panorama sub frame which will be merged with the existing panorama frame
683  * @param panoramaSubMask The mask of the panorama sub frame defining valid and invalid pixels
684  * @param subFrameWidth The width of the panorama sub frame in pixel, with range [1, panoramaWidth - subTopLeft.x()]
685  * @param subFrameHeight The height of the panorama sub frame in pixel, with range [1, panoramaHeight - subTopLeft.y()]
686  * @param panoramaSubFramePaddingElements The number of padding elements at the end of each sub frame row, in elements, with range [0, infinity)
687  * @param panoramaSubMaskPaddingElements The number of padding elements at the end of each sub mask row, in elements, with range [0, infinity)
688  * @param subTopLeft The top left position of the sub frame, with range [0, panoramaTopLeft.x() + panoramaWidth)x[0, panoramaTopLeft.y() + panoramaHeight)
689  * @param panoramaFrame The existing panorama frame which will receive the new image information
690  * @param panoramaMask The mask of the existing panorama frame
691  * @param panoramaWidth The width of the panorama frame in pixel
692  * @param panoramaFramePaddingElements The number of padding elements at the end of each panorama frame row, in elements, with range [0, infinity)
693  * @param panoramaMaskPaddingElements The number of padding elements at the end of each panorama mask row, in elements, with range [0, infinity)
694  * @param panoramaTopLeft The top left position of the panorama frame
695  * @param maskValue The mask value defining valid pixels
696  * @param worker Optional worker object to distribute the computation
697  * @tparam tChannels The number of frame data channels
698  * @see mergeSetNew8BitPerChannelSubset().
699  */
700  template <unsigned int tChannels>
701  static inline void mergeSetNew8BitPerChannel(const uint8_t* panoramaSubFrame, const uint8_t* panoramaSubMask, const unsigned int subFrameWidth, const unsigned int subFrameHeight, const unsigned int panoramaSubFramePaddingElements, const unsigned panoramaSubMaskPaddingElements, const PixelPosition& subTopLeft, uint8_t* panoramaFrame, uint8_t* panoramaMask, const unsigned int panoramaWidth, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const PixelPosition& panoramaTopLeft, const uint8_t maskValue, Worker* worker = nullptr);
702 
703  /**
704  * Merges a given panorama sub frame with the already existing panorama frame by averaging the current pixel value with the given pixel value.
705  * @param panoramaSubFrame The panorama sub frame which will be merged with the existing panorama frame
706  * @param panoramaSubMask The mask of the panorama sub frame defining valid and invalid pixels
707  * @param subFrameWidth The width of the panorama sub frame in pixel, with range [1, panoramaWidth - subTopLeft.x()]
708  * @param subFrameHeight The height of the panorama sub frame in pixel, with range [1, panoramaHeight - subTopLeft.y()]
709  * @param panoramaSubFramePaddingElements The number of padding elements at the end of each sub frame row, in elements, with range [0, infinity)
710  * @param panoramaSubMaskPaddingElements The number of padding elements at the end of each sub mask row, in elements, with range [0, infinity)
711  * @param subTopLeft The top left position of the sub frame, with range [0, panoramaTopLeft.x() + panoramaWidth)x[0, panoramaTopLeft.y() + panoramaHeight)
712  * @param panoramaFrame The existing panorama frame which will receive the new image information
713  * @param panoramaMask The mask of the existing panorama frame
714  * @param panoramaWidth The width of the panorama frame in pixel
715  * @param panoramaFramePaddingElements The number of padding elements at the end of each panorama frame row, in elements, with range [0, infinity)
716  * @param panoramaMaskPaddingElements The number of padding elements at the end of each panorama mask row, in elements, with range [0, infinity)
717  * @param panoramaTopLeft The top left position of the panorama frame
718  * @param maskValue The mask value defining valid pixels
719  * @param worker Optional worker object to distribute the computation
720  * @tparam tChannels The number of frame data channels
721  * @see mergeAverageLocal8BitPerChannelSubset().
722  */
723  template <unsigned int tChannels>
724  static inline void mergeAverageLocal8BitPerChannel(const uint8_t* panoramaSubFrame, const uint8_t* panoramaSubMask, const unsigned int subFrameWidth, const unsigned int subFrameHeight, const unsigned int panoramaSubFramePaddingElements, const unsigned panoramaSubMaskPaddingElements, const PixelPosition& subTopLeft, uint8_t* panoramaFrame, uint8_t* panoramaMask, const unsigned int panoramaWidth, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const PixelPosition& panoramaTopLeft, const uint8_t maskValue, Worker* worker = nullptr);
725 
726  /**
727  * Merges a given panorama sub frame with the already existing panorama frame by averaging the all pixel values from the past and the current pixel values.
728  * @param panoramaSubFrame The panorama sub frame which will be merged with the existing panorama frame
729  * @param panoramaSubMask The mask of the panorama sub frame defining valid and invalid pixels
730  * @param subFrameWidth The width of the panorama sub frame in pixel, with range [1, panoramaWidth - subTopLeft.x()]
731  * @param subFrameHeight The height of the panorama sub frame in pixel, with range [1, panoramaHeight - subTopLeft.y()]
732  * @param panoramaSubFramePaddingElements The number of padding elements at the end of each sub frame row, in elements, with range [0, infinity)
733  * @param panoramaSubMaskPaddingElements The number of padding elements at the end of each sub mask row, in elements, with range [0, infinity)
734  * @param subTopLeft The top left position of the sub frame, with range [0, panoramaTopLeft.x() + panoramaWidth)x[0, panoramaTopLeft.y() + panoramaHeight)
735  * @param panoramaNominatorFrame The nominator frame of the panorama frame summing all individual pixels values
736  * @param panoramaDenominatorFrame The denominator frame of the panorama frame storing the number of summed pixels individually for every pixel
737  * @param panoramaFrame The existing panorama frame which will receive the new image information
738  * @param panoramaMask The mask of the existing panorama frame
739  * @param panoramaWidth The width of the panorama frame in pixel
740  * @param panoramaFramePaddingElements The number of padding elements at the end of each panorama frame row, in elements, with range [0, infinity)
741  * @param panoramaMaskPaddingElements The number of padding elements at the end of each panorama mask row, in elements, with range [0, infinity)
742  * @param panoramaTopLeft The top left position of the panorama frame
743  * @param maskValue The mask value defining valid pixels
744  * @param worker Optional worker object to distribute the computation
745  * @tparam tChannels The number of frame data channels
746  * @see mergeAverageGlobal8BitPerChannelSubset().
747  */
748  template <unsigned int tChannels>
749  static inline void mergeAverageGlobal8BitPerChannel(const uint8_t* panoramaSubFrame, const uint8_t* panoramaSubMask, const unsigned int subFrameWidth, const unsigned int subFrameHeight, const unsigned int panoramaSubFramePaddingElements, const unsigned panoramaSubMaskPaddingElements, const PixelPosition& subTopLeft, uint32_t* panoramaNominatorFrame, uint32_t* panoramaDenominatorFrame, uint8_t* panoramaFrame, uint8_t* panoramaMask, const unsigned int panoramaWidth, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const PixelPosition& panoramaTopLeft, const uint8_t maskValue, Worker* worker = nullptr);
750 
751  /**
752  * Merges a subset of a given panorama sub frame with the already existing panorama frame by setting all valid pixels of the sub frame.
753  * @param panoramaSubFrame The panorama sub frame which will be merged with the existing panorama frame
754  * @param panoramaSubMask The mask of the panorama sub frame defining valid and invalid pixels
755  * @param subFrameWidth The width of the panorama sub frame in pixel, with range [1, panoramaWidth - subTopLeft.x()]
756  * @param panoramaSubFramePaddingElements The number of padding elements at the end of each sub frame row, in elements, with range [0, infinity)
757  * @param panoramaSubMaskPaddingElements The number of padding elements at the end of each sub mask row, in elements, with range [0, infinity)
758  * @param subTopLeftX The horizontal top left position of the sub frame, with range [0, panoramaTopLeft.x() + panoramaWidth)
759  * @param subTopLeftY The vertical top left position of the sub frame, with range [0, panoramaTopLeft.x() + panoramaWidth)
760  * @param panoramaFrame The existing panorama frame which will receive the new image information
761  * @param panoramaMask The mask of the existing panorama frame
762  * @param panoramaWidth The width of the panorama frame in pixel
763  * @param panoramaFramePaddingElements The number of padding elements at the end of each panorama frame row, in elements, with range [0, infinity)
764  * @param panoramaMaskPaddingElements The number of padding elements at the end of each panorama mask row, in elements, with range [0, infinity)
765  * @param panoramaTopLeftX The horizontal top left position of the panorama frame
766  * @param panoramaTopLeftY The vertical top left position of the panorama frame
767  * @param maskValue The mask value defining valid pixels
768  * @param firstSubRow The first sub row to be handled
769  * @param numberSubRows The number of sub rows to be handled
770  * @tparam tChannels The number of frame data channels
771  * @see mergeSetAll8BitPerChannel().
772  */
773  template <unsigned int tChannels>
774  static void mergeSetAll8BitPerChannelSubset(const uint8_t* panoramaSubFrame, const uint8_t* panoramaSubMask, const unsigned int subFrameWidth, const unsigned int panoramaSubFramePaddingElements, const unsigned int panoramaSubMaskPaddingElements, const unsigned int subTopLeftX, const unsigned int subTopLeftY, uint8_t* panoramaFrame, uint8_t* panoramaMask, const unsigned int panoramaWidth, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const unsigned int panoramaTopLeftX, const unsigned int panoramaTopLeftY, const uint8_t maskValue, const unsigned int firstSubRow, const unsigned int numberSubRows);
775 
776  /**
777  * Merges a subset of a given panorama sub frame with the already existing panorama frame by setting only pixels which haven't been set before.
778  * @param panoramaSubFrame The panorama sub frame which will be merged with the existing panorama frame
779  * @param panoramaSubMask The mask of the panorama sub frame defining valid and invalid pixels
780  * @param subFrameWidth The width of the panorama sub frame in pixel, with range [1, panoramaWidth - subTopLeft.x()]
781  * @param panoramaSubFramePaddingElements The number of padding elements at the end of each sub frame row, in elements, with range [0, infinity)
782  * @param panoramaSubMaskPaddingElements The number of padding elements at the end of each sub mask row, in elements, with range [0, infinity)
783  * @param subTopLeftX The horizontal top left position of the sub frame, with range [0, panoramaTopLeft.x() + panoramaWidth)
784  * @param subTopLeftY The vertical top left position of the sub frame, with range [0, panoramaTopLeft.x() + panoramaWidth)
785  * @param panoramaFrame The existing panorama frame which will receive the new image information
786  * @param panoramaMask The mask of the existing panorama frame
787  * @param panoramaWidth The width of the panorama frame in pixel
788  * @param panoramaFramePaddingElements The number of padding elements at the end of each panorama frame row, in elements, with range [0, infinity)
789  * @param panoramaMaskPaddingElements The number of padding elements at the end of each panorama mask row, in elements, with range [0, infinity)
790  * @param panoramaTopLeftX The horizontal top left position of the panorama frame
791  * @param panoramaTopLeftY The vertical top left position of the panorama frame
792  * @param maskValue The mask value defining valid pixels
793  * @param firstSubRow The first sub row to be handled
794  * @param numberSubRows The number of sub rows to be handled
795  * @tparam tChannels The number of frame data channels
796  * @see mergeSetNew8BitPerChannel().
797  */
798  template <unsigned int tChannels>
799  static void mergeSetNew8BitPerChannelSubset(const uint8_t* panoramaSubFrame, const uint8_t* panoramaSubMask, const unsigned int subFrameWidth, const unsigned int panoramaSubFramePaddingElements, const unsigned int panoramaSubMaskPaddingElements, const unsigned int subTopLeftX, const unsigned int subTopLeftY, uint8_t* panoramaFrame, uint8_t* panoramaMask, const unsigned int panoramaWidth, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const unsigned int panoramaTopLeftX, const unsigned int panoramaTopLeftY, const uint8_t maskValue, const unsigned int firstSubRow, const unsigned int numberSubRows);
800 
801  /**
802  * Merges a subset of a given panorama sub frame with the already existing panorama frame by averaging the current pixel value with the given pixel value.
803  * @param panoramaSubFrame The panorama sub frame which will be merged with the existing panorama frame
804  * @param panoramaSubMask The mask of the panorama sub frame defining valid and invalid pixels
805  * @param subFrameWidth The width of the panorama sub frame in pixel, with range [1, panoramaWidth - subTopLeft.x()]
806  * @param panoramaSubFramePaddingElements The number of padding elements at the end of each sub frame row, in elements, with range [0, infinity)
807  * @param panoramaSubMaskPaddingElements The number of padding elements at the end of each sub mask row, in elements, with range [0, infinity)
808  * @param subTopLeftX The horizontal top left position of the sub frame, with range [0, panoramaTopLeft.x() + panoramaWidth)
809  * @param subTopLeftY The vertical top left position of the sub frame, with range [0, panoramaTopLeft.x() + panoramaWidth)
810  * @param panoramaFrame The existing panorama frame which will receive the new image information
811  * @param panoramaMask The mask of the existing panorama frame
812  * @param panoramaWidth The width of the panorama frame in pixel
813  * @param panoramaFramePaddingElements The number of padding elements at the end of each panorama frame row, in elements, with range [0, infinity)
814  * @param panoramaMaskPaddingElements The number of padding elements at the end of each panorama mask row, in elements, with range [0, infinity)
815  * @param panoramaTopLeftX The horizontal top left position of the panorama frame
816  * @param panoramaTopLeftY The vertical top left position of the panorama frame
817  * @param maskValue The mask value defining valid pixels
818  * @param firstSubRow The first sub row to be handled
819  * @param numberSubRows The number of sub rows to be handled
820  * @tparam tChannels The number of frame data channels
821  * @see mergeAverageLocal8BitPerChannel().
822  */
823  template <unsigned int tChannels>
824  static void mergeAverageLocal8BitPerChannelSubset(const uint8_t* panoramaSubFrame, const uint8_t* panoramaSubMask, const unsigned int subFrameWidth, const unsigned int panoramaSubFramePaddingElements, const unsigned int panoramaSubMaskPaddingElements, const unsigned int subTopLeftX, const unsigned int subTopLeftY, uint8_t* panoramaFrame, uint8_t* panoramaMask, const unsigned int panoramaWidth, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const unsigned int panoramaTopLeftX, const unsigned int panoramaTopLeftY, const uint8_t maskValue, const unsigned int firstSubRow, const unsigned int numberSubRows);
825 
826  /**
827  * Merges a subset of a given panorama sub frame with the already existing panorama frame by averaging the all pixel values from the past and the current pixel values.
828  * @param panoramaSubFrame The panorama sub frame which will be merged with the existing panorama frame
829  * @param panoramaSubMask The mask of the panorama sub frame defining valid and invalid pixels
830  * @param subFrameWidth The width of the panorama sub frame in pixel, with range [1, panoramaWidth - subTopLeft.x()]
831  * @param panoramaSubFramePaddingElements The number of padding elements at the end of each sub frame row, in elements, with range [0, infinity)
832  * @param panoramaSubMaskPaddingElements The number of padding elements at the end of each sub mask row, in elements, with range [0, infinity)
833  * @param subTopLeftX The horizontal top left position of the sub frame, with range [0, panoramaTopLeft.x() + panoramaWidth)
834  * @param subTopLeftY The vertical top left position of the sub frame, with range [0, panoramaTopLeft.x() + panoramaWidth)
835  * @param panoramaNominatorFrame The nominator frame of the panorama frame summing all individual pixels values
836  * @param panoramaDenominatorFrame The denominator frame of the panorama frame storing the number of summed pixels individually for every pixel
837  * @param panoramaFrame The existing panorama frame which will receive the new image information
838  * @param panoramaMask The mask of the existing panorama frame
839  * @param panoramaWidth The width of the panorama frame in pixel
840  * @param panoramaFramePaddingElements The number of padding elements at the end of each panorama frame row, in elements, with range [0, infinity)
841  * @param panoramaMaskPaddingElements The number of padding elements at the end of each panorama mask row, in elements, with range [0, infinity)
842  * @param panoramaTopLeftX The horizontal top left position of the panorama frame
843  * @param panoramaTopLeftY The vertical top left position of the panorama frame
844  * @param maskValue The mask value defining valid pixels
845  * @param firstSubRow The first sub row to be handled
846  * @param numberSubRows The number of sub rows to be handled
847  * @tparam tChannels The number of frame data channels
848  * @see mergeAverageGlobal8BitPerChannel().
849  */
850  template <unsigned int tChannels>
851  static void mergeAverageGlobal8BitPerChannelSubset(const uint8_t* panoramaSubFrame, const uint8_t* panoramaSubMask, const unsigned int subFrameWidth, const unsigned int panoramaSubFramePaddingElements, const unsigned int panoramaSubMaskPaddingElements, const unsigned int subTopLeftX, const unsigned int subTopLeftY, uint32_t* panoramaNominatorFrame, uint32_t* panoramaDenominatorFrame, uint8_t* panoramaFrame, uint8_t* panoramaMask, const unsigned int panoramaWidth, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const unsigned int panoramaTopLeftX, const unsigned int panoramaTopLeftY, const uint8_t maskValue, const unsigned int firstSubRow, const unsigned int numberSubRows);
852 
853  /**
854  * Converts a subset of a given input camera frame with 8 bit per channel captured with a given orientation into a corresponding camera frame with different orientation.
855  * @param inputCamera The camera profile of the given input frame
856  * @param inputOrientation The orientation of the given input frame (and input camera)
857  * @param inputFrame The input frame which will be converted, the frame dimension must match with the given camera profile
858  * @param inputFramePaddingElements The number of padding elements of the input frame, range: [0, infinity)
859  * @param outputCamera The camera profile of the resulting output frame
860  * @param outputOrientation The orientation of the resulting output frame
861  * @param outputFrame The resulting output frame
862  * @param outputMask The resulting mask of the output frame defining valid and invalid pixels
863  * @param outputFramePaddingElements The number of padding elements of the input frame, range: [0, infinity)
864  * @param outputMaskPaddingElements The number of padding elements of the input mask, range: [0, infinity)
865  * @param maskValue The mask value defining valid pixels in the mask frames
866  * @param firstOutputRow The first output row to be handled
867  * @param numberOutputRows The number of output rows to be handled
868  * @tparam tChannels The number of frame data channels
869  */
870  template <unsigned int tChannels>
871  static void cameraFrame2cameraFrame8BitPerChannelSubset(const PinholeCamera* inputCamera, const SquareMatrix3* inputOrientation, const uint8_t* inputFrame, const unsigned int inputFramePaddingElements, const PinholeCamera* outputCamera, const SquareMatrix3* outputOrientation, uint8_t* outputFrame, uint8_t* outputMask, const unsigned int outputFramePaddingElements, const unsigned int outputMaskPaddingElements, const uint8_t maskValue, const unsigned int firstOutputRow, const unsigned int numberOutputRows);
872 
873  /**
874  * Converts a subset of a given input camera frame with 8 bit per channel captured with a given orientation into a corresponding camera frame with different orientation.
875  * This function created the final frame by application of a lookup table avoiding the expensive transformation calculations for each individual pixel.<br>
876  * @param lookupTable The lookup table allowing to determine the approximated transformation function between input and output frame
877  * @param inputFrame The input frame which will be converted, the frame dimension must match with the given camera profile
878  * @param inputWidth The width of the input frame, in pixel
879  * @param inputHeight The height of the input frame, in pixel
880  * @param inputFramePaddingElements The number of padding elements of the input frame, range: [0, infinity)
881  * @param outputFrame The resulting output frame
882  * @param outputMask The resulting mask of the output frame defining valid and invalid pixels
883  * @param maskValue The mask value defining valid pixels in the mask frames
884  * @param outputFramePaddingElements The number of padding elements of the input frame, range: [0, infinity)
885  * @param outputMaskPaddingElements The number of padding elements of the input mask, range: [0, infinity)
886  * @param firstOutputRow The first output row to be handled
887  * @param numberOutputRows The number of output rows to be handled
888  * @tparam tChannels The number of frame data channels
889  */
890  template <unsigned int tChannels>
891  static void cameraFrame2cameraFrameLookup8BitPerChannelSubset(const LookupTable* lookupTable, const uint8_t* inputFrame, const unsigned int inputWidth, const unsigned int inputHeight, const unsigned int inputFramePaddingElements, uint8_t* outputFrame, uint8_t* outputMask, const unsigned int outputFramePaddingElements, const unsigned int outputMaskPaddingElements, const uint8_t maskValue, const unsigned int firstOutputRow, const unsigned int numberOutputRows);
892 
893  /**
894  * Converts a subset of a given input camera frame with 8 bit per channel captured with a given orientation into a corresponding camera frame with different orientation.
895  * @param inputCamera The camera profile of the given input frame
896  * @param inputOrientation The orientation of the given input frame (and input camera)
897  * @param inputFrame The input frame which will be converted, the frame dimension must match with the given camera profile
898  * @param inputMask Mask defining valid and invalid pixels in the input frame, a default frame sets all pixels as valid
899  * @param inputFramePaddingElements The number of padding elements of the input frame, range: [0, infinity)
900  * @param inputMaskPaddingElements The number of padding elements of the input mask, range: [0, infinity)
901  * @param outputCamera The camera profile of the resulting output frame
902  * @param outputOrientation The orientation of the resulting output frame
903  * @param outputFrame The resulting output frame
904  * @param outputMask The resulting mask of the output frame defining valid and invalid pixels
905  * @param outputFramePaddingElements The number of padding elements of the input frame, range: [0, infinity)
906  * @param outputMaskPaddingElements The number of padding elements of the input mask, range: [0, infinity)
907  * @param maskValue The mask value defining valid pixels in the mask frames
908  * @param firstOutputRow The first output row to be handled
909  * @param numberOutputRows The number of output rows to be handled
910  * @tparam tChannels The number of frame data channels
911  */
912  template <unsigned int tChannels>
913  static void cameraFrame2cameraFrameMask8BitPerChannelSubset(const PinholeCamera* inputCamera, const SquareMatrix3* inputOrientation, const uint8_t* inputFrame, const uint8_t* inputMask, const unsigned int inputFramePaddingElements, const unsigned int inputMaskPaddingElements, const PinholeCamera* outputCamera, const SquareMatrix3* outputOrientation, uint8_t* outputFrame, uint8_t* outputMask, const unsigned int outputFramePaddingElements, const unsigned int outputMaskPaddingElements, const uint8_t maskValue, const unsigned int firstOutputRow, const unsigned int numberOutputRows);
914 
915  /**
916  * Converts a subset of a given input camera frame with 8 bit per channel captured with a given orientation into a corresponding camera frame with different orientation.
917  * This function created the final frame by application of a lookup table avoiding the expensive transformation calculations for each individual pixel.<br>
918  * @param lookupTable The lookup table allowing to determine the approximated transformation function between input and output frame
919  * @param inputFrame The input frame which will be converted, the frame dimension must match with the given camera profile
920  * @param inputMask Mask defining valid and invalid pixels in the input frame, a default frame sets all pixels as valid
921  * @param inputWidth The width of the input frame, in pixel
922  * @param inputHeight The height of the input frame, in pixel
923  * @param inputFramePaddingElements The number of padding elements of the input frame, range: [0, infinity)
924  * @param inputMaskPaddingElements The number of padding elements of the input mask, range: [0, infinity)
925  * @param outputFrame The resulting output frame
926  * @param outputMask The resulting mask of the output frame defining valid and invalid pixels
927  * @param outputFramePaddingElements The number of padding elements of the input frame, range: [0, infinity)
928  * @param outputMaskPaddingElements The number of padding elements of the input mask, range: [0, infinity)
929  * @param maskValue The mask value defining valid pixels in the mask frames
930  * @param firstOutputRow The first output row to be handled
931  * @param numberOutputRows The number of output rows to be handled
932  * @tparam tChannels The number of frame data channels
933  */
934  template <unsigned int tChannels>
935  static void cameraFrame2cameraFrameMaskLookup8BitPerChannelSubset(const LookupTable* lookupTable, const uint8_t* inputFrame, const uint8_t* inputMask, const unsigned int inputWidth, const unsigned int inputHeight, const unsigned int inputFramePaddingElements, const unsigned int inputMaskPaddingElements, uint8_t* outputFrame, uint8_t* outputMask, const unsigned int outputFramePaddingElements, const unsigned int outputMaskPaddingElements, const uint8_t maskValue, const unsigned int firstOutputRow, const unsigned int numberOutputRows);
936 
937  /**
938  * Copies (interpolates) a subset of a section from the entire panorama frame with 8 bit per data channel to a camera frame with specified camera orientation.
939  * @param pinholeCamera The pinhole camera profile of the resulting camera frame
940  * @param panoramaFrame The sub-frame of the entire (possible maximal) panorama frame from which the resulting camera frame is created
941  * @param panoramaMask The mask frame corresponding with the given panorama frame (with same dimension)
942  * @param panoramaFrameWidth The width of the given panorama frame in pixel, with range [1, panoramaDimensionWidth]
943  * @param panoramaFrameHeight The height of the given panorama frame in pixel, with range [1, panoramaDimensionHeight]
944  * @param panoramaFramePaddingElements The number of padding elements at the end of each panorama frame row, in elements, with range [0, infinity)
945  * @param panoramaMaskPaddingElements The number of padding elements at the end of each panorama mask row, in elements, with range [0, infinity)
946  * @param panoramaDimensionWidth The maximal width of the entire maximal possible panorama frame, in pixel
947  * @param panoramaDimensionHeight The maximal height of the entire maximal possible panorama frame, in pixel
948  * @param panoramaFrameTopLeftX The horizontal top left position of the given sub-frame of the panorama frame
949  * @param panoramaFrameTopLeftY The vertical top left position of the given sub-frame of the panorama frame
950  * @param orientation The orientation of the resulting camera frame
951  * @param cameraFrame The resulting camera frame, will receive the frame dimension as provided by the camera profile
952  * @param cameraMask The resulting camera mask, will receive the frame dimension as provided by the camera profile
953  * @param cameraFramePaddingElements The number of padding elements at the end of each camera frame row, in elements, with range [0, infinity)
954  * @param cameraMaskPaddingElements The number of padding elements at the end of each camera mask row, in elements, with range [0, infinity)
955  * @param maskValue The mask value defining a valid mask pixel
956  * @param fineAdjustment Optional transformation lookup table with relative offsets providing a fine adjustment for the camera frame
957  * @param firstCameraRow First camera row to be handled
958  * @param numberCameraRows The number of camera rows to be handled
959  * @tparam tChannels The number of frame data channels
960  */
961  template <unsigned int tChannels>
962  static void panoramaFrame2cameraFrame8BitPerChannelSubset(const PinholeCamera* pinholeCamera, const uint8_t* panoramaFrame, const uint8_t* panoramaMask, const unsigned int panoramaFrameWidth, const unsigned int panoramaFrameHeight, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const unsigned int panoramaDimensionWidth, const unsigned int panoramaDimensionHeight, const unsigned int panoramaFrameTopLeftX, const unsigned int panoramaFrameTopLeftY, const SquareMatrix3* orientation, uint8_t* cameraFrame, uint8_t* cameraMask, const unsigned int cameraFramePaddingElements, const unsigned int cameraMaskPaddingElements, const uint8_t maskValue, const LookupTable* fineAdjustment, const unsigned int firstCameraRow, const unsigned int numberCameraRows);
963 
964  /**
965  * Copies (interpolates) a subset of a section from the entire panorama frame with 8 bit per data channel to a camera frame with specified camera orientation.
966  * @param lookupTable The 2D lookup table for the camera frame mapping positions defined in the camera frame to positions defined in the panorama frame
967  * @param panoramaFrame The sub-frame of the entire (possible maximal) panorama frame from which the resulting camera frame is created
968  * @param panoramaMask The mask frame corresponding with the given panorama frame (with same dimension)
969  * @param panoramaFramePaddingElements The number of padding elements at the end of each panorama frame row, in elements, with range [0, infinity)
970  * @param panoramaMaskPaddingElements The number of padding elements at the end of each panorama mask row, in elements, with range [0, infinity)
971  * @param panoramaDimensionWidth The maximal width of the entire maximal possible panorama frame, in pixel
972  * @param panoramaDimensionHeight The maximal height of the entire maximal possible panorama frame, in pixel
973  * @param panoramaFrameTopLeftX The horizontal top left position of the resulting sub-frame of the panorama frame
974  * @param panoramaFrameTopLeftY The vertical top left position of the resulting sub-frame of the panorama frame
975  * @param panoramaFrameWidth The width of the given panorama frame in pixel, with range [1, panoramaDimensionWidth]
976  * @param panoramaFrameHeight The height of the given panorama frame in pixel, with range [1, panoramaDimensionHeight]
977  * @param cameraFrame The resulting camera frame, will receive the frame dimension as provided by the camera profile
978  * @param cameraMask The resulting camera mask, will receive the frame dimension as provided by the camera profile
979  * @param cameraFramePaddingElements The number of padding elements at the end of each camera frame row, in elements, with range [0, infinity)
980  * @param cameraMaskPaddingElements The number of padding elements at the end of each camera mask row, in elements, with range [0, infinity)
981  * @param maskValue The mask value defining a valid mask pixel
982  * @param firstCameraRow First camera row to be handled
983  * @param numberCameraRows The number of camera rows to be handled
984  * @tparam tChannels The number of frame data channels
985  */
986  template <unsigned int tChannels>
987  static void panoramaFrame2cameraFrameLookup8BitPerChannelSubset(const LookupTable* lookupTable, const uint8_t* panoramaFrame, const uint8_t* panoramaMask, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const unsigned int panoramaDimensionWidth, const unsigned int panoramaDimensionHeight, const unsigned int panoramaFrameTopLeftX, const unsigned int panoramaFrameTopLeftY, const unsigned int panoramaFrameWidth, const unsigned int panoramaFrameHeight, uint8_t* cameraFrame, uint8_t* cameraMask, const unsigned int cameraFramePaddingElements, const unsigned int cameraMaskPaddingElements, const uint8_t maskValue, const unsigned int firstCameraRow, const unsigned int numberCameraRows);
988 
989  /**
990  * Copies (interpolates) the entire area of an 8 bit per data channel camera frame with specified camera orientation to a subset of a section of an entire panorama frame.
991  * @param pinholeCamera The pinhole camera profile of the resulting camera frame
992  * @param cameraFrame The camera frame to be copied, must be valid
993  * @param cameraFramePaddingElements The number of padding elements at the end of each camera frame row, in elements, with range [0, infinity)
994  * @param orientation The orientation of the given camera frame
995  * @param panoramaDimensionWidth The maximal width of the entire maximal possible panorama frame, in pixel
996  * @param panoramaDimensionHeight The maximal height of the entire maximal possible panorama frame, in pixel
997  * @param panoramaFrameTopLeftX The horizontal top left position of the resulting sub-frame of the panorama frame
998  * @param panoramaFrameTopLeftY The vertical top left position of the resulting sub-frame of the panorama frame
999  * @param panoramaFrame The resulting sub-frame of the entire (possible maximal) panorama frame
1000  * @param panoramaMask The mask frame corresponding with the resulting panorama frame (with same dimension)
1001  * @param panoramaFrameWidth The width of the resulting panorama frame in pixel, with range [1, panoramaDimensionWidth]
1002  * @param panoramaFrameHeight The height of the resulting panorama frame in pixel, with range [1, panoramaDimensionHeight]
1003  * @param panoramaFramePaddingElements The number of padding elements at the end of each panorama frame row, in elements, with range [0, infinity)
1004  * @param panoramaMaskPaddingElements The number of padding elements at the end of each panorama mask row, in elements, with range [0, infinity)
1005  * @param maskValue The mask value defining a valid mask pixel
1006  * @param fineAdjustment Optional transformation lookup table with relative offsets providing a fine adjustment for the given camera frame
1007  * @param firstPanoramaRow First panorama frame row to be handled
1008  * @param numberPanoramaRows The number of panorama frame rows to be handled
1009  * @tparam tChannels The number of frame data channels
1010  */
1011  template <unsigned int tChannels>
1012  static void cameraFrame2panoramaFrame8BitPerChannelSubset(const PinholeCamera* pinholeCamera, const uint8_t* cameraFrame, const unsigned int cameraFramePaddingElements, const SquareMatrix3* orientation, const unsigned int panoramaDimensionWidth, const unsigned int panoramaDimensionHeight, const int panoramaFrameTopLeftX, const int panoramaFrameTopLeftY, uint8_t* panoramaFrame, uint8_t* panoramaMask, const unsigned int panoramaFrameWidth, const unsigned int panoramaFrameHeight, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const uint8_t maskValue, const LookupTable* fineAdjustment, const unsigned int firstPanoramaRow, const unsigned int numberPanoramaRows);
1013 
1014  /**
1015  * Copies (interpolates) the entire area of an 8 bit per data channel camera frame with specified camera orientation to a subset of a section of an entire panorama frame.
1016  * @param lookupTable The 2D lookup table for the camera frame mapping positions defined in the camera frame to positions defined in the panorama frame
1017  * @param cameraFrame The camera frame to be copied
1018  * @param cameraFrameWidth The width of the camera frame in pixel
1019  * @param cameraFrameHeight The height of the camera frame in pixel
1020  * @param cameraFramePaddingElements The number of padding elements at the end of each camera frame row, in elements, with range [0, infinity)
1021  * @param panoramaFrame The resulting sub-frame of the entire (possible maximal) panorama frame
1022  * @param panoramaMask The mask frame corresponding with the resulting panorama frame (with same dimension)
1023  * @param panoramaFramePaddingElements The number of padding elements at the end of each panorama frame row, in elements, with range [0, infinity)
1024  * @param panoramaMaskPaddingElements The number of padding elements at the end of each panorama mask row, in elements, with range [0, infinity)
1025  * @param maskValue The mask value defining a valid mask pixel
1026  * @param firstPanoramaRow First panorama frame row to be handled
1027  * @param numberPanoramaRows The number of panorama frame rows to be handled
1028  * @tparam tChannels The number of frame data channels
1029  */
1030  template <unsigned int tChannels>
1031  static void cameraFrame2panoramaFrameLookup8BitPerChannelSubset(const LookupTable* lookupTable, const uint8_t* cameraFrame, const unsigned int cameraFrameWidth, const unsigned int cameraFrameHeight, const unsigned int cameraFramePaddingElements, uint8_t* panoramaFrame, uint8_t* panoramaMask, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const uint8_t maskValue, const unsigned int firstPanoramaRow, const unsigned int numberPanoramaRows);
1032 
1033  /**
1034  * Copies (interpolates) a subset of an 8 bit per data channel camera frame (specified by a mask) with specified camera orientation to subset of a section of an entire panorama frame.
1035  * @param pinholeCamera The pinhole camera profile of the resulting camera frame
1036  * @param cameraFrame The camera frame to be copied, must be valid
1037  * @param cameraMask The mask of camera frame specifying valid pixels, must be valid
1038  * @param cameraFramePaddingElements The number of padding elements at the end of each camera frame row, in elements, with range [0, infinity)
1039  * @param cameraMaskPaddingElements The number of padding elements at the end of each camera mask row, in elements, with range [0, infinity)
1040  * @param orientation The orientation of the given camera frame
1041  * @param panoramaDimensionWidth The maximal width of the entire maximal possible panorama frame, in pixel
1042  * @param panoramaDimensionHeight The maximal height of the entire maximal possible panorama frame, in pixel
1043  * @param panoramaFrameTopLeftX The horizontal top left position of the resulting sub-frame of the panorama frame
1044  * @param panoramaFrameTopLeftY The vertical top left position of the resulting sub-frame of the panorama frame
1045  * @param panoramaFrame The resulting sub-frame of the entire (possible maximal) panorama frame
1046  * @param panoramaMask The mask frame corresponding with the resulting panorama frame (with same dimension)
1047  * @param panoramaFrameWidth The width of the resulting panorama frame in pixel, with range [1, panoramaDimensionWidth]
1048  * @param panoramaFrameHeight The height of the resulting panorama frame in pixel, with range [1, panoramaDimensionHeight]
1049  * @param panoramaFramePaddingElements The number of padding elements at the end of each panorama frame row, in elements, with range [0, infinity)
1050  * @param panoramaMaskPaddingElements The number of padding elements at the end of each panorama mask row, in elements, with range [0, infinity)
1051  * @param maskValue The mask value defining a valid mask pixel
1052  * @param fineAdjustment Optional transformation lookup table with relative offsets providing a fine adjustment for the given camera frame
1053  * @param firstPanoramaRow First panorama frame row to be handled
1054  * @param numberPanoramaRows The number of panorama frame rows to be handled
1055  * @tparam tChannels The number of frame data channels
1056  */
1057  template <unsigned int tChannels>
1058  static void cameraFrame2panoramaFrameMask8BitPerChannelSubset(const PinholeCamera* pinholeCamera, const uint8_t* cameraFrame, const uint8_t* cameraMask, const unsigned int cameraFramePaddingElements, const unsigned int cameraMaskPaddingElements, const SquareMatrix3* orientation, const unsigned int panoramaDimensionWidth, const unsigned int panoramaDimensionHeight, const int panoramaFrameTopLeftX, const int panoramaFrameTopLeftY, uint8_t* panoramaFrame, uint8_t* panoramaMask, const unsigned int panoramaFrameWidth, const unsigned int panoramaFrameHeight, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const uint8_t maskValue, const LookupTable* fineAdjustment, const unsigned int firstPanoramaRow, const unsigned int numberPanoramaRows);
1059 
1060  /**
1061  * Copies (interpolates) a subset of an 8 bit per data channel camera frame (specified by a mask) with specified camera orientation to subset of a section of an entire panorama frame.
1062  * @param lookupTable The 2D lookup table for the camera frame mapping positions defined in the camera frame to positions defined in the panorama frame
1063  * @param cameraFrame The camera frame to be copied, must be valid
1064  * @param cameraMask The mask of camera frame specifying valid pixels, must be valid
1065  * @param cameraFrameWidth The width of the camera frame in pixel
1066  * @param cameraFrameHeight The height of the camera frame in pixel
1067  * @param cameraFramePaddingElements The number of padding elements at the end of each camera frame row, in elements, with range [0, infinity)
1068  * @param cameraMaskPaddingElements The number of padding elements at the end of each camera mask row, in elements, with range [0, infinity)
1069  * @param panoramaFrame The resulting sub-frame of the entire (possible maximal) panorama frame
1070  * @param panoramaMask The mask frame corresponding with the resulting panorama frame (with same dimension)
1071  * @param panoramaFramePaddingElements The number of padding elements at the end of each panorama frame row, in elements, with range [0, infinity)
1072  * @param panoramaMaskPaddingElements The number of padding elements at the end of each panorama mask row, in elements, with range [0, infinity)
1073  * @param maskValue The mask value defining a valid mask pixel
1074  * @param firstPanoramaRow First panorama frame row to be handled
1075  * @param numberPanoramaRows The number of panorama frame rows to be handled
1076  * @tparam tChannels The number of frame data channels
1077  */
1078  template <unsigned int tChannels>
1079  static void cameraFrame2panoramaFrameMaskLookup8BitPerChannelSubset(const LookupTable* lookupTable, const uint8_t* cameraFrame, const uint8_t* cameraMask, const unsigned int cameraFrameWidth, const unsigned int cameraFrameHeight, const unsigned int cameraFramePaddingElements, const unsigned int cameraMaskPaddingElements, uint8_t* panoramaFrame, uint8_t* panoramaMask, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const uint8_t maskValue, const unsigned int firstPanoramaRow, const unsigned int numberPanoramaRows);
1080 
1081  /**
1082  * Creates are contour of (the outside of) a camera frame
1083  *
1084  * @param width The width of the camera frame, range: [1, infinity)
1085  * @param height The height of the camera frame, range: [1, infinity)
1086  * @param count Number of segments each edge is split into, range: [1, infinity)
1087  * @return The contour in counter-clockwise order
1088  */
1089  static Vectors2 generateFrameContour(const unsigned int width, const unsigned int height, const unsigned int count);
1090 
1091  protected:
1092 
1093  /// The actual panorama frame, may be a sub-frame of the entire panorama frame.
1095 
1096  /// The mask of the panorama frame defining valid and invalid pixels.
1098 
1099  /// The optional nominator frame of the panorama frame, necessary if UM_AVERAGE_GLOBAL is set as update mode.
1101 
1102  /// The optional denominator frame of the panorama frame, necessary if UM_AVERAGE_GLOBAL is set as update mode.
1104 
1105  /// The maximal width of the panorama frame representing horizontal 360 degrees, in pixel.
1106  unsigned int dimensionWidth_ = 0u;
1107 
1108  /// The maximal height of the panorama frame representing vertical 180 degrees, in pixel.
1109  unsigned int dimensionHeight_ = 0u;
1110 
1111  /// The inverse of the maximal width of the panorama frame, panoramaInvDimensionWidth = (1 / panoramaDimensionWidth).
1112  Scalar invertedDimensionWidth_ = Scalar(0);
1113 
1114  /// The inverse of the maximal height of the panorama frame, panoramaInvDimensionHeight = (1 / panoramaDimensionHeight).
1115  Scalar invertedDimensionHeight_ = Scalar(0);
1116 
1117  /// The top left position of the sub-frame of the entire panorama frame.
1118  PixelPosition frameTopLeft_ = CV::PixelPosition((unsigned int)(-1), (unsigned int)(-1));
1119 
1120  /// The mask value defining the mask value of valid pixels.
1121  uint8_t maskValue_ = 0xFFu;
1122 
1123  /// The update mode of this panorama frame.
1124  UpdateMode updateMode_ = UM_INVALID;
1125 };
1126 
1127 inline PanoramaFrame::PanoramaFrame(const unsigned int dimensionWidth, const unsigned int dimensionHeight, const uint8_t maskValue, const UpdateMode updateMode) :
1128  dimensionWidth_(dimensionWidth),
1129  dimensionHeight_(dimensionHeight),
1130  invertedDimensionWidth_(dimensionWidth != 0u ? Scalar(1) / Scalar(dimensionWidth) : 0),
1131  invertedDimensionHeight_(dimensionHeight != 0u ? Scalar(1) / Scalar(dimensionHeight) : 0),
1132  frameTopLeft_((unsigned int)(-1), (unsigned int)(-1)),
1133  maskValue_(maskValue),
1134  updateMode_(updateMode)
1135 {
1136  ocean_assert(updateMode_ != UM_INVALID);
1137 }
1138 
1139 inline const Frame& PanoramaFrame::frame() const
1140 {
1141  return frame_;
1142 }
1143 
1144 inline const Frame& PanoramaFrame::mask() const
1145 {
1146  return mask_;
1147 }
1148 
1149 inline uint8_t PanoramaFrame::maskValue() const
1150 {
1151  return maskValue_;
1152 }
1153 
1155 {
1156  return updateMode_;
1157 }
1158 
1160 {
1161  return frameTopLeft_;
1162 }
1163 
1164 inline unsigned int PanoramaFrame::dimensionWidth() const
1165 {
1166  return dimensionWidth_;
1167 }
1168 
1169 inline unsigned int PanoramaFrame::dimensionHeight() const
1170 {
1171  return dimensionHeight_;
1172 }
1173 
1174 inline bool PanoramaFrame::extractFrame(const PinholeCamera& pinholeCamera, const SquareMatrix3& orientation, Frame& frame, Frame& mask, const unsigned int approximationBinSize, Worker* worker, const LookupTable* fineAdjustment) const
1175 {
1176  ocean_assert(frame_.isValid() && pinholeCamera.isValid() && !orientation.isSingular());
1177  if (!frame_.isValid() || !pinholeCamera.isValid() || orientation.isSingular())
1178  {
1179  return false;
1180  }
1181 
1182  return panoramaFrame2cameraFrame(pinholeCamera, frame_, mask_, dimensionWidth_, dimensionHeight_, frameTopLeft_, orientation, frame, mask, maskValue_, approximationBinSize, worker, fineAdjustment);
1183 }
1184 
1185 inline Vector2 PanoramaFrame::cameraPixel2panoramaPixel(const PinholeCamera& pinholeCamera, const SquareMatrix3& orientation, const Vector2& cameraPixel, const Vector2& referenceAngle) const
1186 {
1187  ocean_assert(pinholeCamera.isValid() && !orientation.isSingular());
1188 
1189  ocean_assert(cameraPixel.x() >= Scalar(0) && cameraPixel.x() < Scalar(pinholeCamera.width()));
1190  ocean_assert(cameraPixel.y() >= Scalar(0) && cameraPixel.y() < Scalar(pinholeCamera.height()));
1191 
1192  const Vector3 ray(orientation * pinholeCamera.vector(pinholeCamera.undistort<true>(cameraPixel)));
1193 
1194  const Vector2 angle(ray2angle(ray, referenceAngle));
1195  const Vector2 panoramaPosition(angle2pixel(angle, dimensionWidth_, dimensionHeight_));
1196 
1197  return panoramaPosition;
1198 }
1199 
1200 inline Vector2 PanoramaFrame::cameraPixel2panoramaPixelStrict(const PinholeCamera& pinholeCamera, const SquareMatrix3& orientation, const Vector2& cameraPixel) const
1201 {
1202  ocean_assert(pinholeCamera.isValid() && !orientation.isSingular());
1203 
1204  ocean_assert(cameraPixel.x() >= Scalar(0) && cameraPixel.x() < Scalar(pinholeCamera.width()));
1205  ocean_assert(cameraPixel.y() >= Scalar(0) && cameraPixel.y() < Scalar(pinholeCamera.height()));
1206 
1207  const Vector3 ray(orientation * pinholeCamera.vector(pinholeCamera.undistort<true>(cameraPixel)));
1208 
1209  const Vector2 angle(ray2angleStrict(ray));
1210  const Vector2 panoramaPosition(angle2pixel(angle, dimensionWidth_, dimensionHeight_));
1211 
1212  return panoramaPosition;
1213 }
1214 
1215 inline Vector2 PanoramaFrame::panoramaPixel2cameraPixel(const PinholeCamera& pinholeCamera, const SquareMatrix3& iOrientation, const Vector2& panoramaPixel) const
1216 {
1217  ocean_assert(pinholeCamera.isValid() && !iOrientation.isSingular());
1218 
1220  const Vector3 ray(iOrientation * angle2ray(angle));
1221  ocean_assert(ray.z() < 0);
1222 
1223  const Vector3 rayOnPlane(ray * Scalar(-1) / ray.z());
1224  ocean_assert(rayOnPlane.z() < 0);
1225 
1226  const Vector2 cameraPosition(pinholeCamera.normalizedImagePoint2imagePoint<true>(Vector2(rayOnPlane.x(), -rayOnPlane.y()), true));
1227 
1228  return cameraPosition;
1229 }
1230 
1231 inline bool PanoramaFrame::isValid() const
1232 {
1233  return dimensionWidth_ != 0u && dimensionHeight_ != 0u;
1234 }
1235 
1236 inline PanoramaFrame::operator bool() const
1237 {
1238  return isValid();
1239 }
1240 
1241 inline Vector2 PanoramaFrame::angle2pixel(const Vector2& angle) const
1242 {
1244 }
1245 
1246 inline Vector2 PanoramaFrame::pixel2angle(const Vector2& position) const
1247 {
1248  ocean_assert(position.x() >= 0 && position.x() < Scalar(dimensionWidth_));
1249  ocean_assert(position.y() >= 0 && position.y() < Scalar(dimensionHeight_));
1250 
1251  ocean_assert(invertedDimensionWidth_ == Scalar(1) / Scalar(dimensionWidth_));
1252  ocean_assert(invertedDimensionHeight_ == Scalar(1) / Scalar(dimensionHeight_));
1253 
1255 }
1256 
1257 inline Vector2 PanoramaFrame::angle2pixel(const Vector2& angle, const unsigned int panoramaDimensionWidth, const unsigned int panoramaDimensionHeight)
1258 {
1259  const Scalar x = ((angle[0] + Numeric::pi()) * Scalar(panoramaDimensionWidth)) * Scalar(0.15915494309189533576888376337251); // 1 / 2PI
1260  const Scalar y = ((-angle[1] + Numeric::pi_2()) * Scalar(panoramaDimensionHeight)) * Scalar(0.31830988618379067153776752674503); // 1 / PI
1261 
1262  return Vector2(x, y);
1263 }
1264 
1265 inline Vector2 PanoramaFrame::angle2pixelStrict(const Vector2& angle, const unsigned int panoramaDimensionWidth, const unsigned int panoramaDimensionHeight)
1266 {
1267  ocean_assert(angle[0] >= -Numeric::pi() && angle[0] < Numeric::pi());
1268  ocean_assert(angle[1] >= -Numeric::pi_2() && angle[1] <= Numeric::pi_2());
1269 
1270  const Scalar x = ((angle[0] + Numeric::pi()) * Scalar(panoramaDimensionWidth)) * Scalar(0.15915494309189533576888376337251); // 1 / 2PI
1271  const Scalar y = ((-angle[1] + Numeric::pi_2()) * Scalar(panoramaDimensionHeight)) * Scalar(0.31830988618379067153776752674503); // 1 / PI
1272 
1273  ocean_assert(x >= 0 && x < Scalar(panoramaDimensionWidth));
1274  ocean_assert(y >= 0 && y < Scalar(panoramaDimensionHeight));
1275 
1276  return Vector2(x, y);
1277 }
1278 
1279 inline Vector2 PanoramaFrame::pixel2angle(const Vector2& position, const Scalar invPanoramaDimensionWidth, const Scalar invPanoramaDimensionHeight)
1280 {
1281  ocean_assert(invPanoramaDimensionWidth > 0 && invPanoramaDimensionWidth <= 1);
1282  ocean_assert(invPanoramaDimensionHeight > 0 && invPanoramaDimensionHeight <= 1);
1283 
1284  const Scalar latitude = (position.x() * Numeric::pi2()) * invPanoramaDimensionWidth - Numeric::pi();
1285  const Scalar longitude = Numeric::pi_2() - (position.y() * Numeric::pi()) * invPanoramaDimensionHeight;
1286 
1287  return Vector2(latitude, longitude);
1288 }
1289 
1290 inline Vector2 PanoramaFrame::pixel2angleStrict(const Vector2& position, const Scalar invPanoramaDimensionWidth, const Scalar invPanoramaDimensionHeight)
1291 {
1292  ocean_assert(invPanoramaDimensionWidth > 0 && invPanoramaDimensionWidth <= 1);
1293  ocean_assert(invPanoramaDimensionHeight > 0 && invPanoramaDimensionHeight <= 1);
1294 
1295  ocean_assert(position.x() >= 0 && position.x() <= Scalar(1) / Scalar(invPanoramaDimensionWidth));
1296  ocean_assert(position.y() >= 0 && position.y() <= Scalar(1) / Scalar(invPanoramaDimensionHeight));
1297 
1298  const Scalar latitude = (position.x() * Numeric::pi2()) * invPanoramaDimensionWidth - Numeric::pi();
1299  const Scalar longitude = Numeric::pi_2() - (position.y() * Numeric::pi()) * invPanoramaDimensionHeight;
1300 
1301  ocean_assert(latitude >= -Numeric::pi() && latitude < Numeric::pi());
1302  ocean_assert(longitude >= -Numeric::pi_2() && longitude <= Numeric::pi_2());
1303 
1304  return Vector2(latitude, longitude);
1305 }
1306 
1307 inline Vector2 PanoramaFrame::ray2angle(const Vector3& ray, const Vector2& referenceAngle)
1308 {
1309  ocean_assert(Numeric::isEqual(ray.length(), 1));
1310 
1311  Scalar longitude = (Numeric::isEqualEps(ray.x()) && Numeric::isEqualEps(-ray.z())) ? Scalar(0) : Numeric::atan2(ray.x(), -ray.z());
1312  Scalar latitude = Numeric::asin(ray.y());
1313 
1314  ocean_assert(longitude >= -Numeric::pi() && longitude <= Numeric::pi());
1315  ocean_assert(latitude >= -Numeric::pi_2() && latitude <= Numeric::pi_2());
1316 
1317  const Scalar longitudeMinus = longitude - Numeric::pi2();
1318  const Scalar longitudePlus = longitude + Numeric::pi2();
1319 
1320  if (Numeric::abs(referenceAngle.x() - longitude) > Numeric::abs(referenceAngle.x() - longitudeMinus))
1321  {
1322  longitude = longitudeMinus;
1323  }
1324  if (Numeric::abs(referenceAngle.x() - longitude) > Numeric::abs(referenceAngle.x() - longitudePlus))
1325  {
1326  longitude = longitudePlus;
1327  }
1328 
1329  const Scalar latitudeMinus = latitude - Numeric::pi();
1330  const Scalar latitudePlus = latitude + Numeric::pi();
1331 
1332  if (Numeric::abs(referenceAngle.y() - latitude) > Numeric::abs(referenceAngle.y() - latitudeMinus))
1333  {
1334  latitude = latitudeMinus;
1335  }
1336  if (Numeric::abs(referenceAngle.y() - latitude) > Numeric::abs(referenceAngle.y() - latitudePlus))
1337  {
1338  latitude = latitudePlus;
1339  }
1340 
1341  return Vector2(longitude, latitude);
1342 }
1343 
1345 {
1346  const Scalar longitude = (Numeric::isEqualEps(ray.x()) && Numeric::isEqualEps(-ray.z())) ? Scalar(0) : Numeric::atan2(ray.x(), -ray.z());
1347  const Scalar latitude = Numeric::asin(ray.y());
1348 
1349  ocean_assert(longitude >= -Numeric::pi() && longitude <= Numeric::pi());
1350  ocean_assert(latitude >= -Numeric::pi_2() && latitude <= Numeric::pi_2());
1351 
1352  if (longitude == Numeric::pi())
1353  {
1354  return Vector2(-Numeric::pi(), latitude);
1355  }
1356  else
1357  {
1358  return Vector2(longitude, latitude);
1359  }
1360 }
1361 
1363 {
1364  const Scalar diagonal = Numeric::cos(angle[1]);
1365 
1366  const Vector3 ray(diagonal * Numeric::sin(angle[0]), Numeric::sin(angle[1]), -diagonal * Numeric::cos(angle[0]));
1367  ocean_assert(Numeric::isEqual(ray.length(), 1));
1368 
1369  return ray;
1370 }
1371 
1373 {
1374  ocean_assert(angle[0] >= -Numeric::pi() && angle[0] < Numeric::pi());
1375  ocean_assert(angle[1] >= -Numeric::pi_2() && angle[1] <= Numeric::pi_2());
1376 
1377  const Scalar diagonal = Numeric::cos(angle[1]);
1378 
1379  const Vector3 ray(diagonal * Numeric::sin(angle[0]), Numeric::sin(angle[1]), -diagonal * Numeric::cos(angle[0]));
1380  ocean_assert(Numeric::isEqual(ray.length(), 1));
1381 
1382  return ray;
1383 }
1384 
1385 template <unsigned int tChannels>
1386 inline void PanoramaFrame::cameraFrame2cameraFrame8BitPerChannel(const PinholeCamera& inputCamera, const SquareMatrix3& inputOrientation, const uint8_t* inputFrame, const uint8_t* inputMask, const unsigned int inputFramePaddingElements, const unsigned int inputMaskPaddingElements, const PinholeCamera& outputCamera, const SquareMatrix3& outputOrientation, uint8_t* outputFrame, uint8_t* outputMask, const unsigned int outputFramePaddingElements, const unsigned int outputMaskPaddingElements, const uint8_t maskValue, const unsigned int approximationBinSize, Worker* worker)
1387 {
1388  static_assert(tChannels >= 1u, "Invalid channel number!");
1389 
1390  ocean_assert(inputCamera.isValid() && !inputOrientation.isSingular());
1391  ocean_assert(outputCamera.isValid() && !outputOrientation.isSingular());
1392 
1393  ocean_assert(inputFrame != nullptr && outputFrame != nullptr && outputMask != nullptr);
1394 
1395  if (approximationBinSize <= 1u)
1396  {
1397  if (inputMask != nullptr)
1398  {
1399  if (worker != nullptr)
1400  {
1401  worker->executeFunction(Worker::Function::createStatic(&PanoramaFrame::cameraFrame2cameraFrameMask8BitPerChannelSubset<tChannels>, &inputCamera, &inputOrientation, inputFrame, inputMask, inputFramePaddingElements, inputMaskPaddingElements, &outputCamera, &outputOrientation, outputFrame, outputMask, outputFramePaddingElements, outputMaskPaddingElements, maskValue, 0u, 0u), 0u, outputCamera.height());
1402  }
1403  else
1404  {
1405  cameraFrame2cameraFrameMask8BitPerChannelSubset<tChannels>(&inputCamera, &inputOrientation, inputFrame, inputMask, inputFramePaddingElements, inputMaskPaddingElements, &outputCamera, &outputOrientation, outputFrame, outputMask, outputFramePaddingElements, outputMaskPaddingElements, maskValue, 0u, outputCamera.height());
1406  }
1407  }
1408  else
1409  {
1410  if (worker != nullptr)
1411  {
1412  worker->executeFunction(Worker::Function::createStatic(&PanoramaFrame::cameraFrame2cameraFrame8BitPerChannelSubset<tChannels>, &inputCamera, &inputOrientation, inputFrame, inputFramePaddingElements, &outputCamera, &outputOrientation, outputFrame, outputMask, outputFramePaddingElements, outputMaskPaddingElements, maskValue, 0u, 0u), 0u, outputCamera.height());
1413  }
1414  else
1415  {
1416  cameraFrame2cameraFrame8BitPerChannelSubset<tChannels>(&inputCamera, &inputOrientation, inputFrame, inputFramePaddingElements, &outputCamera, &outputOrientation, outputFrame, outputMask, outputFramePaddingElements, outputMaskPaddingElements, maskValue, 0u, outputCamera.height());
1417  }
1418  }
1419  }
1420  else
1421  {
1422  const unsigned int binsX = min(outputCamera.width() / approximationBinSize, outputCamera.width() / 4u);
1423  const unsigned int binsY = min(outputCamera.height() / approximationBinSize, outputCamera.height() / 4u);
1424  LookupTable lookupTable(outputCamera.width(), outputCamera.height(), binsX, binsY);
1425 
1426  cameraFrame2cameraFrameLookupTable(inputCamera, inputOrientation, outputCamera, outputOrientation, lookupTable);
1427 
1428  if (inputMask != nullptr)
1429  {
1430  if (worker != nullptr)
1431  {
1432  worker->executeFunction(Worker::Function::createStatic(&cameraFrame2cameraFrameMaskLookup8BitPerChannelSubset<tChannels>, (const LookupTable*)&lookupTable, inputFrame, inputMask, inputCamera.width(), inputCamera.height(), inputFramePaddingElements, inputMaskPaddingElements, outputFrame, outputMask, outputFramePaddingElements, outputMaskPaddingElements, maskValue, 0u, 0u), 0u, outputCamera.height());
1433  }
1434  else
1435  {
1436  cameraFrame2cameraFrameMaskLookup8BitPerChannelSubset<tChannels>((const LookupTable*)&lookupTable, inputFrame, inputMask, inputCamera.width(), inputCamera.height(), inputFramePaddingElements, inputMaskPaddingElements, outputFrame, outputMask, outputFramePaddingElements, outputMaskPaddingElements, maskValue, 0u, outputCamera.height());
1437  }
1438  }
1439  else
1440  {
1441  if (worker != nullptr)
1442  {
1443  worker->executeFunction(Worker::Function::createStatic(&cameraFrame2cameraFrameLookup8BitPerChannelSubset<tChannels>, (const LookupTable*)&lookupTable, inputFrame, inputCamera.width(), inputCamera.height(), inputFramePaddingElements, outputFrame, outputMask, outputFramePaddingElements, outputMaskPaddingElements, maskValue, 0u, 0u), 0u, outputCamera.height());
1444  }
1445  else
1446  {
1447  cameraFrame2cameraFrameLookup8BitPerChannelSubset<tChannels>((const LookupTable*)&lookupTable, inputFrame, inputCamera.width(), inputCamera.height(), inputFramePaddingElements, outputFrame, outputMask, outputFramePaddingElements, outputMaskPaddingElements, maskValue, 0u, outputCamera.height());
1448  }
1449  }
1450  }
1451 }
1452 
1453 template <unsigned int tChannels>
1454 inline void PanoramaFrame::panoramaFrame2cameraFrame8BitPerChannel(const PinholeCamera& pinholeCamera, const uint8_t* panoramaFrame, const uint8_t* panoramaMask, const unsigned int panoramaFrameWidth, const unsigned int panoramaFrameHeight, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const unsigned int panoramaDimensionWidth, const unsigned int panoramaDimensionHeight, const PixelPosition& panoramaFrameTopLeft, const SquareMatrix3& orientation, uint8_t* cameraFrame, uint8_t* cameraMask, const unsigned int cameraFramePaddingElements, const unsigned int cameraMaskPaddingElements, const uint8_t maskValue, const unsigned int approximationBinSize, Worker* worker, const LookupTable* fineAdjustment)
1455 {
1456  static_assert(tChannels >= 1u, "Invalid channel number!");
1457 
1458  ocean_assert(pinholeCamera.isValid() && !orientation.isSingular());
1459  ocean_assert(panoramaFrame != nullptr && panoramaMask != nullptr);
1460  ocean_assert(panoramaFrameWidth != 0u && panoramaFrameHeight != 0u);
1461  ocean_assert(cameraFrame != nullptr && cameraMask != nullptr);
1462 
1463  if (approximationBinSize <= 1u)
1464  {
1465  if (worker != nullptr)
1466  {
1467  worker->executeFunction(Worker::Function::createStatic(&PanoramaFrame::panoramaFrame2cameraFrame8BitPerChannelSubset<tChannels>, &pinholeCamera, panoramaFrame, panoramaMask, panoramaFrameWidth, panoramaFrameHeight, panoramaFramePaddingElements, panoramaMaskPaddingElements, panoramaDimensionWidth, panoramaDimensionHeight, panoramaFrameTopLeft.x(), panoramaFrameTopLeft.y(), &orientation, cameraFrame, cameraMask, cameraFramePaddingElements, cameraMaskPaddingElements, maskValue, fineAdjustment, 0u, 0u), 0u, pinholeCamera.height());
1468  }
1469  else
1470  {
1471  panoramaFrame2cameraFrame8BitPerChannelSubset<tChannels>(&pinholeCamera, panoramaFrame, panoramaMask, panoramaFrameWidth, panoramaFrameHeight, panoramaFramePaddingElements, panoramaMaskPaddingElements, panoramaDimensionWidth, panoramaDimensionHeight, panoramaFrameTopLeft.x(), panoramaFrameTopLeft.y(), &orientation, cameraFrame, cameraMask, cameraFramePaddingElements, cameraMaskPaddingElements, maskValue, fineAdjustment, 0u, pinholeCamera.height());
1472  }
1473  }
1474  else
1475  {
1476  const unsigned int binsX = min(pinholeCamera.width() / approximationBinSize, pinholeCamera.width() / 4u);
1477  const unsigned int binsY = min(pinholeCamera.height() / approximationBinSize, pinholeCamera.height() / 4u);
1478  LookupTable lookupTable(pinholeCamera.width(), pinholeCamera.height(), binsX, binsY);
1479 
1480  panoramaFrame2cameraFrameLookupTable(pinholeCamera, orientation, panoramaDimensionWidth, panoramaDimensionHeight, panoramaFrameTopLeft, lookupTable, fineAdjustment);
1481 
1482  if (worker != nullptr)
1483  {
1484  worker->executeFunction(Worker::Function::createStatic(&panoramaFrame2cameraFrameLookup8BitPerChannelSubset<tChannels>, (const LookupTable*)(&lookupTable), panoramaFrame, panoramaMask, panoramaFramePaddingElements, panoramaMaskPaddingElements, panoramaDimensionWidth, panoramaDimensionHeight, panoramaFrameTopLeft.x(), panoramaFrameTopLeft.y(), panoramaFrameWidth, panoramaFrameHeight, cameraFrame, cameraMask, cameraFramePaddingElements, cameraMaskPaddingElements, maskValue, 0u, 0u), 0u, pinholeCamera.height());
1485  }
1486  else
1487  {
1488  panoramaFrame2cameraFrameLookup8BitPerChannelSubset<tChannels>((const LookupTable*)(&lookupTable), panoramaFrame, panoramaMask, panoramaFramePaddingElements, panoramaMaskPaddingElements, panoramaDimensionWidth, panoramaDimensionHeight, panoramaFrameTopLeft.x(), panoramaFrameTopLeft.y(), panoramaFrameWidth, panoramaFrameHeight, cameraFrame, cameraMask, cameraFramePaddingElements, cameraMaskPaddingElements, maskValue, 0u, pinholeCamera.height());
1489  }
1490  }
1491 }
1492 
1493 template <unsigned int tChannels>
1494 inline void PanoramaFrame::cameraFrame2panoramaFrame8BitPerChannel(const PinholeCamera& pinholeCamera, const uint8_t* cameraFrame, const unsigned int cameraFramePaddingElements, const SquareMatrix3& orientation, const unsigned int panoramaDimensionWidth, const unsigned int panoramaDimensionHeight, const PixelPositionI& panoramaFrameTopLeft, uint8_t* panoramaFrame, uint8_t* panoramaMask, const unsigned int panoramaFrameWidth, const unsigned int panoramaFrameHeight, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const uint8_t maskValue, const unsigned int approximationBinSize, Worker* worker, const LookupTable* fineAdjustment)
1495 {
1496  static_assert(tChannels >= 1u, "Invalid channel number!");
1497 
1498  ocean_assert(pinholeCamera.isValid() && !orientation.isSingular());
1499  ocean_assert(cameraFrame != nullptr);
1500  ocean_assert(panoramaFrame != nullptr && panoramaMask != nullptr);
1501  ocean_assert(panoramaFrameWidth != 0u && panoramaFrameHeight != 0u);
1502 
1503  if (approximationBinSize <= 1u)
1504  {
1505  if (worker != nullptr)
1506  {
1507  worker->executeFunction(Worker::Function::createStatic(&cameraFrame2panoramaFrame8BitPerChannelSubset<tChannels>, &pinholeCamera, cameraFrame, cameraFramePaddingElements, &orientation, panoramaDimensionWidth, panoramaDimensionHeight, panoramaFrameTopLeft.x(), panoramaFrameTopLeft.y(), panoramaFrame, panoramaMask, panoramaFrameWidth, panoramaFrameHeight, panoramaFramePaddingElements, panoramaMaskPaddingElements, maskValue, fineAdjustment, 0u, 0u), 0u, panoramaFrameHeight);
1508  }
1509  else
1510  {
1511  cameraFrame2panoramaFrame8BitPerChannelSubset<tChannels>(&pinholeCamera, cameraFrame, cameraFramePaddingElements, &orientation, panoramaDimensionWidth, panoramaDimensionHeight, panoramaFrameTopLeft.x(), panoramaFrameTopLeft.y(), panoramaFrame, panoramaMask, panoramaFrameWidth, panoramaFrameHeight, panoramaFramePaddingElements, panoramaMaskPaddingElements, maskValue, fineAdjustment, 0u, panoramaFrameHeight);
1512  }
1513  }
1514  else
1515  {
1516  const unsigned int binSize = approximationBinSize != 0u ? approximationBinSize : 20u;
1517 
1518  const unsigned int binsX = min(panoramaFrameWidth / binSize, panoramaFrameWidth / 4u);
1519  const unsigned int binsY = min(panoramaFrameHeight / binSize, panoramaFrameHeight / 4u);
1520  LookupTable lookupTable(panoramaFrameWidth, panoramaFrameHeight, binsX, binsY);
1521 
1522  cameraFrame2panoramaFrameLookupTable(pinholeCamera, orientation, panoramaDimensionWidth, panoramaDimensionHeight, panoramaFrameTopLeft, lookupTable, fineAdjustment);
1523 
1524  if (worker != nullptr)
1525  {
1526  worker->executeFunction(Worker::Function::createStatic(&cameraFrame2panoramaFrameLookup8BitPerChannelSubset<tChannels>, (const LookupTable*)(&lookupTable), cameraFrame, pinholeCamera.width(), pinholeCamera.height(), cameraFramePaddingElements, panoramaFrame, panoramaMask, panoramaFramePaddingElements, panoramaMaskPaddingElements, maskValue, 0u, 0u), 0u, panoramaFrameHeight);
1527  }
1528  else
1529  {
1530  cameraFrame2panoramaFrameLookup8BitPerChannelSubset<tChannels>(&lookupTable, cameraFrame, pinholeCamera.width(), pinholeCamera.height(), cameraFramePaddingElements, panoramaFrame, panoramaMask, panoramaFramePaddingElements, panoramaMaskPaddingElements, maskValue, 0u, panoramaFrameHeight);
1531  }
1532  }
1533 }
1534 
1535 template <unsigned int tChannels>
1536 inline void PanoramaFrame::cameraFrame2panoramaFrameMask8BitPerChannel(const PinholeCamera& pinholeCamera, const uint8_t* cameraFrame, const uint8_t* cameraMask, const unsigned int cameraFramePaddingElements, const unsigned int cameraMaskPaddingElements, const SquareMatrix3& orientation, const unsigned int panoramaDimensionWidth, const unsigned int panoramaDimensionHeight, const PixelPositionI& panoramaFrameTopLeft, uint8_t* panoramaFrame, uint8_t* panoramaMask, const unsigned int panoramaFrameWidth, const unsigned int panoramaFrameHeight, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const uint8_t maskValue, const unsigned int approximationBinSize, Worker* worker, const LookupTable* fineAdjustment)
1537 {
1538  static_assert(tChannels >= 1u, "Invalid channel number!");
1539 
1540  ocean_assert(pinholeCamera.isValid() && !orientation.isSingular());
1541 
1542  ocean_assert(cameraFrame != nullptr && cameraMask != nullptr);
1543  ocean_assert(panoramaFrame != nullptr && panoramaMask != nullptr);
1544  ocean_assert(panoramaFrameWidth != 0u && panoramaFrameHeight != 0u);
1545 
1546  if (approximationBinSize <= 1u)
1547  {
1548  if (worker != nullptr)
1549  {
1550  worker->executeFunction(Worker::Function::createStatic(&cameraFrame2panoramaFrameMask8BitPerChannelSubset<tChannels>, &pinholeCamera, cameraFrame, cameraMask, cameraFramePaddingElements, cameraMaskPaddingElements, &orientation, panoramaDimensionWidth, panoramaDimensionHeight, panoramaFrameTopLeft.x(), panoramaFrameTopLeft.y(), panoramaFrame, panoramaMask, panoramaFrameWidth, panoramaFrameHeight, panoramaFramePaddingElements, panoramaMaskPaddingElements, maskValue, fineAdjustment, 0u, 0u), 0u, panoramaFrameHeight);
1551  }
1552  else
1553  {
1554  cameraFrame2panoramaFrameMask8BitPerChannelSubset<tChannels>(&pinholeCamera, cameraFrame, cameraMask, cameraFramePaddingElements, cameraMaskPaddingElements, &orientation, panoramaDimensionWidth, panoramaDimensionHeight, panoramaFrameTopLeft.x(), panoramaFrameTopLeft.y(), panoramaFrame, panoramaMask, panoramaFrameWidth, panoramaFrameHeight, panoramaFramePaddingElements, panoramaMaskPaddingElements, maskValue, fineAdjustment, 0u, panoramaFrameHeight);
1555  }
1556  }
1557  else
1558  {
1559  const unsigned int binSize = approximationBinSize != 0u ? approximationBinSize : 20u;
1560 
1561  const unsigned int binsX = min(panoramaFrameWidth / binSize, panoramaFrameWidth / 4u);
1562  const unsigned int binsY = min(panoramaFrameHeight / binSize, panoramaFrameHeight / 4u);
1563  LookupTable lookupTable(panoramaFrameWidth, panoramaFrameHeight, binsX, binsY);
1564 
1565  cameraFrame2panoramaFrameLookupTable(pinholeCamera, orientation, panoramaDimensionWidth, panoramaDimensionHeight, panoramaFrameTopLeft, lookupTable, fineAdjustment);
1566 
1567  if (worker != nullptr)
1568  {
1569  worker->executeFunction(Worker::Function::createStatic(&cameraFrame2panoramaFrameMaskLookup8BitPerChannelSubset<tChannels>, (const LookupTable*)(&lookupTable), cameraFrame, cameraMask, pinholeCamera.width(), pinholeCamera.height(), cameraFramePaddingElements, cameraMaskPaddingElements, panoramaFrame, panoramaMask, panoramaFramePaddingElements, panoramaMaskPaddingElements, maskValue, 0u, 0u), 0u, panoramaFrameHeight);
1570  }
1571  else
1572  {
1573  cameraFrame2panoramaFrameMaskLookup8BitPerChannelSubset<tChannels>((const LookupTable*)(&lookupTable), cameraFrame, cameraMask, pinholeCamera.width(), pinholeCamera.height(), cameraFramePaddingElements, cameraMaskPaddingElements, panoramaFrame, panoramaMask, panoramaFramePaddingElements, panoramaMaskPaddingElements, maskValue, 0u, panoramaFrameHeight);
1574  }
1575  }
1576 }
1577 
1578 template <unsigned int tChannels>
1579 inline void PanoramaFrame::mergeSetAll8BitPerChannel(const uint8_t* panoramaSubFrame, const uint8_t* panoramaSubMask, const unsigned int subFrameWidth, const unsigned int subFrameHeight, const unsigned int panoramaSubFramePaddingElements, const unsigned panoramaSubMaskPaddingElements, const PixelPosition& subTopLeft, uint8_t* panoramaFrame, uint8_t* panoramaMask, const unsigned int panoramaWidth, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const PixelPosition& panoramaTopLeft, const uint8_t maskValue, Worker* worker)
1580 {
1581  static_assert(tChannels >= 1u, "Invalid channel number!");
1582 
1583  if (worker != nullptr)
1584  {
1585  worker->executeFunction(Worker::Function::createStatic(&PanoramaFrame::mergeSetAll8BitPerChannelSubset<tChannels>, panoramaSubFrame, panoramaSubMask, subFrameWidth, panoramaSubFramePaddingElements, panoramaSubMaskPaddingElements, subTopLeft.x(), subTopLeft.y(), panoramaFrame, panoramaMask, panoramaWidth, panoramaFramePaddingElements, panoramaMaskPaddingElements, panoramaTopLeft.x(), panoramaTopLeft.y(), maskValue, 0u, 0u), 0u, subFrameHeight, 15u, 16u, 20u);
1586  }
1587  else
1588  {
1589  mergeSetAll8BitPerChannelSubset<tChannels>(panoramaSubFrame, panoramaSubMask, subFrameWidth, panoramaSubFramePaddingElements, panoramaSubMaskPaddingElements, subTopLeft.x(), subTopLeft.y(), panoramaFrame, panoramaMask, panoramaWidth, panoramaFramePaddingElements, panoramaMaskPaddingElements, panoramaTopLeft.x(), panoramaTopLeft.y(), maskValue, 0u, subFrameHeight);
1590  }
1591 }
1592 
1593 template <unsigned int tChannels>
1594 inline void PanoramaFrame::mergeSetNew8BitPerChannel(const uint8_t* panoramaSubFrame, const uint8_t* panoramaSubMask, const unsigned int subFrameWidth, const unsigned int subFrameHeight, const unsigned int panoramaSubFramePaddingElements, const unsigned panoramaSubMaskPaddingElements, const PixelPosition& subTopLeft, uint8_t* panoramaFrame, uint8_t* panoramaMask, const unsigned int panoramaWidth, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const PixelPosition& panoramaTopLeft, const uint8_t maskValue, Worker* worker)
1595 {
1596  static_assert(tChannels >= 1u, "Invalid channel number!");
1597 
1598  if (worker != nullptr)
1599  {
1600  worker->executeFunction(Worker::Function::createStatic(&PanoramaFrame::mergeSetNew8BitPerChannelSubset<tChannels>, panoramaSubFrame, panoramaSubMask, subFrameWidth, panoramaSubFramePaddingElements, panoramaSubMaskPaddingElements, subTopLeft.x(), subTopLeft.y(), panoramaFrame, panoramaMask, panoramaWidth, panoramaFramePaddingElements, panoramaMaskPaddingElements, panoramaTopLeft.x(), panoramaTopLeft.y(), maskValue, 0u, 0u), 0u, subFrameHeight, 15u, 16u, 20u);
1601  }
1602  else
1603  {
1604  mergeSetNew8BitPerChannelSubset<tChannels>(panoramaSubFrame, panoramaSubMask, subFrameWidth, panoramaSubFramePaddingElements, panoramaSubMaskPaddingElements, subTopLeft.x(), subTopLeft.y(), panoramaFrame, panoramaMask, panoramaWidth, panoramaFramePaddingElements, panoramaMaskPaddingElements, panoramaTopLeft.x(), panoramaTopLeft.y(), maskValue, 0u, subFrameHeight);
1605  }
1606 }
1607 
1608 template <unsigned int tChannels>
1609 inline void PanoramaFrame::mergeAverageLocal8BitPerChannel(const uint8_t* panoramaSubFrame, const uint8_t* panoramaSubMask, const unsigned int subFrameWidth, const unsigned int subFrameHeight, const unsigned int panoramaSubFramePaddingElements, const unsigned panoramaSubMaskPaddingElements, const PixelPosition& subTopLeft, uint8_t* panoramaFrame, uint8_t* panoramaMask, const unsigned int panoramaWidth, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const PixelPosition& panoramaTopLeft, const uint8_t maskValue, Worker* worker)
1610 {
1611  static_assert(tChannels >= 1u, "Invalid channel number!");
1612 
1613  if (worker != nullptr)
1614  {
1615  worker->executeFunction(Worker::Function::createStatic(&PanoramaFrame::mergeAverageLocal8BitPerChannelSubset<tChannels>, panoramaSubFrame, panoramaSubMask, subFrameWidth, panoramaSubFramePaddingElements, panoramaSubMaskPaddingElements, subTopLeft.x(), subTopLeft.y(), panoramaFrame, panoramaMask, panoramaWidth, panoramaFramePaddingElements, panoramaMaskPaddingElements, panoramaTopLeft.x(), panoramaTopLeft.y(), maskValue, 0u, 0u), 0u, subFrameHeight, 15u, 16u, 20u);
1616  }
1617  else
1618  {
1619  mergeAverageLocal8BitPerChannelSubset<tChannels>(panoramaSubFrame, panoramaSubMask, subFrameWidth, panoramaSubFramePaddingElements, panoramaSubMaskPaddingElements, subTopLeft.x(), subTopLeft.y(), panoramaFrame, panoramaMask, panoramaWidth, panoramaFramePaddingElements, panoramaMaskPaddingElements, panoramaTopLeft.x(), panoramaTopLeft.y(), maskValue, 0u, subFrameHeight);
1620  }
1621 }
1622 
1623 template <unsigned int tChannels>
1624 inline void PanoramaFrame::mergeAverageGlobal8BitPerChannel(const uint8_t* panoramaSubFrame, const uint8_t* panoramaSubMask, const unsigned int subFrameWidth, const unsigned int subFrameHeight, const unsigned int panoramaSubFramePaddingElements, const unsigned int panoramaSubMaskPaddingElements, const PixelPosition& subTopLeft, uint32_t* panoramaNominatorFrame, uint32_t* panoramaDenominatorFrame, uint8_t* panoramaFrame, uint8_t* panoramaMask, const unsigned int panoramaWidth, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const PixelPosition& panoramaTopLeft, const uint8_t maskValue, Worker* worker)
1625 {
1626  static_assert(tChannels >= 1u, "Invalid channel number!");
1627 
1628  if (worker != nullptr)
1629  {
1630  worker->executeFunction(Worker::Function::createStatic(&PanoramaFrame::mergeAverageGlobal8BitPerChannelSubset<tChannels>, panoramaSubFrame, panoramaSubMask, subFrameWidth, panoramaSubFramePaddingElements, panoramaSubMaskPaddingElements, subTopLeft.x(), subTopLeft.y(), panoramaNominatorFrame, panoramaDenominatorFrame, panoramaFrame, panoramaMask, panoramaWidth, panoramaFramePaddingElements, panoramaMaskPaddingElements, panoramaTopLeft.x(), panoramaTopLeft.y(), maskValue, 0u, 0u), 0u, subFrameHeight, 17u, 18u, 20u);
1631  }
1632  else
1633  {
1634  mergeAverageGlobal8BitPerChannelSubset<tChannels>(panoramaSubFrame, panoramaSubMask, subFrameWidth, panoramaSubFramePaddingElements, panoramaSubMaskPaddingElements, subTopLeft.x(), subTopLeft.y(), panoramaNominatorFrame, panoramaDenominatorFrame, panoramaFrame, panoramaMask, panoramaWidth, panoramaFramePaddingElements, panoramaMaskPaddingElements, panoramaTopLeft.x(), panoramaTopLeft.y(), maskValue, 0u, subFrameHeight);
1635  }
1636 }
1637 
1638 template <unsigned int tChannels>
1639 void PanoramaFrame::cameraFrame2cameraFrame8BitPerChannelSubset(const PinholeCamera* inputCamera, const SquareMatrix3* inputOrientation, const uint8_t* inputFrame, const unsigned int inputFramePaddingElements, const PinholeCamera* outputCamera, const SquareMatrix3* outputOrientation, uint8_t* outputFrame, uint8_t* outputMask, const unsigned int outputFramePaddingElements, const unsigned int outputMaskPaddingElements, const uint8_t maskValue, const unsigned int firstOutputRow, const unsigned int numberOutputRows)
1640 {
1641  static_assert(tChannels >= 1u, "Invalid channel number!");
1642 
1643  ocean_assert(inputCamera != nullptr && inputCamera->isValid());
1644  ocean_assert(inputOrientation != nullptr && !inputOrientation->isSingular());
1645 
1646  ocean_assert(outputCamera != nullptr && outputCamera->isValid());
1647  ocean_assert(outputOrientation != nullptr && !outputOrientation->isSingular());
1648 
1649  ocean_assert(inputFrame != nullptr && outputFrame != nullptr && outputMask != nullptr);
1650 
1651  ocean_assert(firstOutputRow + numberOutputRows <= outputCamera->height());
1652 
1653  const SquareMatrix3 outputOrientationF(*outputOrientation * PinholeCamera::flipMatrix3());
1654  const SquareMatrix3 inputOrientationF(*inputOrientation * PinholeCamera::flipMatrix3());
1655 
1656  const SquareMatrix3 transformation(inputCamera->intrinsic() * inputOrientationF.inverted() * outputOrientationF * outputCamera->invertedIntrinsic());
1657 
1658  const unsigned int outputFrameStrideElements = outputCamera->width() * tChannels + outputFramePaddingElements;
1659  const unsigned int outputMaskStrideElements = outputCamera->width() + outputMaskPaddingElements;
1660 
1661  outputFrame += firstOutputRow * outputFrameStrideElements;
1662  outputMask += firstOutputRow * outputMaskStrideElements;
1663 
1664  for (unsigned int y = firstOutputRow; y < firstOutputRow + numberOutputRows; ++y)
1665  {
1666  for (unsigned int x = 0u; x < outputCamera->width(); ++x)
1667  {
1668  const Vector2 inputPosition_05 = inputCamera->distort<true>(transformation * outputCamera->undistort<true>(Vector2(Scalar(x), Scalar(y)))) + Vector2(Scalar(0.5), Scalar(0.5));
1669 
1670  if (inputPosition_05.x() >= 0 && inputPosition_05.x() <= Scalar(inputCamera->width()) && inputPosition_05.y() >= 0 && inputPosition_05.y() <= Scalar(inputCamera->height()))
1671  {
1672  FrameInterpolatorBilinear::interpolatePixel8BitPerChannel<tChannels, PC_CENTER>(inputFrame, inputCamera->width(), inputCamera->height(), inputFramePaddingElements, inputPosition_05, outputFrame);
1673  *outputMask = maskValue;
1674  }
1675  else
1676  {
1677  *outputMask = 0xFFu - maskValue;
1678  }
1679 
1680  outputFrame += tChannels;
1681  outputMask++;
1682  }
1683 
1684  outputFrame += outputFramePaddingElements;
1685  outputMask += outputMaskPaddingElements;
1686  }
1687 }
1688 
1689 template <unsigned int tChannels>
1690 void PanoramaFrame::cameraFrame2cameraFrameLookup8BitPerChannelSubset(const LookupTable* lookupTable, const uint8_t* inputFrame, const unsigned int inputWidth, const unsigned int inputHeight, const unsigned int inputFramePaddingElements, uint8_t* outputFrame, uint8_t* outputMask, const unsigned int outputFramePaddingElements, const unsigned int outputMaskPaddingElements, const uint8_t maskValue, const unsigned int firstOutputRow, const unsigned int numberOutputRows)
1691 {
1692  static_assert(tChannels >= 1u, "Invalid channel number!");
1693 
1694  ocean_assert(lookupTable && !lookupTable->isEmpty());
1695  ocean_assert(inputFrame);
1696  ocean_assert(outputFrame && outputMask);
1697 
1698  const unsigned int outputFrameStrideElements = (unsigned int)(lookupTable->sizeX()) * tChannels + outputFramePaddingElements;
1699  const unsigned int outputMaskStrideElements = (unsigned int)(lookupTable->sizeX()) + outputMaskPaddingElements;
1700 
1701  outputFrame += firstOutputRow * outputFrameStrideElements;
1702  outputMask += firstOutputRow * outputMaskStrideElements;
1703 
1704  for (unsigned int y = firstOutputRow; y < firstOutputRow + numberOutputRows; ++y)
1705  {
1706  for (unsigned int x = 0u; x < lookupTable->sizeX(); ++x)
1707  {
1708  const Vector2 inputPosition_05 = lookupTable->bilinearValue(Scalar(x), Scalar(y)) + Vector2(Scalar(0.5), Scalar(0.5));
1709 
1710  if (inputPosition_05.x() >= 0 && inputPosition_05.x() <= Scalar(inputWidth) && inputPosition_05.y() >= 0 && inputPosition_05.y() <= Scalar(inputHeight))
1711  {
1712  FrameInterpolatorBilinear::interpolatePixel8BitPerChannel<tChannels, PC_CENTER>(inputFrame, inputWidth, inputHeight, inputFramePaddingElements, inputPosition_05, outputFrame);
1713  *outputMask = maskValue;
1714  }
1715  else
1716  {
1717  *outputMask = 0xFFu - maskValue;
1718  }
1719 
1720  outputFrame += tChannels;
1721  outputMask++;
1722  }
1723 
1724  outputFrame += outputFramePaddingElements;
1725  outputMask += outputMaskPaddingElements;
1726  }
1727 }
1728 
1729 template <unsigned int tChannels>
1730 void PanoramaFrame::cameraFrame2cameraFrameMask8BitPerChannelSubset(const PinholeCamera* inputCamera, const SquareMatrix3* inputOrientation, const uint8_t* inputFrame, const uint8_t* inputMask, const unsigned int inputFramePaddingElements, const unsigned int inputMaskPaddingElements,const PinholeCamera* outputCamera, const SquareMatrix3* outputOrientation, uint8_t* outputFrame, uint8_t* outputMask, const unsigned int outputFramePaddingElements, const unsigned int outputMaskPaddingElements, const uint8_t maskValue, const unsigned int firstOutputRow, const unsigned int numberOutputRows)
1731 {
1732  static_assert(tChannels >= 1u, "Invalid channel number!");
1733 
1734  ocean_assert(inputCamera != nullptr && inputCamera->isValid());
1735  ocean_assert(inputOrientation != nullptr && !inputOrientation->isSingular());
1736 
1737  ocean_assert(outputCamera != nullptr && outputCamera->isValid());
1738  ocean_assert(outputOrientation != nullptr && !outputOrientation->isSingular());
1739 
1740  ocean_assert(inputFrame != nullptr && inputMask != nullptr && outputFrame != nullptr && outputMask != nullptr );
1741 
1742  ocean_assert(firstOutputRow + numberOutputRows <= outputCamera->height());
1743 
1744  const SquareMatrix3 outputOrientationF(*outputOrientation * PinholeCamera::flipMatrix3());
1745  const SquareMatrix3 inputOrientationF(*inputOrientation * PinholeCamera::flipMatrix3());
1746 
1747  const SquareMatrix3 transformation(inputCamera->intrinsic() * inputOrientationF.inverted() * outputOrientationF * outputCamera->invertedIntrinsic());
1748 
1749  const unsigned int outputFrameStrideElements = outputCamera->width() * tChannels + outputFramePaddingElements;
1750  const unsigned int outputMaskStrideElements = outputCamera->width() + outputMaskPaddingElements;
1751 
1752  outputFrame += firstOutputRow * outputFrameStrideElements;
1753  outputMask += firstOutputRow * outputMaskStrideElements;
1754 
1755  for (unsigned int y = firstOutputRow; y < firstOutputRow + numberOutputRows; ++y)
1756  {
1757  for (unsigned int x = 0u; x < outputCamera->width(); ++x)
1758  {
1759  const Vector2 inputPosition = inputCamera->distort<true>(transformation * outputCamera->undistort<true>(Vector2(Scalar(x), Scalar(y))));
1760  AdvancedFrameInterpolatorBilinear::interpolatePixelWithMask8BitPerChannel<tChannels, PC_TOP_LEFT>(inputFrame, inputMask, inputCamera->width(), inputCamera->height(), inputFramePaddingElements, inputMaskPaddingElements, inputPosition, outputFrame, outputMask[x], maskValue);
1761 
1762  outputFrame += tChannels;
1763  }
1764 
1765  outputFrame += outputFramePaddingElements;
1766  outputMask += outputMaskStrideElements;
1767  }
1768 }
1769 
1770 template <unsigned int tChannels>
1771 void PanoramaFrame::cameraFrame2cameraFrameMaskLookup8BitPerChannelSubset(const LookupTable* lookupTable, const uint8_t* inputFrame, const uint8_t* inputMask, const unsigned int inputWidth, const unsigned int inputHeight, const unsigned int inputFramePaddingElements, const unsigned int inputMaskPaddingElements, uint8_t* outputFrame, uint8_t* outputMask, const unsigned int outputFramePaddingElements, const unsigned int outputMaskPaddingElements, const uint8_t maskValue, const unsigned int firstOutputRow, const unsigned int numberOutputRows)
1772 {
1773  static_assert(tChannels >= 1u, "Invalid channel number!");
1774 
1775  ocean_assert(lookupTable != nullptr && !lookupTable->isEmpty());
1776  ocean_assert(inputFrame != nullptr && inputMask != nullptr);
1777  ocean_assert(outputFrame != nullptr && outputMask != nullptr);
1778 
1779  const unsigned int outputFrameStrideElements = (unsigned int)(lookupTable->sizeX()) * tChannels + outputFramePaddingElements;
1780  const unsigned int outputMaskStrideElements = (unsigned int)(lookupTable->sizeX()) + outputMaskPaddingElements;
1781 
1782  outputFrame += firstOutputRow * outputFrameStrideElements;
1783  outputMask += firstOutputRow * outputMaskStrideElements;
1784 
1785  for (unsigned int y = firstOutputRow; y < firstOutputRow + numberOutputRows; ++y)
1786  {
1787  for (unsigned int x = 0u; x < lookupTable->sizeX(); ++x)
1788  {
1789  const Vector2 inputPosition = lookupTable->bilinearValue(Scalar(x), Scalar(y));
1790 
1791  AdvancedFrameInterpolatorBilinear::interpolatePixelWithMask8BitPerChannel<tChannels, PC_TOP_LEFT>(inputFrame, inputMask, inputWidth, inputHeight, inputFramePaddingElements, inputMaskPaddingElements, inputPosition, outputFrame, outputMask[x], maskValue);
1792 
1793  outputFrame += tChannels;
1794  }
1795 
1796  outputFrame += outputFramePaddingElements;
1797  outputMask += outputMaskStrideElements;
1798  }
1799 }
1800 
1801 template <unsigned int tChannels>
1802 void PanoramaFrame::panoramaFrame2cameraFrame8BitPerChannelSubset(const PinholeCamera* pinholeCamera, const uint8_t* panoramaFrame, const uint8_t* panoramaMask, const unsigned int panoramaFrameWidth, const unsigned int panoramaFrameHeight, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const unsigned int panoramaDimensionWidth, const unsigned int panoramaDimensionHeight, const unsigned int panoramaFrameTopLeftX, const unsigned int panoramaFrameTopLeftY, const SquareMatrix3* orientation, uint8_t* cameraFrame, uint8_t* cameraMask, const unsigned int cameraFramePaddingElements, const unsigned int cameraMaskPaddingElements, const uint8_t maskValue, const LookupTable* fineAdjustment, const unsigned int firstCameraRow, const unsigned int numberCameraRows)
1803 {
1804  static_assert(tChannels >= 1u, "Invalid channel number!");
1805 
1806  ocean_assert(pinholeCamera != nullptr && pinholeCamera->isValid());
1807  ocean_assert(orientation != nullptr && !orientation->isSingular());
1808  ocean_assert(firstCameraRow + numberCameraRows <= pinholeCamera->height());
1809 
1810  ocean_assert(panoramaFrameTopLeftX + panoramaFrameWidth <= panoramaDimensionWidth);
1811  ocean_assert(panoramaFrameTopLeftY + panoramaFrameHeight <= panoramaDimensionHeight);
1812  const Vector2 frameTopLeft_ = Vector2(Scalar(panoramaFrameTopLeftX), Scalar(panoramaFrameTopLeftY));
1813 
1814  const unsigned int cameraFrameStrideElements = pinholeCamera->width() * tChannels + cameraFramePaddingElements;
1815  const unsigned int cameraMaskStrideElements = pinholeCamera->width() + cameraMaskPaddingElements;
1816 
1817  for (unsigned int y = firstCameraRow; y < firstCameraRow + numberCameraRows; ++y)
1818  {
1819  uint8_t* cameraFrameRow = cameraFrame + y * cameraFrameStrideElements;
1820  uint8_t* cameraMaskRow = cameraMask + y * cameraMaskStrideElements;
1821 
1822  for (unsigned int x = 0u; x < pinholeCamera->width(); ++x)
1823  {
1824  Vector2 cameraPosition = Vector2(Scalar(x), Scalar(y));
1825 
1826  if (fineAdjustment)
1827  {
1828  cameraPosition += fineAdjustment->bilinearValue(cameraPosition.x(), cameraPosition.y());
1829  }
1830 
1831  const Vector3 ray(*orientation * pinholeCamera->vector(pinholeCamera->undistort<true>(cameraPosition)));
1832 
1833  const Vector2 angle(ray2angleStrict(ray));
1834  const Vector2 panoramaPosition(angle2pixel(angle, panoramaDimensionWidth, panoramaDimensionHeight));
1835 
1836  const Vector2 localPanoramaPosition(panoramaPosition - frameTopLeft_);
1837 
1838  AdvancedFrameInterpolatorBilinear::interpolatePixelWithMask8BitPerChannel<tChannels, PC_TOP_LEFT>(panoramaFrame, panoramaMask, panoramaFrameWidth, panoramaFrameHeight, panoramaFramePaddingElements, panoramaMaskPaddingElements, localPanoramaPosition, cameraFrameRow, cameraMaskRow[x], maskValue);
1839 
1840  cameraFrameRow += tChannels;
1841  }
1842  }
1843 }
1844 
1845 template <unsigned int tChannels>
1846 void PanoramaFrame::panoramaFrame2cameraFrameLookup8BitPerChannelSubset(const LookupTable* lookupTable, const uint8_t* panoramaFrame, const uint8_t* panoramaMask, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const unsigned int panoramaDimensionWidth, const unsigned int panoramaDimensionHeight, const unsigned int panoramaFrameTopLeftX, const unsigned int panoramaFrameTopLeftY, const unsigned int panoramaFrameWidth, const unsigned int panoramaFrameHeight, uint8_t* cameraFrame, uint8_t* cameraMask, const unsigned int cameraFramePaddingElements, const unsigned int cameraMaskPaddingElements, const uint8_t maskValue, const unsigned int firstCameraRow, const unsigned int numberCameraRows)
1847 {
1848  static_assert(tChannels >= 1u, "Invalid channel number!");
1849 
1850  ocean_assert(lookupTable != nullptr && *lookupTable);
1851  ocean_assert(firstCameraRow + numberCameraRows <= lookupTable->sizeY());
1852 
1853  const unsigned int cameraFrameStrideElements = (unsigned int)(lookupTable->sizeX()) * tChannels + cameraFramePaddingElements;
1854  const unsigned int cameraMaskStrideElements = (unsigned int)(lookupTable->sizeX()) + cameraMaskPaddingElements;
1855 
1856  const Scalar panoramaDimensionWidth_2 = Scalar(panoramaDimensionWidth) * Scalar(0.5);
1857 
1858  Vector2 topLeft, topRight, bottomLeft, bottomRight;
1859  Scalar factorTopLeft, factorTopRight, factorBottomLeft, factorBottomRight;
1860 
1861  for (unsigned int y = firstCameraRow; y < firstCameraRow + numberCameraRows; ++y)
1862  {
1863  uint8_t* cameraFrameRow = cameraFrame + y * cameraFrameStrideElements;
1864  uint8_t* cameraMaskRow = cameraMask + y * cameraMaskStrideElements;
1865 
1866  for (unsigned int x = 0u; x < lookupTable->sizeX(); ++x)
1867  {
1868  lookupTable->bilinearValue(Scalar(x), Scalar(y), topLeft, topRight, bottomLeft, bottomRight, factorTopLeft, factorTopRight, factorBottomLeft, factorBottomRight);
1869 
1870  if (topRight.x() > topLeft.x() && topRight.x() - topLeft.x() > panoramaDimensionWidth_2)
1871  {
1872  topRight.x() -= Scalar(panoramaDimensionWidth);
1873  }
1874  else if (topRight.x() < topLeft.x() && topLeft.x() - topRight.x() > panoramaDimensionWidth_2)
1875  {
1876  topRight.x() += Scalar(panoramaDimensionWidth);
1877  }
1878 
1879  if (bottomLeft.x() > topLeft.x() && bottomLeft.x() - topLeft.x() > panoramaDimensionWidth_2)
1880  {
1881  bottomLeft.x() -= Scalar(panoramaDimensionWidth);
1882  }
1883  else if (bottomLeft.x() < topLeft.x() && topLeft.x() - bottomLeft.x() > panoramaDimensionWidth_2)
1884  {
1885  bottomLeft.x() += Scalar(panoramaDimensionWidth);
1886  }
1887 
1888  if (bottomRight.x() > topLeft.x() && bottomRight.x() - topLeft.x() > panoramaDimensionWidth_2)
1889  {
1890  bottomRight.x() -= Scalar(panoramaDimensionWidth);
1891  }
1892  else if (bottomRight.x() < topLeft.x() && topLeft.x() - bottomRight.x() > panoramaDimensionWidth_2)
1893  {
1894  bottomRight.x() += Scalar(panoramaDimensionWidth);
1895  }
1896 
1897  Vector2 localPanoramaPosition = topLeft * factorTopLeft + topRight * factorTopRight + bottomLeft * factorBottomLeft + bottomRight * factorBottomRight;
1898 
1899  if (localPanoramaPosition.y() >= Scalar(panoramaDimensionHeight))
1900  {
1901  localPanoramaPosition.y() = Scalar(panoramaDimensionHeight * 2u) - localPanoramaPosition.y();
1902 
1903  if (localPanoramaPosition.x() > panoramaDimensionWidth_2)
1904  {
1905  localPanoramaPosition.x() -= panoramaDimensionWidth_2;
1906  }
1907  else
1908  {
1909  localPanoramaPosition.x() += panoramaDimensionWidth_2;
1910  }
1911  }
1912  else if (localPanoramaPosition.y() < Scalar(0))
1913  {
1914  localPanoramaPosition.y() = -localPanoramaPosition.y();
1915 
1916  if (localPanoramaPosition.x() > panoramaDimensionWidth_2)
1917  {
1918  localPanoramaPosition.x() -= panoramaDimensionWidth_2;
1919  }
1920  else
1921  {
1922  localPanoramaPosition.x() += panoramaDimensionWidth_2;
1923  }
1924  }
1925 
1926  ocean_assert(localPanoramaPosition.y() >= Scalar(0) && localPanoramaPosition.y() <= Scalar(panoramaDimensionHeight));
1927 
1928  if (localPanoramaPosition.x() >= Scalar(panoramaDimensionWidth))
1929  {
1930  localPanoramaPosition.x() -= Scalar(panoramaDimensionWidth);
1931  }
1932  else if (localPanoramaPosition.x() < Scalar(0))
1933  {
1934  localPanoramaPosition.x() += Scalar(panoramaDimensionWidth);
1935  }
1936 
1937  ocean_assert(localPanoramaPosition.x() >= Scalar(0) && localPanoramaPosition.x() < Scalar(panoramaDimensionWidth));
1938 
1939  localPanoramaPosition.x() -= Scalar(panoramaFrameTopLeftX);
1940  localPanoramaPosition.y() -= Scalar(panoramaFrameTopLeftY);
1941 
1942  // **TODO** should pixel center be incorporated also above during mirroring/modulo calculation?
1943 
1944  AdvancedFrameInterpolatorBilinear::interpolatePixelWithMask8BitPerChannel<tChannels, PC_TOP_LEFT>(panoramaFrame, panoramaMask, panoramaFrameWidth, panoramaFrameHeight, panoramaFramePaddingElements, panoramaMaskPaddingElements, localPanoramaPosition, cameraFrameRow, cameraMaskRow[x], maskValue);
1945 
1946  cameraFrameRow += tChannels;
1947  }
1948  }
1949 }
1950 
1951 template <unsigned int tChannels>
1952 void PanoramaFrame::cameraFrame2panoramaFrame8BitPerChannelSubset(const PinholeCamera* pinholeCamera, const uint8_t* cameraFrame, const unsigned int cameraFramePaddingElements, const SquareMatrix3* orientation, const unsigned int panoramaDimensionWidth, const unsigned int panoramaDimensionHeight, const int panoramaFrameTopLeftX, const int panoramaFrameTopLeftY, uint8_t* panoramaFrame, uint8_t* panoramaMask, const unsigned int panoramaFrameWidth, const unsigned int panoramaFrameHeight, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const uint8_t maskValue, const LookupTable* fineAdjustment, const unsigned int firstPanoramaRow, const unsigned int numberPanoramaRows)
1953 {
1954  static_assert(tChannels >= 1u, "Invalid channel number!");
1955 
1956  ocean_assert(pinholeCamera != nullptr && pinholeCamera->isValid());
1957  ocean_assert(orientation != nullptr && !orientation->isSingular());
1958  ocean_assert_and_suppress_unused(firstPanoramaRow + numberPanoramaRows <= panoramaFrameHeight, panoramaFrameHeight);
1959 
1960  const Vector2 frameTopLeft_ = Vector2(Scalar(panoramaFrameTopLeftX), Scalar(panoramaFrameTopLeftY));
1961 
1962  ocean_assert(panoramaDimensionWidth != 0u && panoramaDimensionHeight != 0u);
1963  const Scalar invPanoramaDimensionWidth = Scalar(1) / Scalar(panoramaDimensionWidth);
1964  const Scalar invPanoramaDimensionHeight = Scalar(1) / Scalar(panoramaDimensionHeight);
1965 
1966  const SquareMatrix3 invOrientation(orientation->inverted());
1967 
1968  const unsigned int panoramaFrameStrideElements = panoramaFrameWidth * tChannels + panoramaFramePaddingElements;
1969  const unsigned int panoramaMaskStrideElements = panoramaFrameWidth + panoramaMaskPaddingElements;
1970 
1971  const Vector3 roughPrincipalRay(*orientation * pinholeCamera->vector(Vector2(pinholeCamera->principalPointX(), pinholeCamera->principalPointY())));
1972 
1973  for (unsigned int y = firstPanoramaRow; y < firstPanoramaRow + numberPanoramaRows; ++y)
1974  {
1975  uint8_t* panoramaFrameRow = panoramaFrame + y * panoramaFrameStrideElements;
1976  uint8_t* panoramaMaskRow = panoramaMask + y * panoramaMaskStrideElements;
1977 
1978  for (unsigned int x = 0u; x < panoramaFrameWidth; ++x)
1979  {
1980  const Vector2 localPanoramaPosition = Vector2(Scalar(x), Scalar(y));
1981  const Vector2 panoramaPosition = Vector2(localPanoramaPosition + frameTopLeft_);
1982 
1983  const Vector2 angle(pixel2angle(panoramaPosition, invPanoramaDimensionWidth, invPanoramaDimensionHeight));
1984 
1985  const Vector3 ray(angle2ray(angle));
1986 
1987  if (roughPrincipalRay * ray <= 0)
1988  {
1989  // workaround for camera frames cutting the panorama frame into two pieces
1990  *panoramaMaskRow = 0xFFu - maskValue;
1991  }
1992  else
1993  {
1994  const Vector3 invRay(invOrientation * ray);
1995  const Vector3 rayOnPlane(invRay * Scalar(-1) / invRay.z());
1996 
1997  Vector2 cameraPosition(pinholeCamera->normalizedImagePoint2imagePoint<true>(Vector2(rayOnPlane.x(), -rayOnPlane.y()), true));
1998 
1999  if (fineAdjustment)
2000  {
2001  cameraPosition += fineAdjustment->clampedBilinearValue(cameraPosition.x(), cameraPosition.y());
2002  }
2003 
2004  const Vector2 cameraPosition_05 = cameraPosition + Vector2(Scalar(0.5), Scalar(0.5));
2005 
2006  if (cameraPosition_05.x() >= 0 && cameraPosition_05.x() <= Scalar(pinholeCamera->width()) && cameraPosition_05.y() >= 0 && cameraPosition_05.y() <= Scalar(pinholeCamera->height()))
2007  {
2008  FrameInterpolatorBilinear::interpolatePixel8BitPerChannel<tChannels, PC_CENTER>(cameraFrame, pinholeCamera->width(), pinholeCamera->height(), cameraFramePaddingElements, cameraPosition_05, panoramaFrameRow);
2009  *panoramaMaskRow = maskValue;
2010  }
2011  else
2012  {
2013  *panoramaMaskRow = 0xFFu - maskValue;
2014  }
2015  }
2016 
2017  panoramaFrameRow += tChannels;
2018  ++panoramaMaskRow;
2019  }
2020  }
2021 }
2022 
2023 template <unsigned int tChannels>
2024 void PanoramaFrame::cameraFrame2panoramaFrameLookup8BitPerChannelSubset(const LookupTable* lookupTable, const uint8_t* cameraFrame, const unsigned int cameraFrameWidth, const unsigned int cameraFrameHeight, const unsigned int cameraFramePaddingElements, uint8_t* panoramaFrame, uint8_t* panoramaMask, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const uint8_t maskValue, const unsigned int firstPanoramaRow, const unsigned int numberPanoramaRows)
2025 {
2026  static_assert(tChannels >= 1u, "Invalid channel number!");
2027 
2028  ocean_assert(lookupTable != nullptr && !lookupTable->isEmpty());
2029  ocean_assert(firstPanoramaRow + numberPanoramaRows <= lookupTable->sizeY());
2030 
2031  const unsigned int panoramaFrameStrideElements = (unsigned int)(lookupTable->sizeX()) * tChannels + panoramaFramePaddingElements;
2032  const unsigned int panoramaMaskStrideElements = (unsigned int)(lookupTable->sizeX()) + panoramaMaskPaddingElements;
2033 
2034  for (unsigned int y = firstPanoramaRow; y < firstPanoramaRow + numberPanoramaRows; ++y)
2035  {
2036  uint8_t* panoramaFrameRow = panoramaFrame + y * panoramaFrameStrideElements;
2037  uint8_t* panoramaMaskRow = panoramaMask + y * panoramaMaskStrideElements;
2038 
2039  for (unsigned int x = 0u; x < lookupTable->sizeX(); ++x)
2040  {
2041  const Vector2 cameraPosition(lookupTable->bilinearValue(Scalar(x), Scalar(y)));
2042  const Vector2 cameraPosition_05 = cameraPosition + Vector2(Scalar(0.5), Scalar(0.5));
2043 
2044  if (cameraPosition_05.x() >= 0 && cameraPosition_05.x() <= Scalar(cameraFrameWidth) && cameraPosition_05.y() >= 0 && cameraPosition_05.y() <= Scalar(cameraFrameHeight))
2045  {
2046  FrameInterpolatorBilinear::interpolatePixel8BitPerChannel<tChannels, PC_CENTER>(cameraFrame, cameraFrameWidth, cameraFrameHeight, cameraFramePaddingElements, cameraPosition_05, panoramaFrameRow);
2047  *panoramaMaskRow = maskValue;
2048  }
2049  else
2050  {
2051  *panoramaMaskRow = 0xFFu - maskValue;
2052  }
2053 
2054  panoramaFrameRow += tChannels;
2055  ++panoramaMaskRow;
2056  }
2057  }
2058 }
2059 
2060 template <unsigned int tChannels>
2061 void PanoramaFrame::cameraFrame2panoramaFrameMask8BitPerChannelSubset(const PinholeCamera* pinholeCamera, const uint8_t* cameraFrame, const uint8_t* cameraMask, const unsigned int cameraFramePaddingElements, const unsigned int cameraMaskPaddingElements, const SquareMatrix3* orientation, const unsigned int panoramaDimensionWidth, const unsigned int panoramaDimensionHeight, const int panoramaFrameTopLeftX, const int panoramaFrameTopLeftY, uint8_t* panoramaFrame, uint8_t* panoramaMask, const unsigned int panoramaFrameWidth, const unsigned int panoramaFrameHeight, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const uint8_t maskValue, const LookupTable* fineAdjustment, const unsigned int firstPanoramaRow, const unsigned int numberPanoramaRows)
2062 {
2063  static_assert(tChannels >= 1u, "Invalid channel number!");
2064 
2065  ocean_assert(pinholeCamera && pinholeCamera->isValid());
2066  ocean_assert(orientation && !orientation->isSingular());
2067  ocean_assert_and_suppress_unused(firstPanoramaRow + numberPanoramaRows <= panoramaFrameHeight, panoramaFrameHeight);
2068  ocean_assert(fineAdjustment == nullptr || ((unsigned int)fineAdjustment->sizeX() == pinholeCamera->width() && (unsigned int)fineAdjustment->sizeY() == pinholeCamera->height()));
2069 
2070  const Vector2 frameTopLeft_ = Vector2(Scalar(panoramaFrameTopLeftX), Scalar(panoramaFrameTopLeftY));
2071 
2072  ocean_assert(panoramaDimensionWidth != 0u && panoramaDimensionHeight != 0u);
2073  const Scalar invPanoramaDimensionWidth = Scalar(1) / Scalar(panoramaDimensionWidth);
2074  const Scalar invPanoramaDimensionHeight = Scalar(1) / Scalar(panoramaDimensionHeight);
2075 
2076  const SquareMatrix3 invOrientation(orientation->inverted());
2077 
2078  const unsigned int panoramaFrameStrideElements = panoramaFrameWidth * tChannels + panoramaFramePaddingElements;
2079  const unsigned int panoramaMaskStrideElements = panoramaFrameWidth + panoramaMaskPaddingElements;
2080 
2081  for (unsigned int y = firstPanoramaRow; y < firstPanoramaRow + numberPanoramaRows; ++y)
2082  {
2083  uint8_t* panoramaFrameRow = panoramaFrame + y * panoramaFrameStrideElements;
2084  uint8_t* panoramaMaskRow = panoramaMask + y * panoramaMaskStrideElements;
2085 
2086  for (unsigned int x = 0u; x < panoramaFrameWidth; ++x)
2087  {
2088  const Vector2 localPanoramaPosition = Vector2(Scalar(x), Scalar(y));
2089  const Vector2 panoramaPosition = Vector2(localPanoramaPosition + frameTopLeft_);
2090 
2091  const Vector2 angle(pixel2angle(panoramaPosition, invPanoramaDimensionWidth, invPanoramaDimensionHeight));
2092  const Vector3 ray(invOrientation * angle2ray(angle));
2093  ocean_assert(ray.z() < 0);
2094 
2095  const Vector3 rayOnPlane(ray * Scalar(-1) / ray.z());
2096  ocean_assert(rayOnPlane.z() < 0);
2097 
2098  Vector2 cameraPosition(pinholeCamera->normalizedImagePoint2imagePoint<true>(Vector2(rayOnPlane.x(), -rayOnPlane.y()), true));
2099 
2100  if (fineAdjustment)
2101  {
2102  cameraPosition += fineAdjustment->clampedBilinearValue(cameraPosition.x(), cameraPosition.y());
2103  }
2104 
2105  AdvancedFrameInterpolatorBilinear::interpolatePixelWithMask8BitPerChannel<tChannels, PC_TOP_LEFT>(cameraFrame, cameraMask, pinholeCamera->width(), pinholeCamera->height(), cameraFramePaddingElements, cameraMaskPaddingElements, cameraPosition, panoramaFrameRow, panoramaMaskRow[x], maskValue);
2106 
2107  panoramaFrameRow += tChannels;
2108  }
2109  }
2110 }
2111 
2112 template <unsigned int tChannels>
2113 void PanoramaFrame::cameraFrame2panoramaFrameMaskLookup8BitPerChannelSubset(const LookupTable* lookupTable, const uint8_t* cameraFrame, const uint8_t* cameraMask, const unsigned int cameraFrameWidth, const unsigned int cameraFrameHeight, const unsigned int cameraFramePaddingElements, const unsigned int cameraMaskPaddingElements, uint8_t* panoramaFrame, uint8_t* panoramaMask, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const uint8_t maskValue, const unsigned int firstPanoramaRow, const unsigned int numberPanoramaRows)
2114 {
2115  static_assert(tChannels >= 1u, "Invalid channel number!");
2116 
2117  ocean_assert(lookupTable != nullptr && !lookupTable->isEmpty());
2118  ocean_assert(firstPanoramaRow + numberPanoramaRows <= lookupTable->sizeY());
2119 
2120  const unsigned int panoramaFrameStrideElements = (unsigned int)(lookupTable->sizeX()) * tChannels + panoramaFramePaddingElements;
2121  const unsigned int panoramaMaskStrideElements = (unsigned int)(lookupTable->sizeX()) + panoramaMaskPaddingElements;
2122 
2123  for (unsigned int y = firstPanoramaRow; y < firstPanoramaRow + numberPanoramaRows; ++y)
2124  {
2125  uint8_t* panoramaFrameRow = panoramaFrame + y * panoramaFrameStrideElements;
2126  uint8_t* panoramaMaskRow = panoramaMask + y * panoramaMaskStrideElements;
2127 
2128  for (unsigned int x = 0u; x < lookupTable->sizeX(); ++x)
2129  {
2130  const Vector2 cameraPosition(lookupTable->bilinearValue(Scalar(x), Scalar(y)));
2131 
2132  AdvancedFrameInterpolatorBilinear::interpolatePixelWithMask8BitPerChannel<tChannels, PC_TOP_LEFT>(cameraFrame, cameraMask, cameraFrameWidth, cameraFrameHeight, cameraFramePaddingElements, cameraMaskPaddingElements, cameraPosition, panoramaFrameRow, panoramaMaskRow[x], maskValue);
2133 
2134  panoramaFrameRow += tChannels;
2135  }
2136  }
2137 }
2138 
2139 }
2140 
2141 }
2142 
2143 }
2144 
2145 #endif // META_OCEAN_TRACKING_OFFLINE_PANORAMA_FRAME_H
This class implements a panorama frame with spherical projection model.
Definition: PanoramaFrame.h:47
virtual void clear()
Clears the panorama frame and allows to set a new first camera frame.
UpdateMode updateMode() const
Returns the update mode of this panorama frame.
Definition: PanoramaFrame.h:1154
static void cameraFrame2panoramaFrame8BitPerChannelSubset(const PinholeCamera *pinholeCamera, const uint8_t *cameraFrame, const unsigned int cameraFramePaddingElements, const SquareMatrix3 *orientation, const unsigned int panoramaDimensionWidth, const unsigned int panoramaDimensionHeight, const int panoramaFrameTopLeftX, const int panoramaFrameTopLeftY, uint8_t *panoramaFrame, uint8_t *panoramaMask, const unsigned int panoramaFrameWidth, const unsigned int panoramaFrameHeight, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const uint8_t maskValue, const LookupTable *fineAdjustment, const unsigned int firstPanoramaRow, const unsigned int numberPanoramaRows)
Copies (interpolates) the entire area of an 8 bit per data channel camera frame with specified camera...
Definition: PanoramaFrame.h:1952
PanoramaFrame(const Frame &frame, const Frame &mask, const uint8_t maskValue, const UpdateMode updateMode, Worker *worker=nullptr)
Creates a new panorama frame instance by an already existing (entire) panorama frame.
static Scalar approximateIntersectionArea(const PinholeCamera &pinholeCamera0, const SquareMatrix3 &orientation0, const PinholeCamera &pinholeCamera1, const SquareMatrix3 &orientation1, Scalar *intersectionRatio=nullptr)
Approximate the area of the intersection of two frames.
PixelPosition frameTopLeft_
The top left position of the sub-frame of the entire panorama frame.
Definition: PanoramaFrame.h:1118
static void mergeSetNew8BitPerChannelSubset(const uint8_t *panoramaSubFrame, const uint8_t *panoramaSubMask, const unsigned int subFrameWidth, const unsigned int panoramaSubFramePaddingElements, const unsigned int panoramaSubMaskPaddingElements, const unsigned int subTopLeftX, const unsigned int subTopLeftY, uint8_t *panoramaFrame, uint8_t *panoramaMask, const unsigned int panoramaWidth, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const unsigned int panoramaTopLeftX, const unsigned int panoramaTopLeftY, const uint8_t maskValue, const unsigned int firstSubRow, const unsigned int numberSubRows)
Merges a subset of a given panorama sub frame with the already existing panorama frame by setting onl...
Scalar invertedDimensionHeight_
The inverse of the maximal height of the panorama frame, panoramaInvDimensionHeight = (1 / panoramaDi...
Definition: PanoramaFrame.h:1115
Vector2 panoramaPixel2cameraPixel(const PinholeCamera &pinholeCamera, const SquareMatrix3 &iOrientation, const Vector2 &panoramaPixel) const
Converts a given pixel position defined in the entire (maximal possible) panorama frame into the pixe...
Definition: PanoramaFrame.h:1215
bool reset(const PixelPosition &topLeft, const Frame &frame, const Frame &mask, Worker *worker=nullptr)
Resets the panorama frame of this object by one new panorama sub-frame.
static Vector3 angle2rayStrict(const Vector2 &angle)
Converts an angle in the panorama frame to a unit ray starting at the panorama frame's center.
Definition: PanoramaFrame.h:1372
static void cameraFrame2cameraFrameLookupTable(const PinholeCamera &inputCamera, const SquareMatrix3 &world_R_input, const PinholeCamera &outputCamera, const SquareMatrix3 &world_R_output, LookupTable &input_LT_output)
Creates a 2D lookup table allowing to interpolate pixel locations defined in one camera frame to pixe...
static void mergeAverageGlobal8BitPerChannelSubset(const uint8_t *panoramaSubFrame, const uint8_t *panoramaSubMask, const unsigned int subFrameWidth, const unsigned int panoramaSubFramePaddingElements, const unsigned int panoramaSubMaskPaddingElements, const unsigned int subTopLeftX, const unsigned int subTopLeftY, uint32_t *panoramaNominatorFrame, uint32_t *panoramaDenominatorFrame, uint8_t *panoramaFrame, uint8_t *panoramaMask, const unsigned int panoramaWidth, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const unsigned int panoramaTopLeftX, const unsigned int panoramaTopLeftY, const uint8_t maskValue, const unsigned int firstSubRow, const unsigned int numberSubRows)
Merges a subset of a given panorama sub frame with the already existing panorama frame by averaging t...
static Vector2 pixel2angleStrict(const Vector2 &position, const Scalar invPanoramaDimensionWidth, const Scalar invPanoramaDimensionHeight)
Converts a pixel position in the entire (maximal possible) panorama frame to the corresponding angle ...
Definition: PanoramaFrame.h:1290
static void cameraFrame2cameraFrameMaskLookup8BitPerChannelSubset(const LookupTable *lookupTable, const uint8_t *inputFrame, const uint8_t *inputMask, const unsigned int inputWidth, const unsigned int inputHeight, const unsigned int inputFramePaddingElements, const unsigned int inputMaskPaddingElements, uint8_t *outputFrame, uint8_t *outputMask, const unsigned int outputFramePaddingElements, const unsigned int outputMaskPaddingElements, const uint8_t maskValue, const unsigned int firstOutputRow, const unsigned int numberOutputRows)
Converts a subset of a given input camera frame with 8 bit per channel captured with a given orientat...
Definition: PanoramaFrame.h:1771
Box2 panoramaSubFrameBoundingBox(const PinholeCamera &pinholeCamera, const SquareMatrix3 &orientation) const
Determines the bounding box for a camera frame with given orientation in the panorama frame.
static Vector2 ray2angleStrict(const Vector3 &ray)
Converts a unit ray starting at the panorama frame's center to the corresponding angle.
Definition: PanoramaFrame.h:1344
const Frame & frame() const
Returns the current panorama sub-frame (not the maximal possible panorama frame).
Definition: PanoramaFrame.h:1139
static bool panoramaFrame2cameraFrame(const PinholeCamera &pinholeCamera, const Frame &panoramaFrame, const Frame &panoramaMask, const unsigned int panoramaDimensionWidth, const unsigned int panoramaDimensionHeight, const PixelPosition &panoramaFrameTopLeft, const SquareMatrix3 &orientation, Frame &cameraFrame, Frame &cameraMask, const uint8_t maskValue=0xFFu, const unsigned int approximationBinSize=20u, Worker *worker=nullptr, const LookupTable *fineAdjustment=nullptr)
Copies (interpolates) a section from the entire panorama frame to a camera frame with specified camer...
Frame frame_
The actual panorama frame, may be a sub-frame of the entire panorama frame.
Definition: PanoramaFrame.h:1094
static void cameraFrame2panoramaFrameMaskLookup8BitPerChannelSubset(const LookupTable *lookupTable, const uint8_t *cameraFrame, const uint8_t *cameraMask, const unsigned int cameraFrameWidth, const unsigned int cameraFrameHeight, const unsigned int cameraFramePaddingElements, const unsigned int cameraMaskPaddingElements, uint8_t *panoramaFrame, uint8_t *panoramaMask, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const uint8_t maskValue, const unsigned int firstPanoramaRow, const unsigned int numberPanoramaRows)
Copies (interpolates) a subset of an 8 bit per data channel camera frame (specified by a mask) with s...
Definition: PanoramaFrame.h:2113
static void cameraFrame2panoramaFrameLookupTable(const PinholeCamera &pinholeCamera, const SquareMatrix3 &orientation, const unsigned int panoramaDimensionWidth, const unsigned int panoramaDimensionHeight, const PixelPositionI &panoramaFrameTopLeft, LookupTable &lookupTable, const LookupTable *fineAdjustment)
Creates a 2D lookup table allowing to interpolate positions defined in the entire panorama frame to p...
virtual ~PanoramaFrame()=default
Default destructor.
static Vector2 angle2pixelStrict(const Vector2 &angle, const unsigned int panoramaDimensionWidth, const unsigned int panoramaDimensionHeight)
Converts an angle in the entire (maximal possible) panorama frame to the corresponding pixel position...
Definition: PanoramaFrame.h:1265
Vector2 cameraPixel2panoramaPixel(const PinholeCamera &pinholeCamera, const SquareMatrix3 &orientation, const Vector2 &cameraPixel, const Vector2 &referenceAngle) const
Converts a given pixel position defined in the current camera frame into the pixel position defined i...
Definition: PanoramaFrame.h:1185
uint8_t maskValue_
The mask value defining the mask value of valid pixels.
Definition: PanoramaFrame.h:1121
static Vectors2 generateFrameContour(const unsigned int width, const unsigned int height, const unsigned int count)
Creates are contour of (the outside of) a camera frame.
unsigned int dimensionWidth_
The maximal width of the panorama frame representing horizontal 360 degrees, in pixel.
Definition: PanoramaFrame.h:1106
static void cameraFrame2panoramaFrameLookup8BitPerChannelSubset(const LookupTable *lookupTable, const uint8_t *cameraFrame, const unsigned int cameraFrameWidth, const unsigned int cameraFrameHeight, const unsigned int cameraFramePaddingElements, uint8_t *panoramaFrame, uint8_t *panoramaMask, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const uint8_t maskValue, const unsigned int firstPanoramaRow, const unsigned int numberPanoramaRows)
Copies (interpolates) the entire area of an 8 bit per data channel camera frame with specified camera...
Definition: PanoramaFrame.h:2024
static void panoramaFrame2cameraFrame8BitPerChannelSubset(const PinholeCamera *pinholeCamera, const uint8_t *panoramaFrame, const uint8_t *panoramaMask, const unsigned int panoramaFrameWidth, const unsigned int panoramaFrameHeight, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const unsigned int panoramaDimensionWidth, const unsigned int panoramaDimensionHeight, const unsigned int panoramaFrameTopLeftX, const unsigned int panoramaFrameTopLeftY, const SquareMatrix3 *orientation, uint8_t *cameraFrame, uint8_t *cameraMask, const unsigned int cameraFramePaddingElements, const unsigned int cameraMaskPaddingElements, const uint8_t maskValue, const LookupTable *fineAdjustment, const unsigned int firstCameraRow, const unsigned int numberCameraRows)
Copies (interpolates) a subset of a section from the entire panorama frame with 8 bit per data channe...
Definition: PanoramaFrame.h:1802
static void mergeAverageGlobal8BitPerChannel(const uint8_t *panoramaSubFrame, const uint8_t *panoramaSubMask, const unsigned int subFrameWidth, const unsigned int subFrameHeight, const unsigned int panoramaSubFramePaddingElements, const unsigned panoramaSubMaskPaddingElements, const PixelPosition &subTopLeft, uint32_t *panoramaNominatorFrame, uint32_t *panoramaDenominatorFrame, uint8_t *panoramaFrame, uint8_t *panoramaMask, const unsigned int panoramaWidth, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const PixelPosition &panoramaTopLeft, const uint8_t maskValue, Worker *worker=nullptr)
Merges a given panorama sub frame with the already existing panorama frame by averaging the all pixel...
static bool haveIntersectionByRays(const PinholeCamera &pinholeCamera0, const SquareMatrix3 &orientation0, const PinholeCamera &pinholeCamera1, const SquareMatrix3 &orientation1, const Scalar borderFactor=Scalar(0.1), const unsigned int minimalIntersections=2u)
Checks whether two camera frames have a guaranteed intersection.
Frame nominatorFrame_
The optional nominator frame of the panorama frame, necessary if UM_AVERAGE_GLOBAL is set as update m...
Definition: PanoramaFrame.h:1100
bool reset(const PinholeCamera &pinholeCamera, const Frame &frame, const SquareMatrix3 &orientation, const unsigned int approximationBinSize=20u, Worker *worker=nullptr)
Resets the panorama frame of this object by one new single camera frame.
static bool cameraFrame2panoramaFrame(const PinholeCamera &pinholeCamera, const Frame &cameraFrame, const SquareMatrix3 &orientation, const unsigned int panoramaDimensionWidth, const unsigned int panoramaDimensionHeight, const PixelPositionI &panoramaFrameTopLeft, Frame &panoramaFrame, Frame &panoramaMask, const uint8_t maskValue=0xFFu, const unsigned int approximationBinSize=20u, Worker *worker=nullptr, const LookupTable *fineAdjustment=nullptr)
Copies (interpolates) the entire area of a camera frame with specified camera orientation to a sectio...
static void panoramaFrame2cameraFrameLookupTable(const PinholeCamera &pinholeCamera, const SquareMatrix3 &orientation, const unsigned int panoramaDimensionWidth, const unsigned int panoramaDimensionHeight, const PixelPosition &panoramaFrameTopLeft, LookupTable &lookupTable, const LookupTable *fineAdjustment)
Creates a 2D lookup table allowing to interpolate positions defined in the camera frame to positions ...
UpdateMode updateMode_
The update mode of this panorama frame.
Definition: PanoramaFrame.h:1124
static bool cameraFrame2panoramaFrame(const PinholeCamera &pinholeCamera, const Frame &cameraFrame, const Frame &cameraMask, const SquareMatrix3 &orientation, const unsigned int panoramaDimensionWidth, const unsigned int panoramaDimensionHeight, const PixelPositionI &panoramaFrameTopLeft, Frame &panoramaFrame, Frame &panoramaMask, const uint8_t maskValue=0xFFu, const unsigned int approximationBinSize=20u, Worker *worker=nullptr, const LookupTable *fineAdjustment=nullptr)
Copies (interpolates) the a subset of a camera frame (specified by a mask) with specified camera orie...
bool addFrame(const PinholeCamera &pinholeCamera, const SquareMatrix3 &orientation, const Frame &frame, const Frame &mask, const unsigned int approximationBinSize=20u, Worker *worker=nullptr)
Adds a new camera frame to the panorama frame for which the orientation is known.
static Vector2 cameraPixel2cameraPixel(const PinholeCamera &inputCamera, const SquareMatrix3 &inputOrientation, const Vector2 &inputPosition, const PinholeCamera &outputCamera, const SquareMatrix3 &outputOrientation)
Converts a camera pixel position defined in one frame into a camera pixel position defined in another...
static void mergeAverageLocal8BitPerChannel(const uint8_t *panoramaSubFrame, const uint8_t *panoramaSubMask, const unsigned int subFrameWidth, const unsigned int subFrameHeight, const unsigned int panoramaSubFramePaddingElements, const unsigned panoramaSubMaskPaddingElements, const PixelPosition &subTopLeft, uint8_t *panoramaFrame, uint8_t *panoramaMask, const unsigned int panoramaWidth, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const PixelPosition &panoramaTopLeft, const uint8_t maskValue, Worker *worker=nullptr)
Merges a given panorama sub frame with the already existing panorama frame by averaging the current p...
Definition: PanoramaFrame.h:1609
uint8_t maskValue() const
Returns the mask value defining the 8 bit pixel value of valid pixels.
Definition: PanoramaFrame.h:1149
LookupCorner2< Vector2 > LookupTable
Definition of a lookup table for 2D vectors.
Definition: PanoramaFrame.h:72
void resize(const PixelPosition &topLeft, const unsigned int width, const unsigned int height)
Resizes the internal panorama sub-frame.
unsigned int dimensionHeight_
The maximal height of the panorama frame representing vertical 180 degrees, in pixel.
Definition: PanoramaFrame.h:1109
PanoramaFrame(Frame &&frame, Frame &&mask, const uint8_t maskValue, const UpdateMode updateMode, Worker *worker=nullptr)
Creates a new panorama frame instance by an already existing (entire) panorama frame.
static void cameraFrame2panoramaFrameMask8BitPerChannel(const PinholeCamera &pinholeCamera, const uint8_t *cameraFrame, const uint8_t *cameraMask, const unsigned int cameraFramePaddingElements, const unsigned int cameraMaskPaddingElements, const SquareMatrix3 &orientation, const unsigned int panoramaDimensionWidth, const unsigned int panoramaDimensionHeight, const PixelPositionI &panoramaFrameTopLeft, uint8_t *panoramaFrame, uint8_t *panoramaMask, const unsigned int panoramaFrameWidth, const unsigned int panoramaFrameHeight, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const uint8_t maskValue=0xFFu, const unsigned int approximationBinSize=20u, Worker *worker=nullptr, const LookupTable *fineAdjustment=nullptr)
Copies (interpolates) a subset of an 8 bit per data channel camera frame (specified by a mask) with s...
Definition: PanoramaFrame.h:1536
static void cameraFrame2panoramaFrame8BitPerChannel(const PinholeCamera &pinholeCamera, const uint8_t *cameraFrame, const unsigned int cameraFramePaddingElements, const SquareMatrix3 &orientation, const unsigned int panoramaDimensionWidth, const unsigned int panoramaDimensionHeight, const PixelPositionI &panoramaFrameTopLeft, uint8_t *panoramaFrame, uint8_t *panoramaMask, const unsigned int panoramaFrameWidth, const unsigned int panoramaFrameHeight, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const uint8_t maskValue=0xFFu, const unsigned int approximationBinSize=20u, Worker *worker=nullptr, const LookupTable *fineAdjustment=nullptr)
Copies (interpolates) the entire area of an 8 bit per data channel camera frame with specified camera...
Definition: PanoramaFrame.h:1494
unsigned int dimensionHeight() const
Returns the maximal possible height of the entire panorama frame representing vertical 180 degrees,...
Definition: PanoramaFrame.h:1169
static void cameraFrame2cameraFrame8BitPerChannelSubset(const PinholeCamera *inputCamera, const SquareMatrix3 *inputOrientation, const uint8_t *inputFrame, const unsigned int inputFramePaddingElements, const PinholeCamera *outputCamera, const SquareMatrix3 *outputOrientation, uint8_t *outputFrame, uint8_t *outputMask, const unsigned int outputFramePaddingElements, const unsigned int outputMaskPaddingElements, const uint8_t maskValue, const unsigned int firstOutputRow, const unsigned int numberOutputRows)
Converts a subset of a given input camera frame with 8 bit per channel captured with a given orientat...
Definition: PanoramaFrame.h:1639
Vector2 pixel2angle(const Vector2 &position) const
Converts the pixel position in the entire (maximal possible) panorama frame to the corresponding angl...
Definition: PanoramaFrame.h:1246
static void panoramaFrame2cameraFrame8BitPerChannel(const PinholeCamera &pinholeCamera, const uint8_t *panoramaFrame, const uint8_t *panoramaMask, const unsigned int panoramaFrameWidth, const unsigned int panoramaFrameHeight, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const unsigned int panoramaDimensionWidth, const unsigned int panoramaDimensionHeight, const PixelPosition &panoramaFrameTopLeft, const SquareMatrix3 &orientation, uint8_t *cameraFrame, uint8_t *cameraMask, const unsigned int cameraFramePaddingElements, const unsigned int cameraMaskPaddingElements, const uint8_t maskValue=0xFFu, const unsigned int approximationBinSize=20u, Worker *worker=nullptr, const LookupTable *fineAdjustment=nullptr)
Copies (interpolates) a section from the entire panorama frame with 8 bit per data channel to a camer...
Definition: PanoramaFrame.h:1454
const PixelPosition & frameTopLeft() const
Returns the top left position of the current panorama sub-frame.
Definition: PanoramaFrame.h:1159
static Vector2 ray2angle(const Vector3 &ray, const Vector2 &referenceAngle)
Converts a unit ray starting at the panorama frame's center to the corresponding angle.
Definition: PanoramaFrame.h:1307
UpdateMode
Definition of individual frame update modes.
Definition: PanoramaFrame.h:54
@ UM_SET_NEW
Sets only pixels in the panorama frame which haven't been set before.
Definition: PanoramaFrame.h:58
@ UM_SET_ALL
Overwrites all pixels in the panorama frame.
Definition: PanoramaFrame.h:60
@ UM_INVALID
Invalid update mode.
Definition: PanoramaFrame.h:56
@ UM_AVERAGE_LOCAL
Updates all pixels in the panorama frame by averaging the current pixel value with the new pixel valu...
Definition: PanoramaFrame.h:62
const Frame & mask() const
Returns the mask of the current panorama frame.
Definition: PanoramaFrame.h:1144
static void mergeSetAll8BitPerChannelSubset(const uint8_t *panoramaSubFrame, const uint8_t *panoramaSubMask, const unsigned int subFrameWidth, const unsigned int panoramaSubFramePaddingElements, const unsigned int panoramaSubMaskPaddingElements, const unsigned int subTopLeftX, const unsigned int subTopLeftY, uint8_t *panoramaFrame, uint8_t *panoramaMask, const unsigned int panoramaWidth, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const unsigned int panoramaTopLeftX, const unsigned int panoramaTopLeftY, const uint8_t maskValue, const unsigned int firstSubRow, const unsigned int numberSubRows)
Merges a subset of a given panorama sub frame with the already existing panorama frame by setting all...
Frame mask_
The mask of the panorama frame defining valid and invalid pixels.
Definition: PanoramaFrame.h:1097
Vector2 cameraPixel2panoramaPixelStrict(const PinholeCamera &pinholeCamera, const SquareMatrix3 &orientation, const Vector2 &cameraPixel) const
Converts a given pixel position defined in the current camera frame into the pixel position defined i...
Definition: PanoramaFrame.h:1200
static bool haveIntersectionByInnerFov(const PinholeCamera &pinholeCamera0, const SquareMatrix3 &orientation0, const PinholeCamera &pinholeCamera1, const SquareMatrix3 &orientation1, Scalar *overlappingPercent=nullptr)
Checks whether two camera frames have a guaranteed intersection.
Scalar invertedDimensionWidth_
The inverse of the maximal width of the panorama frame, panoramaInvDimensionWidth = (1 / panoramaDime...
Definition: PanoramaFrame.h:1112
static void mergeAverageLocal8BitPerChannelSubset(const uint8_t *panoramaSubFrame, const uint8_t *panoramaSubMask, const unsigned int subFrameWidth, const unsigned int panoramaSubFramePaddingElements, const unsigned int panoramaSubMaskPaddingElements, const unsigned int subTopLeftX, const unsigned int subTopLeftY, uint8_t *panoramaFrame, uint8_t *panoramaMask, const unsigned int panoramaWidth, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const unsigned int panoramaTopLeftX, const unsigned int panoramaTopLeftY, const uint8_t maskValue, const unsigned int firstSubRow, const unsigned int numberSubRows)
Merges a subset of a given panorama sub frame with the already existing panorama frame by averaging t...
static bool cameraFrame2cameraFrame(const PinholeCamera &inputCamera, const SquareMatrix3 &inputOrientation, const Frame &inputFrame, const Frame &inputMask, const PinholeCamera &outputCamera, const SquareMatrix3 &outputOrientation, Frame &outputFrame, Frame &outputMask, const uint8_t maskValue, const unsigned int approximationBinSize, Worker *worker)
Converts a given input camera frame captured with a given orientation into a corresponding camera fra...
static void panoramaFrame2cameraFrameLookup8BitPerChannelSubset(const LookupTable *lookupTable, const uint8_t *panoramaFrame, const uint8_t *panoramaMask, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const unsigned int panoramaDimensionWidth, const unsigned int panoramaDimensionHeight, const unsigned int panoramaFrameTopLeftX, const unsigned int panoramaFrameTopLeftY, const unsigned int panoramaFrameWidth, const unsigned int panoramaFrameHeight, uint8_t *cameraFrame, uint8_t *cameraMask, const unsigned int cameraFramePaddingElements, const unsigned int cameraMaskPaddingElements, const uint8_t maskValue, const unsigned int firstCameraRow, const unsigned int numberCameraRows)
Copies (interpolates) a subset of a section from the entire panorama frame with 8 bit per data channe...
Definition: PanoramaFrame.h:1846
bool extractFrame(const PinholeCamera &pinholeCamera, const SquareMatrix3 &orientation, Frame &frame, Frame &mask, const unsigned int approximationBinSize=20u, Worker *worker=nullptr, const LookupTable *fineAdjustment=nullptr) const
Extracts a camera frame from the panorama frame.
Definition: PanoramaFrame.h:1174
static Vector3 angle2ray(const Vector2 &angle)
Converts an angle in the panorama frame to a unit ray starting at the panorama frame's center.
Definition: PanoramaFrame.h:1362
unsigned int dimensionWidth() const
Returns the maximal possible width of the entire panorama frame representing horizontal 360 degrees,...
Definition: PanoramaFrame.h:1164
Frame denominatorFrame_
The optional denominator frame of the panorama frame, necessary if UM_AVERAGE_GLOBAL is set as update...
Definition: PanoramaFrame.h:1103
PanoramaFrame()=default
Creates an invalid panorama frame instance.
static void cameraFrame2cameraFrameLookup8BitPerChannelSubset(const LookupTable *lookupTable, const uint8_t *inputFrame, const unsigned int inputWidth, const unsigned int inputHeight, const unsigned int inputFramePaddingElements, uint8_t *outputFrame, uint8_t *outputMask, const unsigned int outputFramePaddingElements, const unsigned int outputMaskPaddingElements, const uint8_t maskValue, const unsigned int firstOutputRow, const unsigned int numberOutputRows)
Converts a subset of a given input camera frame with 8 bit per channel captured with a given orientat...
Definition: PanoramaFrame.h:1690
bool isValid() const
Returns whether this panorama frame holds valid configuration parameters and thus can be used.
Definition: PanoramaFrame.h:1231
bool update(const PinholeCamera &pinholeCamera, const Frame &frame, const Frame &mask, const SquareMatrix3 &orientation, const unsigned int approximationBinSize=20u, Worker *worker=nullptr, const LookupTable *fineAdjustment=nullptr)
Updates the panorama frame data with a new camera frame.
static void mergeSetAll8BitPerChannel(const uint8_t *panoramaSubFrame, const uint8_t *panoramaSubMask, const unsigned int subFrameWidth, const unsigned int subFrameHeight, const unsigned int panoramaSubFramePaddingElements, const unsigned panoramaSubMaskPaddingElements, const PixelPosition &subTopLeft, uint8_t *panoramaFrame, uint8_t *panoramaMask, const unsigned int panoramaWidth, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const PixelPosition &panoramaTopLeft, const uint8_t maskValue, Worker *worker=nullptr)
Merges a given panorama sub frame with the already existing panorama frame by setting all valid pixel...
Definition: PanoramaFrame.h:1579
static void mergeSetNew8BitPerChannel(const uint8_t *panoramaSubFrame, const uint8_t *panoramaSubMask, const unsigned int subFrameWidth, const unsigned int subFrameHeight, const unsigned int panoramaSubFramePaddingElements, const unsigned panoramaSubMaskPaddingElements, const PixelPosition &subTopLeft, uint8_t *panoramaFrame, uint8_t *panoramaMask, const unsigned int panoramaWidth, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const PixelPosition &panoramaTopLeft, const uint8_t maskValue, Worker *worker=nullptr)
Merges a given panorama sub frame with the already existing panorama frame by setting only pixels whi...
Definition: PanoramaFrame.h:1594
static void cameraFrame2cameraFrameMask8BitPerChannelSubset(const PinholeCamera *inputCamera, const SquareMatrix3 *inputOrientation, const uint8_t *inputFrame, const uint8_t *inputMask, const unsigned int inputFramePaddingElements, const unsigned int inputMaskPaddingElements, const PinholeCamera *outputCamera, const SquareMatrix3 *outputOrientation, uint8_t *outputFrame, uint8_t *outputMask, const unsigned int outputFramePaddingElements, const unsigned int outputMaskPaddingElements, const uint8_t maskValue, const unsigned int firstOutputRow, const unsigned int numberOutputRows)
Converts a subset of a given input camera frame with 8 bit per channel captured with a given orientat...
Definition: PanoramaFrame.h:1730
bool cameraFrame2panoramaSubFrame(const PinholeCamera &pinholeCamera, const Frame &frame, const Frame &mask, const SquareMatrix3 &orientation, Frame &panoramaSubFrame, Frame &panoramaSubMask, PixelPositionI &subFrameTopLeft, const unsigned int approximationBinSize=20u, Worker *worker=nullptr, const LookupTable *fineAdjustment=nullptr)
Copies (interpolates) the entire area of a camera frame with specified camera orientation to a sub-fr...
bool setFrame(const PixelPosition &topLeft, const Frame &frame, const Frame &mask=Frame(), Worker *worker=nullptr)
Sets or resets the panorama sub-frame (not the maximal possible panorama frame).
bool merge(const Frame &panoramaSubFrame, const Frame &panoramaSubMask, const PixelPosition &subTopLeft, Worker *worker=nullptr)
Merges a given panorama sub-frame with given top left start position with the panorama frame of this ...
Vector2 angle2pixel(const Vector2 &angle) const
Converts an angle in the entire (maximal possible) panorama frame to the corresponding pixel position...
Definition: PanoramaFrame.h:1241
static void cameraFrame2panoramaFrameMask8BitPerChannelSubset(const PinholeCamera *pinholeCamera, const uint8_t *cameraFrame, const uint8_t *cameraMask, const unsigned int cameraFramePaddingElements, const unsigned int cameraMaskPaddingElements, const SquareMatrix3 *orientation, const unsigned int panoramaDimensionWidth, const unsigned int panoramaDimensionHeight, const int panoramaFrameTopLeftX, const int panoramaFrameTopLeftY, uint8_t *panoramaFrame, uint8_t *panoramaMask, const unsigned int panoramaFrameWidth, const unsigned int panoramaFrameHeight, const unsigned int panoramaFramePaddingElements, const unsigned int panoramaMaskPaddingElements, const uint8_t maskValue, const LookupTable *fineAdjustment, const unsigned int firstPanoramaRow, const unsigned int numberPanoramaRows)
Copies (interpolates) a subset of an 8 bit per data channel camera frame (specified by a mask) with s...
Definition: PanoramaFrame.h:2061
static void cameraFrame2cameraFrame8BitPerChannel(const PinholeCamera &inputCamera, const SquareMatrix3 &inputOrientation, const uint8_t *inputFrame, const uint8_t *inputMask, const unsigned int inputFramePaddingElements, const unsigned int inputMaskPaddingElements, const PinholeCamera &outputCamera, const SquareMatrix3 &outputOrientation, uint8_t *outputFrame, uint8_t *outputMask, const unsigned int outputFramePaddingElements, const unsigned int outputMaskPaddingElements, const uint8_t maskValue, const unsigned int approximationBinSize, Worker *worker)
Converts a given input camera frame with 8 bit per channel captured with a given orientation into a c...
Definition: PanoramaFrame.h:1386
T y() const
Returns the vertical coordinate position of this object.
Definition: PixelPosition.h:470
T x() const
Returns the horizontal coordinate position of this object.
Definition: PixelPosition.h:458
static Caller< void > createStatic(typename StaticFunctionPointerMaker< void, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass >::Type function)
Creates a new caller container for a static function with no function parameter.
Definition: Caller.h:2876
static SquareMatrixT3< U > flipMatrix3()
Returns the 3x3 transformation matrix flipping a transformation around the x-axis by 180 deg.
Definition: Camera.h:497
This class implements Ocean's image class.
Definition: Frame.h:1792
bool isValid() const
Returns whether this frame is valid.
Definition: Frame.h:4448
size_t sizeY() const
Returns the vertical dimension of this lookup object.
Definition: Lookup2.h:947
size_t sizeX() const
Returns the horizontal dimension of this lookup object.
Definition: Lookup2.h:941
bool isEmpty() const
Returns whether this lookup object does not hold any lookup bin.
Definition: Lookup2.h:1009
This class implements a 2D lookup object with values at the bins' corners defining the individual loo...
Definition: Lookup2.h:636
T clampedBilinearValue(const TScalar x, const TScalar y) const
Applies a lookup for a specific position in this lookup object while the position is clamped to match...
Definition: Lookup2.h:2112
T bilinearValue(const TScalar x, const TScalar y) const
Applies a lookup for a specific position in this lookup object.
Definition: Lookup2.h:1815
static constexpr T pi2()
Returns 2*PI which is equivalent to 360 degree.
Definition: Numeric.h:932
static constexpr T pi_2()
Returns PI/2 which is equivalent to 90 degree.
Definition: Numeric.h:938
static T atan2(const T y, const T x)
Returns the arctangent of a given value in radian.
Definition: Numeric.h:1632
static T sin(const T value)
Returns the sine of a given value.
Definition: Numeric.h:1568
static T abs(const T value)
Returns the absolute value of a given value.
Definition: Numeric.h:1220
static constexpr T pi()
Returns PI which is equivalent to 180 degree.
Definition: Numeric.h:926
static bool isEqual(const T first, const T second)
Returns whether two values are equal up to a small epsilon.
Definition: Numeric.h:2386
static constexpr bool isEqualEps(const T value)
Returns whether a value is smaller than or equal to a small epsilon.
Definition: Numeric.h:2087
static T cos(const T value)
Returns the cosine of a given value.
Definition: Numeric.h:1584
static T asin(const T value)
Returns the arcsine of a given value.
Definition: Numeric.h:2887
unsigned int width() const
Returns the width of the camera image.
Definition: PinholeCamera.h:1300
T principalPointX() const
Returns the x-value of the principal point of the camera image in the pixel domain.
Definition: PinholeCamera.h:1318
const SquareMatrixT3< T > & invertedIntrinsic() const
Returns the inverted intrinsic camera matrix.
Definition: PinholeCamera.h:1263
VectorT2< T > distort(const VectorT2< T > &undistorted) const
Returns the distorted position of a given undistorted position defined in pixel coordinates.
Definition: PinholeCamera.h:1418
VectorT2< T > undistort(const VectorT2< T > &distorted, const unsigned int iterations=10u, const T zoom=T(1)) const
Returns the undistorted position of a given distorted position defined in pixel coordinates.
Definition: PinholeCamera.h:1373
bool isValid() const
Returns whether this camera is valid.
Definition: PinholeCamera.h:1572
const SquareMatrixT3< T > & intrinsic() const
Returns the intrinsic camera matrix.
Definition: PinholeCamera.h:1257
unsigned int height() const
Returns the height of the camera image.
Definition: PinholeCamera.h:1306
VectorT2< T > normalizedImagePoint2imagePoint(const VectorT2< T > &normalizedImagePoint, const bool distortImagePoint) const
Calculates the image point corresponding to a given normalized image point.
Definition: PinholeCamera.h:1602
T principalPointY() const
Returns the y-value of the principal point of the camera image in the pixel domain.
Definition: PinholeCamera.h:1324
VectorT3< T > vector(const VectorT2< T > &position, const bool makeUnitVector=true) const
Returns a normalized vector (with length 1) starting at the camera's center and intersecting a given ...
Definition: PinholeCamera.h:2171
SquareMatrixT3< T > inverted() const
Returns the inverted matrix of this matrix.
Definition: SquareMatrix3.h:1176
bool isSingular() const
Returns whether this matrix is singular (and thus cannot be inverted).
Definition: SquareMatrix3.h:1341
const T & x() const noexcept
Returns the x value.
Definition: Vector2.h:698
const T & y() const noexcept
Returns the y value.
Definition: Vector2.h:710
const T & y() const noexcept
Returns the y value.
Definition: Vector3.h:812
const T & x() const noexcept
Returns the x value.
Definition: Vector3.h:800
const T & z() const noexcept
Returns the z value.
Definition: Vector3.h:824
T length() const
Returns the length of the vector.
Definition: Vector3.h:664
This class implements a worker able to distribute function calls over different threads.
Definition: Worker.h:33
bool executeFunction(const Function &function, const unsigned int first, const unsigned int size, const unsigned int firstIndex=(unsigned int)(-1), const unsigned int sizeIndex=(unsigned int)(-1), const unsigned int minimalIterations=1u, const unsigned int threadIndex=(unsigned int)(-1))
Executes a callback function separable by two function parameters.
PixelPositionT< unsigned int > PixelPosition
Definition of the default PixelPosition object with a data type allowing only positive coordinate val...
Definition: PixelPosition.h:27
float Scalar
Definition of a scalar type.
Definition: Math.h:128
std::vector< Vector2 > Vectors2
Definition of a vector holding Vector2 objects.
Definition: Vector2.h:64
VectorT2< Scalar > Vector2
Definition of a 2D vector.
Definition: Vector2.h:21
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15