Skip to content

Commit da4a8cb

Browse files
author
Thiemo Wiedemeyer
committed
small bug fix. always output 4 byte color image and alpha channel is set to zero.
1 parent 4149685 commit da4a8cb

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

examples/protonect/src/registration.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ void Registration::apply(const Frame *rgb, const Frame *depth, Frame *undistorte
9191
rgb->width != 1920 || rgb->height != 1080 || (rgb->bytes_per_pixel != 3 && rgb->bytes_per_pixel != 4) ||
9292
depth->width != 512 || depth->height != 424 || depth->bytes_per_pixel != 4 ||
9393
undistorted->width != 512 || undistorted->height != 424 || undistorted->bytes_per_pixel != 4 ||
94-
registered->width != 512 || registered->height != 424 || (registered->bytes_per_pixel != 3 && registered->bytes_per_pixel != 5))
94+
registered->width != 512 || registered->height != 424 || registered->bytes_per_pixel != 4)
9595
return;
9696

9797
const float *depth_data = (float*)depth->data;
@@ -205,8 +205,8 @@ void Registration::apply(const Frame *rgb, const Frame *depth, Frame *undistorte
205205
const float min_z = p_filter_map[c_off];
206206
const float z = *undistorted_data;
207207

208-
// check for allowed depth noise
209-
*(int*)registered_data = (z - min_z) / z > filter_tolerance ? 0 : *(int*)(rgb->data + c_off * rgb->bytes_per_pixel);
208+
// check for allowed depth noise and make sure the alpha channel is not set because it could belong to the next pixel for 3 byte images.
209+
*(unsigned int*)registered_data = (z - min_z) / z > filter_tolerance ? 0 : (*(unsigned int*)(rgb->data + c_off * rgb->bytes_per_pixel)) & 0x00FFFFFF;
210210
}
211211

212212
// delete the temporary maps
@@ -217,8 +217,8 @@ void Registration::apply(const Frame *rgb, const Frame *depth, Frame *undistorte
217217
for(int i = 0; i < size_depth; ++i, ++map_c_off, registered_data += registered->bytes_per_pixel){
218218
const int c_off = *map_c_off;
219219

220-
// check if offset is out of image
221-
*(int*)registered_data = c_off < 0 ? 0 : *(int*)(rgb->data + c_off * rgb->bytes_per_pixel);
220+
// check if offset is out of image and make sure the alpha channel is not set because it could belong to the next pixel for 3 byte images.
221+
*(unsigned int*)registered_data = c_off < 0 ? 0 : (*(unsigned int*)(rgb->data + c_off * rgb->bytes_per_pixel)) & 0x00FFFFFF;
222222
}
223223
}
224224
delete[] depth_to_c_off;

0 commit comments

Comments
 (0)