From d3d347703d092150985d045d3c472fa39060f938 Mon Sep 17 00:00:00 2001 From: Thiemo Wiedemeyer Date: Wed, 10 Jun 2015 16:04:29 +0200 Subject: [PATCH 1/6] implemented filtering of shadowed regions. --- .../include/libfreenect2/registration.h | 4 + examples/protonect/src/registration.cpp | 99 +++++++++++++++---- 2 files changed, 85 insertions(+), 18 deletions(-) diff --git a/examples/protonect/include/libfreenect2/registration.h b/examples/protonect/include/libfreenect2/registration.h index 7f3d1bdf4..f6170fd53 100644 --- a/examples/protonect/include/libfreenect2/registration.h +++ b/examples/protonect/include/libfreenect2/registration.h @@ -57,6 +57,10 @@ class LIBFREENECT2_API Registration float depth_to_color_map_x[512 * 424]; float depth_to_color_map_y[512 * 424]; int depth_to_color_map_yi[512 * 424]; + + const int filter_width_half; + const int filter_height_half; + const float filter_tolerance; }; } /* namespace libfreenect2 */ diff --git a/examples/protonect/src/registration.cpp b/examples/protonect/src/registration.cpp index e09cec45e..a7b3d2d5d 100644 --- a/examples/protonect/src/registration.cpp +++ b/examples/protonect/src/registration.cpp @@ -100,48 +100,107 @@ void Registration::apply(const Frame *rgb, const Frame *depth, Frame *undistorte const int *map_dist = distort_map; const float *map_x = depth_to_color_map_x; const int *map_yi = depth_to_color_map_yi; + const int size_depth = 512 * 424; - const int size_color = 1920 * 1080 * 3; + const int size_color = 1920 * 1080; const float color_cx = color.cx + 0.5f; // 0.5f added for later rounding + // size of filter map with a border of filter_height_half on top and bottom so that no check for borders is needed. + // since the color image is wide angle no border to the sides is needed. + const int size_filter_map = size_color + 1920 * filter_height_half * 2; + // offset to the important data + const int offset_filter_map = 1920 * filter_height_half; + + // map for storing the min z values used for each color pixel + float *filter_map = new float[size_filter_map]; + // pointer to the beginning of the important data + float *p_filter_map = filter_map + offset_filter_map; + + // map for storing the color offest for each depth pixel + int *depth_to_c_off = new int[size_depth]; + int *map_c_off = depth_to_c_off; + + // initializing the depth_map with values outside of the Kinect2 range + for(float *it = filter_map, *end = filter_map + size_filter_map; it != end; ++it){ + *it = 65536.0f; + } + // iterating over all pixels from undistorted depth and registered color image - // the three maps have the same structure as the images, so their pointers are increased each iteration as well - for (int i = 0; i < size_depth; ++i, ++registered_data, ++undistorted_data, ++map_dist, ++map_x, ++map_yi) { + // the four maps have the same structure as the images, so their pointers are increased each iteration as well + for(int i = 0; i < size_depth; ++i, ++undistorted_data, ++map_dist, ++map_x, ++map_yi, ++map_c_off){ // getting index of distorted depth pixel const int index = *map_dist; // check if distorted depth pixel is outside of the depth image if(index < 0){ + *map_c_off = -1; *undistorted_data = 0; - *registered_data = 0; - *++registered_data = 0; - *++registered_data = 0; continue; } // getting depth value for current pixel - const float z_raw = depth_data[index]; - *undistorted_data = z_raw; + const float z = depth_data[index]; + *undistorted_data = z; // checking for invalid depth value - if (z_raw <= 0.0f) { - *registered_data = 0; - *++registered_data = 0; - *++registered_data = 0; + if(z <= 0.0f){ + *map_c_off = -1; continue; } // calculating x offset for rgb image based on depth value - const float rx = (*map_x + (color.shift_m / z_raw)) * color.fx + color_cx; + const float rx = (*map_x + (color.shift_m / z)) * color.fx + color_cx; const int cx = rx; // same as round for positive numbers (0.5f was already added to color_cx) // getting y offset for depth image const int cy = *map_yi; // combining offsets - const int c_off = cx * 3 + cy; + const int c_off = cx + cy * 1920; // check if c_off is outside of rgb image // checking rx/cx is not needed because the color image is much wider then the depth image - if (c_off < 0 || c_off >= size_color) { + if(c_off < 0 || c_off >= size_color){ + *map_c_off = -1; + continue; + } + + // setting a window around the filter map pixel corresponding to the color pixel with the current z value + int yi = (cy - filter_height_half) * 1920 + cx - filter_width_half; // index of first pixel to set + for(int r = -filter_height_half; r <= filter_height_half; ++r, yi += 1920) // index increased by a full row each iteration + { + float *it = p_filter_map + yi; + for(int c = -filter_width_half; c <= filter_width_half; ++c, ++it) + { + // only set if the current z is smaller + if(z < *it) + *it = z; + } + } + + // saving the offset for later + *map_c_off = c_off; + } + + // reseting the pointers to the beginning + undistorted_data = (float*)undistorted->data; + map_c_off = depth_to_c_off; + + // run through all registered color pixels and set them based on filter results + for(int i = 0; i < size_depth; ++i, ++registered_data, ++map_c_off, ++undistorted_data){ + const int c_off = *map_c_off; + + // check if offset is out of image + if(c_off < 0){ + *registered_data = 0; + *++registered_data = 0; + *++registered_data = 0; + continue; + } + + const float min_z = p_filter_map[c_off]; + const float z = *undistorted_data; + + // check for allowed depth noise + if((z - min_z) / z > filter_tolerance) { *registered_data = 0; *++registered_data = 0; *++registered_data = 0; @@ -149,15 +208,19 @@ void Registration::apply(const Frame *rgb, const Frame *depth, Frame *undistorte } // Setting RGB or registered image - const unsigned char *rgb_data = rgb->data + c_off; + const unsigned char *rgb_data = rgb->data + c_off * 3; *registered_data = *rgb_data; *++registered_data = *++rgb_data; *++registered_data = *++rgb_data; } + + // delete the temporary maps + delete[] filter_map; + delete[] depth_to_c_off; } Registration::Registration(Freenect2Device::IrCameraParams depth_p, Freenect2Device::ColorCameraParams rgb_p): - depth(depth_p), color(rgb_p) + depth(depth_p), color(rgb_p), filter_width_half(2), filter_height_half(1), filter_tolerance(0.01f) { float mx, my; int ix, iy, index; @@ -186,7 +249,7 @@ Registration::Registration(Freenect2Device::IrCameraParams depth_p, Freenect2Dev *map_x++ = rx; *map_y++ = ry; // compute the y offset to minimize later computations - *map_yi++ = roundf(ry) * 1920 * 3; + *map_yi++ = roundf(ry); } } } From 05d73e0a257a0297d9f121c854f8f0706c70dfbd Mon Sep 17 00:00:00 2001 From: Thiemo Wiedemeyer Date: Thu, 11 Jun 2015 09:55:35 +0200 Subject: [PATCH 2/6] registration code can now handle 3 byte and 4 byte color images. --- examples/protonect/src/registration.cpp | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/examples/protonect/src/registration.cpp b/examples/protonect/src/registration.cpp index a7b3d2d5d..bc8a3f108 100644 --- a/examples/protonect/src/registration.cpp +++ b/examples/protonect/src/registration.cpp @@ -88,10 +88,10 @@ void Registration::apply(const Frame *rgb, const Frame *depth, Frame *undistorte { // Check if all frames are valid and have the correct size if (!undistorted || !rgb || !registered || - rgb->width != 1920 || rgb->height != 1080 || rgb->bytes_per_pixel != 3 || + rgb->width != 1920 || rgb->height != 1080 || (rgb->bytes_per_pixel != 3 && rgb->bytes_per_pixel != 4) || depth->width != 512 || depth->height != 424 || depth->bytes_per_pixel != 4 || undistorted->width != 512 || undistorted->height != 424 || undistorted->bytes_per_pixel != 4 || - registered->width != 512 || registered->height != 424 || registered->bytes_per_pixel != 3) + registered->width != 512 || registered->height != 424 || (registered->bytes_per_pixel != 3 && registered->bytes_per_pixel != 5)) return; const float *depth_data = (float*)depth->data; @@ -185,14 +185,12 @@ void Registration::apply(const Frame *rgb, const Frame *depth, Frame *undistorte map_c_off = depth_to_c_off; // run through all registered color pixels and set them based on filter results - for(int i = 0; i < size_depth; ++i, ++registered_data, ++map_c_off, ++undistorted_data){ + for(int i = 0; i < size_depth; ++i, registered_data += registered->bytes_per_pixel, ++map_c_off, ++undistorted_data){ const int c_off = *map_c_off; // check if offset is out of image if(c_off < 0){ - *registered_data = 0; - *++registered_data = 0; - *++registered_data = 0; + *(int*)registered_data = 0; continue; } @@ -201,17 +199,13 @@ void Registration::apply(const Frame *rgb, const Frame *depth, Frame *undistorte // check for allowed depth noise if((z - min_z) / z > filter_tolerance) { - *registered_data = 0; - *++registered_data = 0; - *++registered_data = 0; + *(int*)registered_data = 0; continue; } // Setting RGB or registered image - const unsigned char *rgb_data = rgb->data + c_off * 3; - *registered_data = *rgb_data; - *++registered_data = *++rgb_data; - *++registered_data = *++rgb_data; + const int *rgb_data = (int*)(rgb->data + c_off * rgb->bytes_per_pixel); + *(int*)registered_data = *rgb_data; } // delete the temporary maps From 4149685f2d0f74a329ea858ce3d9275a4cc9a5f7 Mon Sep 17 00:00:00 2001 From: Thiemo Wiedemeyer Date: Thu, 11 Jun 2015 10:40:00 +0200 Subject: [PATCH 3/6] made filtering optional, but enabled by default. --- .../include/libfreenect2/registration.h | 2 +- examples/protonect/src/registration.cpp | 85 +++++++++++-------- 2 files changed, 49 insertions(+), 38 deletions(-) diff --git a/examples/protonect/include/libfreenect2/registration.h b/examples/protonect/include/libfreenect2/registration.h index f6170fd53..2fe65a531 100644 --- a/examples/protonect/include/libfreenect2/registration.h +++ b/examples/protonect/include/libfreenect2/registration.h @@ -44,7 +44,7 @@ class LIBFREENECT2_API Registration void apply(int dx, int dy, float dz, float& cx, float &cy) const; // undistort/register a whole image - void apply(const Frame* rgb, const Frame* depth, Frame* undistorted, Frame* registered) const; + void apply(const Frame* rgb, const Frame* depth, Frame* undistorted, Frame* registered, const bool enable_filter = true) const; private: void distort(int mx, int my, float& dx, float& dy) const; diff --git a/examples/protonect/src/registration.cpp b/examples/protonect/src/registration.cpp index bc8a3f108..f3a7f18b2 100644 --- a/examples/protonect/src/registration.cpp +++ b/examples/protonect/src/registration.cpp @@ -84,7 +84,7 @@ void Registration::apply( int dx, int dy, float dz, float& cx, float &cy) const cx = rx * color.fx + color.cx; } -void Registration::apply(const Frame *rgb, const Frame *depth, Frame *undistorted, Frame *registered) const +void Registration::apply(const Frame *rgb, const Frame *depth, Frame *undistorted, Frame *registered, const bool enable_filter) const { // Check if all frames are valid and have the correct size if (!undistorted || !rgb || !registered || @@ -112,17 +112,22 @@ void Registration::apply(const Frame *rgb, const Frame *depth, Frame *undistorte const int offset_filter_map = 1920 * filter_height_half; // map for storing the min z values used for each color pixel - float *filter_map = new float[size_filter_map]; + float *filter_map = NULL; // pointer to the beginning of the important data - float *p_filter_map = filter_map + offset_filter_map; + float *p_filter_map = NULL; // map for storing the color offest for each depth pixel int *depth_to_c_off = new int[size_depth]; int *map_c_off = depth_to_c_off; // initializing the depth_map with values outside of the Kinect2 range - for(float *it = filter_map, *end = filter_map + size_filter_map; it != end; ++it){ - *it = 65536.0f; + if(enable_filter){ + filter_map = new float[size_filter_map]; + p_filter_map = filter_map + offset_filter_map; + + for(float *it = filter_map, *end = filter_map + size_filter_map; it != end; ++it){ + *it = 65536.0f; + } } // iterating over all pixels from undistorted depth and registered color image @@ -163,53 +168,59 @@ void Registration::apply(const Frame *rgb, const Frame *depth, Frame *undistorte continue; } - // setting a window around the filter map pixel corresponding to the color pixel with the current z value - int yi = (cy - filter_height_half) * 1920 + cx - filter_width_half; // index of first pixel to set - for(int r = -filter_height_half; r <= filter_height_half; ++r, yi += 1920) // index increased by a full row each iteration - { - float *it = p_filter_map + yi; - for(int c = -filter_width_half; c <= filter_width_half; ++c, ++it) + // saving the offset for later + *map_c_off = c_off; + + if(enable_filter){ + // setting a window around the filter map pixel corresponding to the color pixel with the current z value + int yi = (cy - filter_height_half) * 1920 + cx - filter_width_half; // index of first pixel to set + for(int r = -filter_height_half; r <= filter_height_half; ++r, yi += 1920) // index increased by a full row each iteration { - // only set if the current z is smaller - if(z < *it) - *it = z; + float *it = p_filter_map + yi; + for(int c = -filter_width_half; c <= filter_width_half; ++c, ++it) + { + // only set if the current z is smaller + if(z < *it) + *it = z; + } } } - - // saving the offset for later - *map_c_off = c_off; } // reseting the pointers to the beginning - undistorted_data = (float*)undistorted->data; map_c_off = depth_to_c_off; + undistorted_data = (float*)undistorted->data; - // run through all registered color pixels and set them based on filter results - for(int i = 0; i < size_depth; ++i, registered_data += registered->bytes_per_pixel, ++map_c_off, ++undistorted_data){ - const int c_off = *map_c_off; + if(enable_filter){ + // run through all registered color pixels and set them based on filter results + for(int i = 0; i < size_depth; ++i, ++map_c_off, ++undistorted_data, registered_data += registered->bytes_per_pixel){ + const int c_off = *map_c_off; - // check if offset is out of image - if(c_off < 0){ - *(int*)registered_data = 0; - continue; - } + // check if offset is out of image + if(c_off < 0){ + *(int*)registered_data = 0; + continue; + } - const float min_z = p_filter_map[c_off]; - const float z = *undistorted_data; + const float min_z = p_filter_map[c_off]; + const float z = *undistorted_data; - // check for allowed depth noise - if((z - min_z) / z > filter_tolerance) { - *(int*)registered_data = 0; - continue; + // check for allowed depth noise + *(int*)registered_data = (z - min_z) / z > filter_tolerance ? 0 : *(int*)(rgb->data + c_off * rgb->bytes_per_pixel); } - // Setting RGB or registered image - const int *rgb_data = (int*)(rgb->data + c_off * rgb->bytes_per_pixel); - *(int*)registered_data = *rgb_data; + // delete the temporary maps + delete[] filter_map; } + else + { + for(int i = 0; i < size_depth; ++i, ++map_c_off, registered_data += registered->bytes_per_pixel){ + const int c_off = *map_c_off; - // delete the temporary maps - delete[] filter_map; + // check if offset is out of image + *(int*)registered_data = c_off < 0 ? 0 : *(int*)(rgb->data + c_off * rgb->bytes_per_pixel); + } + } delete[] depth_to_c_off; } From da4a8cbbf1b754d15d7d3af18e3e01069b640032 Mon Sep 17 00:00:00 2001 From: Thiemo Wiedemeyer Date: Thu, 11 Jun 2015 10:54:18 +0200 Subject: [PATCH 4/6] small bug fix. always output 4 byte color image and alpha channel is set to zero. --- examples/protonect/src/registration.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/protonect/src/registration.cpp b/examples/protonect/src/registration.cpp index f3a7f18b2..fbc0cd550 100644 --- a/examples/protonect/src/registration.cpp +++ b/examples/protonect/src/registration.cpp @@ -91,7 +91,7 @@ void Registration::apply(const Frame *rgb, const Frame *depth, Frame *undistorte rgb->width != 1920 || rgb->height != 1080 || (rgb->bytes_per_pixel != 3 && rgb->bytes_per_pixel != 4) || depth->width != 512 || depth->height != 424 || depth->bytes_per_pixel != 4 || undistorted->width != 512 || undistorted->height != 424 || undistorted->bytes_per_pixel != 4 || - registered->width != 512 || registered->height != 424 || (registered->bytes_per_pixel != 3 && registered->bytes_per_pixel != 5)) + registered->width != 512 || registered->height != 424 || registered->bytes_per_pixel != 4) return; const float *depth_data = (float*)depth->data; @@ -205,8 +205,8 @@ void Registration::apply(const Frame *rgb, const Frame *depth, Frame *undistorte const float min_z = p_filter_map[c_off]; const float z = *undistorted_data; - // check for allowed depth noise - *(int*)registered_data = (z - min_z) / z > filter_tolerance ? 0 : *(int*)(rgb->data + c_off * rgb->bytes_per_pixel); + // 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. + *(unsigned int*)registered_data = (z - min_z) / z > filter_tolerance ? 0 : (*(unsigned int*)(rgb->data + c_off * rgb->bytes_per_pixel)) & 0x00FFFFFF; } // delete the temporary maps @@ -217,8 +217,8 @@ void Registration::apply(const Frame *rgb, const Frame *depth, Frame *undistorte for(int i = 0; i < size_depth; ++i, ++map_c_off, registered_data += registered->bytes_per_pixel){ const int c_off = *map_c_off; - // check if offset is out of image - *(int*)registered_data = c_off < 0 ? 0 : *(int*)(rgb->data + c_off * rgb->bytes_per_pixel); + // 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. + *(unsigned int*)registered_data = c_off < 0 ? 0 : (*(unsigned int*)(rgb->data + c_off * rgb->bytes_per_pixel)) & 0x00FFFFFF; } } delete[] depth_to_c_off; From 3405757ae2fc9cea289459c578a5365a7d4e30c5 Mon Sep 17 00:00:00 2001 From: Thiemo Wiedemeyer Date: Thu, 11 Jun 2015 10:57:59 +0200 Subject: [PATCH 5/6] updated protonect due to registration changes. --- examples/protonect/Protonect.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/protonect/Protonect.cpp b/examples/protonect/Protonect.cpp index 07da0a331..1b254d3bf 100644 --- a/examples/protonect/Protonect.cpp +++ b/examples/protonect/Protonect.cpp @@ -124,7 +124,7 @@ int main(int argc, char *argv[]) libfreenect2::SyncMultiFrameListener listener(libfreenect2::Frame::Color | libfreenect2::Frame::Ir | libfreenect2::Frame::Depth); libfreenect2::FrameMap frames; - libfreenect2::Frame undistorted(512, 424, 4), registered(512, 424, 3); + libfreenect2::Frame undistorted(512, 424, 4), registered(512, 424, 4); dev->setColorFrameListener(&listener); dev->setIrAndDepthFrameListener(&listener); @@ -149,7 +149,7 @@ int main(int argc, char *argv[]) registration->apply(rgb,depth,&undistorted,®istered); cv::imshow("undistorted", cv::Mat(undistorted.height, undistorted.width, CV_32FC1, undistorted.data) / 4500.0f); - cv::imshow("registered", cv::Mat(registered.height, registered.width, CV_8UC3, registered.data)); + cv::imshow("registered", cv::Mat(registered.height, registered.width, CV_8UC4, registered.data)); int key = cv::waitKey(1); protonect_shutdown = protonect_shutdown || (key > 0 && ((key & 0xFF) == 27)); // shutdown on escape From d823f840c0f43fb03cfd8135cfd5e8112ca90b5a Mon Sep 17 00:00:00 2001 From: Thiemo Wiedemeyer Date: Thu, 11 Jun 2015 14:58:48 +0200 Subject: [PATCH 6/6] Changed jpeg processor to always output BGRX format. Updated registration and removed handling of 3 byte color images. Updated protonect to display color image correct. --- examples/protonect/Protonect.cpp | 2 +- examples/protonect/src/registration.cpp | 21 ++++++++++--------- .../src/turbo_jpeg_rgb_packet_processor.cpp | 4 ++-- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/examples/protonect/Protonect.cpp b/examples/protonect/Protonect.cpp index 1b254d3bf..3308fd0f7 100644 --- a/examples/protonect/Protonect.cpp +++ b/examples/protonect/Protonect.cpp @@ -142,7 +142,7 @@ int main(int argc, char *argv[]) libfreenect2::Frame *ir = frames[libfreenect2::Frame::Ir]; libfreenect2::Frame *depth = frames[libfreenect2::Frame::Depth]; - cv::imshow("rgb", cv::Mat(rgb->height, rgb->width, CV_8UC3, rgb->data)); + cv::imshow("rgb", cv::Mat(rgb->height, rgb->width, CV_8UC4, rgb->data)); cv::imshow("ir", cv::Mat(ir->height, ir->width, CV_32FC1, ir->data) / 20000.0f); cv::imshow("depth", cv::Mat(depth->height, depth->width, CV_32FC1, depth->data) / 4500.0f); diff --git a/examples/protonect/src/registration.cpp b/examples/protonect/src/registration.cpp index fbc0cd550..6a783b95b 100644 --- a/examples/protonect/src/registration.cpp +++ b/examples/protonect/src/registration.cpp @@ -88,15 +88,16 @@ void Registration::apply(const Frame *rgb, const Frame *depth, Frame *undistorte { // Check if all frames are valid and have the correct size if (!undistorted || !rgb || !registered || - rgb->width != 1920 || rgb->height != 1080 || (rgb->bytes_per_pixel != 3 && rgb->bytes_per_pixel != 4) || + rgb->width != 1920 || rgb->height != 1080 || rgb->bytes_per_pixel != 4 || depth->width != 512 || depth->height != 424 || depth->bytes_per_pixel != 4 || undistorted->width != 512 || undistorted->height != 424 || undistorted->bytes_per_pixel != 4 || registered->width != 512 || registered->height != 424 || registered->bytes_per_pixel != 4) return; const float *depth_data = (float*)depth->data; + const unsigned int *rgb_data = (unsigned int*)rgb->data; float *undistorted_data = (float*)undistorted->data; - unsigned char *registered_data = registered->data; + unsigned int *registered_data = (unsigned int*)registered->data; const int *map_dist = distort_map; const float *map_x = depth_to_color_map_x; const int *map_yi = depth_to_color_map_yi; @@ -193,32 +194,32 @@ void Registration::apply(const Frame *rgb, const Frame *depth, Frame *undistorte if(enable_filter){ // run through all registered color pixels and set them based on filter results - for(int i = 0; i < size_depth; ++i, ++map_c_off, ++undistorted_data, registered_data += registered->bytes_per_pixel){ + for(int i = 0; i < size_depth; ++i, ++map_c_off, ++undistorted_data, ++registered_data){ const int c_off = *map_c_off; // check if offset is out of image if(c_off < 0){ - *(int*)registered_data = 0; + *registered_data = 0; continue; } const float min_z = p_filter_map[c_off]; const float z = *undistorted_data; - // 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. - *(unsigned int*)registered_data = (z - min_z) / z > filter_tolerance ? 0 : (*(unsigned int*)(rgb->data + c_off * rgb->bytes_per_pixel)) & 0x00FFFFFF; + // check for allowed depth noise + *registered_data = (z - min_z) / z > filter_tolerance ? 0 : *(rgb_data + c_off); } - // delete the temporary maps delete[] filter_map; } else { - for(int i = 0; i < size_depth; ++i, ++map_c_off, registered_data += registered->bytes_per_pixel){ + // run through all registered color pixels and set them based on c_off + for(int i = 0; i < size_depth; ++i, ++map_c_off, ++registered_data){ const int c_off = *map_c_off; - // 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. - *(unsigned int*)registered_data = c_off < 0 ? 0 : (*(unsigned int*)(rgb->data + c_off * rgb->bytes_per_pixel)) & 0x00FFFFFF; + // check if offset is out of image + *registered_data = c_off < 0 ? 0 : *(rgb_data + c_off); } } delete[] depth_to_c_off; diff --git a/examples/protonect/src/turbo_jpeg_rgb_packet_processor.cpp b/examples/protonect/src/turbo_jpeg_rgb_packet_processor.cpp index f2a92d9f2..c93bec9c7 100644 --- a/examples/protonect/src/turbo_jpeg_rgb_packet_processor.cpp +++ b/examples/protonect/src/turbo_jpeg_rgb_packet_processor.cpp @@ -73,7 +73,7 @@ class TurboJpegRgbPacketProcessorImpl void newFrame() { - frame = new Frame(1920, 1080, tjPixelSize[TJPF_BGR]); + frame = new Frame(1920, 1080, tjPixelSize[TJPF_BGRX]); } void startTiming() @@ -115,7 +115,7 @@ void TurboJpegRgbPacketProcessor::process(const RgbPacket &packet) impl_->frame->timestamp = packet.timestamp; impl_->frame->sequence = packet.sequence; - int r = tjDecompress2(impl_->decompressor, packet.jpeg_buffer, packet.jpeg_buffer_length, impl_->frame->data, 1920, 1920 * tjPixelSize[TJPF_BGR], 1080, TJPF_BGR, 0); + int r = tjDecompress2(impl_->decompressor, packet.jpeg_buffer, packet.jpeg_buffer_length, impl_->frame->data, 1920, 1920 * tjPixelSize[TJPF_BGRX], 1080, TJPF_BGRX, 0); if(r == 0) {