33 #ifndef PANO_UNWRAP_CAMERA
34 #define PANO_UNWRAP_CAMERA bottom_camera
37 #ifndef PANO_UNWRAP_CENTER_X
38 #define PANO_UNWRAP_CENTER_X 0.50
40 #ifndef PANO_UNWRAP_CENTER_Y
41 #define PANO_UNWRAP_CENTER_Y 0.50
43 #ifndef PANO_UNWRAP_RADIUS_BOTTOM
44 #define PANO_UNWRAP_RADIUS_BOTTOM 0.20
46 #ifndef PANO_UNWRAP_RADIUS_TOP
47 #define PANO_UNWRAP_RADIUS_TOP 0.30
49 #ifndef PANO_UNWRAP_FORWARD_DIRECTION
50 #define PANO_UNWRAP_FORWARD_DIRECTION 270.0
52 #ifndef PANO_UNWRAP_FLIP_HORIZONTAL
53 #define PANO_UNWRAP_FLIP_HORIZONTAL FALSE
56 #ifndef PANO_UNWRAP_VERTICAL_RESOLUTION
57 #define PANO_UNWRAP_VERTICAL_RESOLUTION 0.18
59 #ifndef PANO_UNWRAP_DEROTATE_ATTITUDE
60 #define PANO_UNWRAP_DEROTATE_ATTITUDE FALSE
63 #ifndef PANO_UNWRAP_WIDTH
64 #define PANO_UNWRAP_WIDTH 640
66 #ifndef PANO_UNWRAP_HEIGHT
67 #define PANO_UNWRAP_HEIGHT 0
70 #ifndef PANO_UNWRAP_OVERWRITE_VIDEO_THREAD
71 #define PANO_UNWRAP_OVERWRITE_VIDEO_THREAD TRUE
74 #ifndef PANO_UNWRAP_FPS
75 #define PANO_UNWRAP_FPS 0
96 .show_calibration =
FALSE,
101 #define PIXEL_U(img,x,y) ( ((uint8_t*)((img)->buf))[4*(int)((x)/2) + 2*(y)*(img)->w] )
102 #define PIXEL_V(img,x,y) ( ((uint8_t*)((img)->buf))[4*(int)((x)/2) + 2*(y)*(img)->w + 2] )
103 #define PIXEL_Y(img,x,y) ( ((uint8_t*)((img)->buf))[2*(x) + 1 + 2*(y)*(img)->w] )
135 if (pano_unwrap.
height == 0) {
139 printf(
"[pano_unwrap] Automatic output image height: %d\n",
145 printf(
"[pano_unwrap] Creating output image with size %d x %d\n",
167 printf(
"[pano_unwrap] Regenerating LUT... ");
189 printf(
"[pano_unwrap] ERROR could not allocate x or y lookup table!\n");
195 float c = cosf(angle);
196 float s = sinf(angle);
200 * ((
float) v / (pano_unwrap.
height - 1));
202 * pano_unwrap.
center.
x + c * radius * img->
h + 0.5);
204 * pano_unwrap.
center.
y - s * radius * img->
h + 0.5);
213 "[pano_unwrap] ERROR could not allocate dphi or dtheta lookup table!\n");
219 LUT.
dphi[u].
x = sinf(bearing) * cosf(angle);
220 LUT.
dphi[u].
y = sinf(bearing) * -sinf(angle);
221 LUT.
dtheta[u].
x = cosf(bearing) * cosf(angle);
222 LUT.
dtheta[u].
y = cosf(bearing) * -sinf(angle);
254 }
else if (x > img_raw->
w - 1) {
259 }
else if (y > img_raw->
h - 1) {
264 if (v == 0 || v == pano_unwrap.
height - 1) {
268 if ((u == pano_unwrap.
width / 2)
269 || (u == pano_unwrap.
width / 2 + 1)) {
274 if ((u == 3 * pano_unwrap.
width / 4)
275 || (u == 3 * pano_unwrap.
width / 4 + 1)) {
291 for (
int i = -5; i <= 5; i++) {
292 for (
int j = -5; j <= 5; j++) {
293 if (i == 0 || j == 0) {
float radius_top
Distance from center point to top of region of interest [fraction of image height].
struct image_t pano_unwrapped_image
Unwrapped panoramic image.
float vertical_resolution
Vertical resolution of raw image in the region of interest, used for attitude derotation [fraction of...
bool show_calibration
Draw calibration pattern on raw image.
struct pano_unwrap_t pano_unwrap
void image_free(struct image_t *img)
Free the image.
#define PANO_UNWRAP_WIDTH
void image_create(struct image_t *img, uint16_t width, uint16_t height, enum image_type type)
Create a new image.
float forward_direction
Angle [deg] in raw image that corresponds to the forward direction, where 0 points right and the valu...
#define PANO_UNWRAP_FLIP_HORIZONTAL
#define PANO_UNWRAP_RADIUS_BOTTOM
struct FloatVect2 * dtheta
uint32_t pprz_ts
The timestamp in us since system startup.
bool derotate_attitude
Set to true if roll/pitch movement should be corrected.
static struct image_t * camera_cb(struct image_t *img)
#define PIXEL_U(img, x, y)
struct video_listener * cv_add_to_device(struct video_config_t *device, cv_function func, uint16_t fps)
uint16_t height
Height of unwrapped image. Set to 0 (default) to determine automatically from unwrapped_width, radius_bottom, _top and vertical_resolution.
static struct FloatRMat * stateGetNedToBodyRMat_f(void)
Get vehicle body attitude rotation matrix (float).
#define MAT33_ELMT(_m, _row, _col)
Computer vision framework for onboard processing.
#define PANO_UNWRAP_CENTER_X
#define PANO_UNWRAP_FORWARD_DIRECTION
#define PIXEL_V(img, x, y)
struct FloatVect2 center
Center point of panoramic lens [fraction of image width, height].
#define PANO_UNWRAP_OVERWRITE_VIDEO_THREAD
#define PANO_UNWRAP_DEROTATE_ATTITUDE
API to get/set the generic vehicle states.
#define PIXEL_Y(img, x, y)
#define PANO_UNWRAP_VERTICAL_RESOLUTION
static void update_LUT(const struct image_t *img)
struct timeval ts
The timestamp of creation.
#define PANO_UNWRAP_CENTER_Y
bool overwrite_video_thread
Set to true if the unwrapped image should be returned to the video thread.
#define PANO_UNWRAP_RADIUS_TOP
float radius_bottom
Distance from center point to bottom of region of interest [fraction of image height].
UYVY format (uint16 per pixel)
static void set_output_image_size(void)
bool flip_horizontal
Set to true to horizontally flip the unwrapped image.
struct pano_unwrap_t settings
#define PANO_UNWRAP_CAMERA
uint16_t width
Width of unwrapped image.
#define PANO_UNWRAP_HEIGHT
static void unwrap_LUT(struct image_t *img_raw, struct image_t *img)