NDEVR
API Documentation
DepthAIPointSmoother.h
1#pragma once
2#include "RasterPointScanner/Headers/ViewportPointSmoother.hpp"
3#include "RasterPointScanner/Headers/RasterFrame.h"
4#include "Base/Headers/Matrix.hpp"
5namespace NDEVR
6{
11 class DepthAISmoother : public ViewportPointSmoother<ColorNormalNode>
12 {
13 public:
17 DepthAISmoother(const Vector<2, uint04>& size, const Matrix<fltp04>& intrinsics)
18 : m_intrinics(intrinsics)
19 , m_original_size(size)
20 {
21 m_view_size_i = size;
22 m_view_size_f = m_view_size_i.as<2, fltp04>();
23 m_inv_fov[X] = 1.0 / m_intrinics[0][0];
24 m_inv_fov[Y] = 1.0 / m_intrinics[1][1];
25 }
26
30 {
32 fltp04 cx = m_intrinics[0][2];
33 fltp04 cy = m_intrinics[1][2];
34 pixel[X] = (pixel[X] - cx) * pixel[Z] * m_inv_fov[X];
35 pixel[Y] = (pixel[Y] - cy) * pixel[Z] * m_inv_fov[Y];
36 return pixel;
37 }
38
41 Vertex<2, fltp04> pointToPixel(Vertex<3, fltp04> location) const final override
42 {
43 fltp04 fx = m_intrinics[0][0];
44 fltp04 fy = m_intrinics[1][1];
45 fltp04 cx = m_intrinics[0][2];
46 fltp04 cy = m_intrinics[1][2];
47 location[X] = (location[X] / location[Z] * fx) + cx;
48 location[Y] = (location[Y] / location[Z] * fy) + cy;
49 return m_pixel_multiplier * location.as<2, fltp04>();
50 }
51
53 void setViewSize(const Vector<2, uint04>& view_size) final override
54 {
55 ViewportPointSmoother::setViewSize(view_size);
56 m_pixel_multiplier = m_view_size_f[X] / cast<fltp04>(m_original_size[X]);
58 }
59
62 {
64 smoother->setViewSize(m_view_size_i);
65 smoother->setBlockTransform(m_block_mat);
66 smoother->m_frame_reduction = m_frame_reduction;
67 return smoother;
68 }
69 protected:
75 };
76}
Vector< 2, fltp04 > m_inv_fov
Inverse focal lengths (1/fx, 1/fy).
void setViewSize(const Vector< 2, uint04 > &view_size) final override
Updates the viewport size and recalculates pixel scaling factors.
Vertex< 3, fltp04 > pixelToPoint(Vertex< 3, fltp04 > pixel) const final override
Converts a pixel coordinate with depth into a 3D point.
Vector< 2, uint04 > m_original_size
Native camera image resolution.
DepthAISmoother(const Vector< 2, uint04 > &size, const Matrix< fltp04 > &intrinsics)
Constructs the smoother with the camera's native size and intrinsic matrix.
Matrix< fltp04 > m_intrinics
Camera intrinsic matrix (fx, fy, cx, cy).
fltp04 m_pixel_multiplier
Scale factor from native to current viewport size.
DepthAISmoother * clone()
Creates a copy of this smoother with the same parameters.
fltp04 m_inv_pixel_multiplier
Inverse of the pixel multiplier.
Vertex< 2, fltp04 > pointToPixel(Vertex< 3, fltp04 > location) const final override
Projects a 3D point onto the image plane as a pixel coordinate.
Templated logic for doing matrix multiplication.
Definition Matrix.hpp:182
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
Definition Vector.hpp:62
constexpr decltype(auto) as() const
Returns the vector as a new time of vector.
Definition Vector.hpp:301
A point in N-dimensional space, used primarily for spatial location information.
Definition Vertex.hpp:44
The primary namespace for the NDEVR SDK.
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
constexpr t_to cast(const Angle< t_from > &value)
Casts an Angle from one backing type to another.
Definition Angle.h:408