27 struct 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);
39 struct 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);
57 template <
typename WarpFunction>
58 void 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)
72 double src_x = (
x - 0.5 *
overscan *
w) / aspx,
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;
109 template <
typename WarpFunction>
118 if (offset_ ==
NULL) {
129 template <
typename PixelType>
134 PixelType* output_buffer) {
136 # pragma omp parallel for schedule(static) \
137 num_threads(threads_) if (threads_ > 1 && height > 100)
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) *
160 template <
typename PixelType>
166 PixelType* output_buffer) {
167 assert(channels >= 1);
168 assert(channels <= 4);
170 distort_.
Apply<PixelType>(
171 input_buffer,
width,
height, channels, output_buffer);
174 template <
typename PixelType>
180 PixelType* output_buffer) {
181 assert(channels >= 1);
182 assert(channels <= 4);
185 undistort_.
Apply<PixelType>(
186 input_buffer,
width,
height, channels, output_buffer);
typedef double(DMatrix)[4][4]
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
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)