14 #define UNDISTORT_FPS 0
18 #ifndef UNDISTORT_MIN_X_NORMALIZED
19 #define UNDISTORT_MIN_X_NORMALIZED -2.0f
23 #ifndef UNDISTORT_MAX_X_NORMALIZED
24 #define UNDISTORT_MAX_X_NORMALIZED 2.0f
28 #ifndef UNDISTORT_CENTER_RATIO
29 #define UNDISTORT_CENTER_RATIO 1.00f
41 static
float K[9] = {0.0f, 0.0f, 0.0f,
50 float h_w_ratio = img->
h / (
float) img->
w;
73 index_dest = pixel_width*(y*img->
w+x);
74 dest[index_dest] = 128;
75 dest[index_dest+1] = 0;
83 for(
float x_n = min_x_normalized; x_n <
max_x_normalized; x_n += normalized_step, x++) {
85 for(
float y_n = min_y_normalized; y_n < max_y_normalized; y_n += normalized_step, y++) {
90 if(x_pd > 0.0f && y_pd > 0.0f) {
93 if(x_pd_ind < img->
w && y_pd_ind < img->
h) {
95 index_dest = pixel_width*(y*img->
w+x);
96 index_src = pixel_width*(y_pd_ind*img_distorted.
w+x_pd_ind);
97 dest[index_dest] = 128;
98 dest[index_dest+1] = source[index_src+1];
float focal_x
focal length in the x-direction in pixels
#define UNDISTORT_MIN_X_NORMALIZED
Minimal normalized coordinate that will be shown in the undistorted image.
void image_free(struct image_t *img)
Free the image.
#define UNDISTORT_FPS
Default FPS (zero means run at camera fps)
void image_create(struct image_t *img, uint16_t width, uint16_t height, enum image_type type)
Create a new image.
void undistort_image_init(void)
void image_copy(struct image_t *input, struct image_t *output)
Copy an image from inut to output This will only work if the formats are the same.
struct video_listener * cv_add_to_device(struct video_config_t *device, cv_function func, uint16_t fps)
static struct image_t * undistort_image_func(struct image_t *img)
Image helper functions like resizing, color filter, converters...
struct video_listener * listener
bool normalized_coords_to_distorted_pixels(float x_n, float y_n, float *x_pd, float *y_pd, float k, const float *K)
Transform normalized coordinates to distorted pixel coordinates.
void * buf
Image buffer (depending on the image_type)
float Dhane_k
(un)distortion parameter for a fish-eye lens
Functions for undistorting camera images.
static void h(const real32_T x[7], const real32_T q[4], real32_T y[6])
float focal_y
focal length in the y-direction in pixels
float center_y
center image coordinate in the y-direction
#define UNDISTORT_MAX_X_NORMALIZED
Maximal normalized coordinate that will be shown in the undistorted image.
UYVY format (uint16 per pixel)
#define UNDISTORT_CENTER_RATIO
Maximal normalized coordinate that will be shown in the undistorted image.
struct camera_intrinsics_t camera_intrinsics
enum image_type type
The image type.
float center_x
center image coordinate in the x-direction