27struct ApplyIntrinsicsFunction {
28 ApplyIntrinsicsFunction(
const CameraIntrinsics& intrinsics,
33 double normalized_x, normalized_y;
34 intrinsics.ImageSpaceToNormalized(x, y, &normalized_x, &normalized_y);
35 intrinsics.ApplyIntrinsics(normalized_x, normalized_y, warp_x, warp_y);
39struct InvertIntrinsicsFunction {
40 InvertIntrinsicsFunction(
const CameraIntrinsics& intrinsics,
45 double normalized_x, normalized_y;
46 intrinsics.InvertIntrinsics(x, y, &normalized_x, &normalized_y);
47 intrinsics.NormalizedToImageSpace(
48 normalized_x, normalized_y, warp_x, warp_y);
57template <
typename WarpFunction>
58void LookupWarpGrid::Compute(
const CameraIntrinsics& intrinsics,
64 double aspx = (
double)
w / intrinsics.image_width();
65 double aspy = (
double)h / intrinsics.image_height();
67# pragma omp parallel for schedule(static) \
68 num_threads(threads_) if (threads_ > 1 && height > 100)
70 for (
int y = 0; y <
height; y++) {
71 for (
int x = 0; x <
width; x++) {
72 double src_x = (x - 0.5 *
overscan *
w) / aspx,
73 src_y = (y - 0.5 *
overscan * h) / aspy;
74 double warp_x, warp_y;
75 WarpFunction(intrinsics, src_x, src_y, &warp_x, &warp_y);
76 warp_x = warp_x * aspx + 0.5 *
overscan *
w;
77 warp_y = warp_y * aspy + 0.5 *
overscan * h;
78 int ix =
int(warp_x), iy =
int(warp_y);
79 int fx =
round((warp_x - ix) * 256), fy =
round((warp_y - iy) * 256);
100 Offset offset = {(short)(ix - x),
104 offset_[y *
width +
x] = offset;
109template <
typename WarpFunction>
118 if (offset_ ==
NULL) {
129template <
typename PixelType>
134 PixelType* output_buffer) {
136# pragma omp parallel for schedule(static) \
137 num_threads(threads_) if (threads_ > 1 && height > 100)
139 for (
int y = 0; y <
height; y++) {
140 for (
int x = 0; x <
width; x++) {
141 Offset offset = offset_[y *
width +
x];
142 const int pixel_index =
143 ((y + offset.iy) *
width + (x + offset.ix)) * channels;
144 const PixelType* s = &input_buffer[pixel_index];
145 for (
int i = 0; i <
channels; i++) {
146 output_buffer[(y *
width +
x) * channels + i] =
147 ((s[i] * (256 - offset.fx) + s[channels + i] * offset.fx) *
149 (s[
width * channels + i] * (256 - offset.fx) +
150 s[
width * channels + channels + i] * offset.fx) *
160template <
typename PixelType>
166 PixelType* output_buffer) {
167 assert(channels >= 1);
168 assert(channels <= 4);
169 distort_.
Update<InvertIntrinsicsFunction>(*
this, width, height, overscan);
170 distort_.
Apply<PixelType>(
171 input_buffer, width, height,
channels, output_buffer);
174template <
typename PixelType>
180 PixelType* output_buffer) {
181 assert(channels >= 1);
182 assert(channels <= 4);
183 undistort_.
Update<ApplyIntrinsicsFunction>(*
this, width, height, overscan);
185 undistort_.
Apply<PixelType>(
186 input_buffer, width, height,
channels, output_buffer);
typedef double(DMatrix)[4][4]
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Brightness Control the brightness and contrast of the input color Vector Map input vector components with curves Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert Invert a producing a negative Combine Generate a color from its and blue channels(Deprecated)") DefNode(ShaderNode
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
void DistortBuffer(const PixelType *input_buffer, int width, int height, double overscan, int channels, PixelType *output_buffer)
void UndistortBuffer(const PixelType *input_buffer, int width, int height, double overscan, int channels, PixelType *output_buffer)
void Apply(const PixelType *input_buffer, int width, int height, int channels, PixelType *output_buffer)
void Update(const CameraIntrinsics &intrinsics, int width, int height, double overscan)
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int