diff --git a/CMakeLists.txt b/CMakeLists.txt index 07c839f2c..aa0ec34db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -126,12 +126,6 @@ SET(LIBRARIES ${LIBFREENECT2_THREADING_LIBRARIES} ) -SET(RESOURCES - data/11to16.bin - data/xTable.bin - data/zTable.bin -) - IF(ENABLE_OPENGL) FIND_PACKAGE(GLFW3) FIND_PACKAGE(OpenGL) diff --git a/data/11to16.bin b/data/11to16.bin deleted file mode 100644 index f62c5ade8..000000000 Binary files a/data/11to16.bin and /dev/null differ diff --git a/data/xTable.bin b/data/xTable.bin deleted file mode 100644 index f74842d36..000000000 Binary files a/data/xTable.bin and /dev/null differ diff --git a/data/zTable.bin b/data/zTable.bin deleted file mode 100644 index 4504b6158..000000000 Binary files a/data/zTable.bin and /dev/null differ diff --git a/include/libfreenect2/depth_packet_processor.h b/include/libfreenect2/depth_packet_processor.h index 6094424fd..49784f818 100644 --- a/include/libfreenect2/depth_packet_processor.h +++ b/include/libfreenect2/depth_packet_processor.h @@ -110,6 +110,12 @@ class LIBFREENECT2_API DepthPacketProcessor : public BaseDepthPacketProcessor virtual void setConfiguration(const libfreenect2::DepthPacketProcessor::Config &config); virtual void loadP0TablesFromCommandResponse(unsigned char* buffer, size_t buffer_length) = 0; + + static const size_t TABLE_SIZE = 512*424; + static const size_t LUT_SIZE = 2048; + virtual void loadXZTables(const float *xtable, const float *ztable) = 0; + virtual void loadLookupTable(const short *lut) = 0; + protected: libfreenect2::DepthPacketProcessor::Config config_; libfreenect2::FrameListener *listener_; @@ -128,17 +134,8 @@ class LIBFREENECT2_API OpenGLDepthPacketProcessor : public DepthPacketProcessor virtual void loadP0TablesFromCommandResponse(unsigned char* buffer, size_t buffer_length); - void loadP0TablesFromFiles(const char* p0_filename, const char* p1_filename, const char* p2_filename); - - /** - * GUESS: the x and z table follow some polynomial, until we know the exact polynom formula and its coefficients - * just load them from a memory dump - although they probably vary per camera - */ - void loadXTableFromFile(const char* filename); - - void loadZTableFromFile(const char* filename); - - void load11To16LutFromFile(const char* filename); + virtual void loadXZTables(const float *xtable, const float *ztable); + virtual void loadLookupTable(const short *lut); virtual void process(const DepthPacket &packet); private: @@ -159,17 +156,8 @@ class LIBFREENECT2_API CpuDepthPacketProcessor : public DepthPacketProcessor virtual void loadP0TablesFromCommandResponse(unsigned char* buffer, size_t buffer_length); - void loadP0TablesFromFiles(const char* p0_filename, const char* p1_filename, const char* p2_filename); - - /** - * GUESS: the x and z table follow some polynomial, until we know the exact polynom formula and its coefficients - * just load them from a memory dump - although they probably vary per camera - */ - void loadXTableFromFile(const char* filename); - - void loadZTableFromFile(const char* filename); - - void load11To16LutFromFile(const char* filename); + virtual void loadXZTables(const float *xtable, const float *ztable); + virtual void loadLookupTable(const short *lut); virtual void process(const DepthPacket &packet); private: @@ -189,15 +177,8 @@ class LIBFREENECT2_API OpenCLDepthPacketProcessor : public DepthPacketProcessor virtual void loadP0TablesFromCommandResponse(unsigned char* buffer, size_t buffer_length); - /** - * GUESS: the x and z table follow some polynomial, until we know the exact polynom formula and its coefficients - * just load them from a memory dump - although they probably vary per camera - */ - void loadXTableFromFile(const char* filename); - - void loadZTableFromFile(const char* filename); - - void load11To16LutFromFile(const char* filename); + virtual void loadXZTables(const float *xtable, const float *ztable); + virtual void loadLookupTable(const short *lut); virtual void process(const DepthPacket &packet); private: diff --git a/include/libfreenect2/libfreenect2.hpp b/include/libfreenect2/libfreenect2.hpp index 99aa772a3..e296e4974 100644 --- a/include/libfreenect2/libfreenect2.hpp +++ b/include/libfreenect2/libfreenect2.hpp @@ -88,7 +88,8 @@ class LIBFREENECT2_API Freenect2Device virtual Freenect2Device::ColorCameraParams getColorCameraParams() = 0; virtual Freenect2Device::IrCameraParams getIrCameraParams() = 0; - + virtual void setColorCameraParams(const Freenect2Device::ColorCameraParams ¶ms) = 0; + virtual void setIrCameraParams(const Freenect2Device::IrCameraParams ¶ms) = 0; virtual void setColorFrameListener(libfreenect2::FrameListener* rgb_frame_listener) = 0; virtual void setIrAndDepthFrameListener(libfreenect2::FrameListener* ir_frame_listener) = 0; diff --git a/src/cpu_depth_packet_processor.cpp b/src/cpu_depth_packet_processor.cpp index 53d0319f6..b16c5c542 100644 --- a/src/cpu_depth_packet_processor.cpp +++ b/src/cpu_depth_packet_processor.cpp @@ -261,26 +261,6 @@ void flipHorizontal(const Mat &in, Mat& out) namespace libfreenect2 { -/** - * Load a buffer from data of a file. - * @param filename Name of the file to load. - * @param buffer Start of the buffer to load. - * @param n Size of the buffer to load. - * @return Whether loading succeeded. - */ -bool loadBufferFromFile2(const std::string& filename, unsigned char *buffer, size_t n) -{ - bool success; - std::ifstream in(filename.c_str()); - - in.read(reinterpret_cast(buffer), n); - success = in.gcount() == n; - - in.close(); - - return success; -} - inline int bfi(int width, int offset, int src2, int src3) { int bitmask = (((1 << width)-1) << offset) & 0xffffffff; @@ -897,111 +877,18 @@ void CpuDepthPacketProcessor::loadP0TablesFromCommandResponse(unsigned char* buf impl_->fillTrigTable(impl_->p0_table2, impl_->trig_table2); } -/** - * Load p0 tables. - * @param p0_filename Filename of the first p0 table. - * @param p1_filename Filename of the second p0 table. - * @param p2_filename Filename of the third p0 table. - */ -void CpuDepthPacketProcessor::loadP0TablesFromFiles(const char* p0_filename, const char* p1_filename, const char* p2_filename) -{ - Mat p0_table0(424, 512); - if(!loadBufferFromFile2(p0_filename, p0_table0.buffer(), p0_table0.sizeInBytes())) - { - LOG_ERROR << "Loading p0table 0 from '" << p0_filename << "' failed!"; - } - - Mat p0_table1(424, 512); - if(!loadBufferFromFile2(p1_filename, p0_table1.buffer(), p0_table1.sizeInBytes())) - { - LOG_ERROR << "Loading p0table 1 from '" << p1_filename << "' failed!"; - } - - Mat p0_table2(424, 512); - if(!loadBufferFromFile2(p2_filename, p0_table2.buffer(), p0_table2.sizeInBytes())) - { - LOG_ERROR << "Loading p0table 2 from '" << p2_filename << "' failed!"; - } - - if(impl_->flip_ptables) - { - flipHorizontal(p0_table0, impl_->p0_table0); - flipHorizontal(p0_table1, impl_->p0_table1); - flipHorizontal(p0_table2, impl_->p0_table2); - - impl_->fillTrigTable(impl_->p0_table0, impl_->trig_table0); - impl_->fillTrigTable(impl_->p0_table1, impl_->trig_table1); - impl_->fillTrigTable(impl_->p0_table2, impl_->trig_table2); - } - else - { - impl_->fillTrigTable(p0_table0, impl_->trig_table0); - impl_->fillTrigTable(p0_table1, impl_->trig_table1); - impl_->fillTrigTable(p0_table2, impl_->trig_table2); - } -} - -/** - * Load the X table from the resources. - * @param filename Name of the file to load. - * @note Filename is not actually used! - */ -void CpuDepthPacketProcessor::loadXTableFromFile(const char* filename) +void CpuDepthPacketProcessor::loadXZTables(const float *xtable, const float *ztable) { impl_->x_table.create(424, 512); - const unsigned char *data; - size_t length; - - if(loadResource("xTable.bin", &data, &length)) - { - std::copy(data, data + length, impl_->x_table.buffer()); - } - else - { - LOG_ERROR << "Loading xtable from resource 'xTable.bin' failed!"; - } -} + std::copy(xtable, xtable + TABLE_SIZE, impl_->x_table.ptr(0,0)); -/** - * Load the Z table from the resources. - * @param filename Name of the file to load. - * @note Filename is not actually used! - */ -void CpuDepthPacketProcessor::loadZTableFromFile(const char* filename) -{ impl_->z_table.create(424, 512); - - const unsigned char *data; - size_t length; - - if(loadResource("zTable.bin", &data, &length)) - { - std::copy(data, data + length, impl_->z_table.buffer()); - } - else - { - LOG_ERROR << "Loading ztable from resource 'zTable.bin' failed!"; - } + std::copy(ztable, ztable + TABLE_SIZE, impl_->z_table.ptr(0,0)); } -/** - * Load the lookup table from 11 to 16 from the resources. - * @param filename Name of the file to load. - * @note Filename is not actually used! - */ -void CpuDepthPacketProcessor::load11To16LutFromFile(const char* filename) +void CpuDepthPacketProcessor::loadLookupTable(const short *lut) { - const unsigned char *data; - size_t length; - - if(loadResource("11to16.bin", &data, &length)) - { - std::copy(data, data + length, reinterpret_cast(impl_->lut11to16)); - } - else - { - LOG_ERROR << "Loading 11to16 lut from resource '11to16.bin' failed!"; - } + std::copy(lut, lut + LUT_SIZE, impl_->lut11to16); } /** diff --git a/src/libfreenect2.cpp b/src/libfreenect2.cpp index 8628f4ca4..f5575b6b6 100644 --- a/src/libfreenect2.cpp +++ b/src/libfreenect2.cpp @@ -30,6 +30,8 @@ #include #include #include +#include +#include #define WRITE_LIBUSB_ERROR(__RESULT) libusb_error_name(__RESULT) << " " << libusb_strerror((libusb_error)__RESULT) #include @@ -49,6 +51,154 @@ using namespace libfreenect2; using namespace libfreenect2::usb; using namespace libfreenect2::protocol; +/* +For detailed analysis see https://github.com/OpenKinect/libfreenect2/issues/144 + +The following discussion is in no way authoritative. It is the current best +explanation considering the hardcoded parameters and decompiled code. + +p0 tables are the "initial shift" of phase values, as in US8587771 B2. + +Three p0 tables are used for "disamgibuation" in the first half of stage 2 +processing. + +At the end of stage 2 processing: + +phase_final is the phase shift used to compute the travel distance. + +What is being measured is max_depth (d), the total travel distance of the +reflected ray. + +But what we want is depth_fit (z), the distance from reflection to the XY +plane. There are two issues: the distance before reflection is not needed; +and the measured ray is not normal to the XY plane. + +Suppose L is the distance between the light source and the focal point (a +fixed constant), and xu,yu is the undistorted and normalized coordinates for +each measured pixel at unit depth. + +Through some derivation, we have + + z = (d*d - L*L)/(d*sqrt(xu*xu + yu*yu + 1) - xu*L)/2. + +The expression in stage 2 processing is a variant of this, with the term +`-L*L` removed. Detailed derivation can be found in the above issue. + +Here, the two terms `sqrt(xu*xu + yu*yu + 1)` and `xu` requires undistorted +coordinates, which is hard to compute in real-time because the inverse of +radial and tangential distortion has no analytical solutions and requires +numeric methods to solve. Thus these two terms are precomputed once and +their variants are stored as ztable and xtable respectively. + +Even though x/ztable is derived with undistortion, they are only used to +correct the effect of distortion on the z value. Image warping is needed for +correcting distortion on x-y value, which happens in registration.cpp. +*/ +struct IrCameraTables: Freenect2Device::IrCameraParams +{ + std::vector xtable; + std::vector ztable; + std::vector lut; + + IrCameraTables(const Freenect2Device::IrCameraParams &parent): + Freenect2Device::IrCameraParams(parent), + xtable(DepthPacketProcessor::TABLE_SIZE), + ztable(DepthPacketProcessor::TABLE_SIZE), + lut(DepthPacketProcessor::LUT_SIZE) + { + const double scaling_factor = 8192; + const double unambigious_dist = 6250.0/3; + size_t divergence = 0; + for (size_t i = 0; i < DepthPacketProcessor::TABLE_SIZE; i++) + { + size_t xi = i % 512; + size_t yi = i / 512; + double xd = (xi + 0.5 - cx)/fx; + double yd = (yi + 0.5 - cy)/fy; + double xu, yu; + divergence += !undistort(xd, yd, xu, yu); + xtable[i] = scaling_factor*xu; + ztable[i] = unambigious_dist/sqrt(xu*xu + yu*yu + 1); + } + + if (divergence > 0) + LOG_ERROR << divergence << " pixels in x/ztable have incorrect undistortion."; + + short y = 0; + for (int x = 0; x < 1024; x++) + { + unsigned inc = 1 << (x/128 - (x>=128)); + lut[x] = y; + lut[1024 + x] = -y; + y += inc; + } + lut[1024] = 32767; + } + + //x,y: undistorted, normalized coordinates + //xd,yd: distorted, normalized coordinates + void distort(double x, double y, double &xd, double &yd) const + { + double x2 = x * x; + double y2 = y * y; + double r2 = x2 + y2; + double xy = x * y; + double kr = ((k3 * r2 + k2) * r2 + k1) * r2 + 1.0; + xd = x*kr + p2*(r2 + 2*x2) + 2*p1*xy; + yd = y*kr + p1*(r2 + 2*y2) + 2*p2*xy; + } + + //The inverse of distort() using Newton's method + //Return true if converged correctly + //This function considers tangential distortion with double precision. + bool undistort(double x, double y, double &xu, double &yu) const + { + double x0 = x; + double y0 = y; + + double last_x = x; + double last_y = y; + const int max_iterations = 100; + int iter; + for (iter = 0; iter < max_iterations; iter++) { + double x2 = x*x; + double y2 = y*y; + double x2y2 = x2 + y2; + double x2y22 = x2y2*x2y2; + double x2y23 = x2y2*x2y22; + + //Jacobian matrix + double Ja = k3*x2y23 + (k2+6*k3*x2)*x2y22 + (k1+4*k2*x2)*x2y2 + 2*k1*x2 + 6*p2*x + 2*p1*y + 1; + double Jb = 6*k3*x*y*x2y22 + 4*k2*x*y*x2y2 + 2*k1*x*y + 2*p1*x + 2*p2*y; + double Jc = Jb; + double Jd = k3*x2y23 + (k2+6*k3*y2)*x2y22 + (k1+4*k2*y2)*x2y2 + 2*k1*y2 + 2*p2*x + 6*p1*y + 1; + + //Inverse Jacobian + double Jdet = 1/(Ja*Jd - Jb*Jc); + double a = Jd*Jdet; + double b = -Jb*Jdet; + double c = -Jc*Jdet; + double d = Ja*Jdet; + + double f, g; + distort(x, y, f, g); + f -= x0; + g -= y0; + + x -= a*f + b*g; + y -= c*f + d*g; + const double eps = std::numeric_limits::epsilon()*16; + if (fabs(x - last_x) <= eps && fabs(y - last_y) <= eps) + break; + last_x = x; + last_y = y; + } + xu = x; + yu = y; + return iter < max_iterations; + } +}; + /** Freenect2 device implementation. */ class Freenect2DeviceImpl : public Freenect2Device { @@ -90,6 +240,8 @@ class Freenect2DeviceImpl : public Freenect2Device virtual Freenect2Device::ColorCameraParams getColorCameraParams(); virtual Freenect2Device::IrCameraParams getIrCameraParams(); + virtual void setColorCameraParams(const Freenect2Device::ColorCameraParams ¶ms); + virtual void setIrCameraParams(const Freenect2Device::IrCameraParams ¶ms); int nextCommandSeq(); @@ -424,6 +576,24 @@ Freenect2Device::IrCameraParams Freenect2DeviceImpl::getIrCameraParams() { return ir_camera_params_; } + +void Freenect2DeviceImpl::setColorCameraParams(const Freenect2Device::ColorCameraParams ¶ms) +{ + rgb_camera_params_ = params; +} + +void Freenect2DeviceImpl::setIrCameraParams(const Freenect2Device::IrCameraParams ¶ms) +{ + ir_camera_params_ = params; + DepthPacketProcessor *proc = pipeline_->getDepthPacketProcessor(); + if (proc != 0) + { + IrCameraTables tables(params); + proc->loadXZTables(&tables.xtable[0], &tables.ztable[0]); + proc->loadLookupTable(&tables.lut[0]); + } +} + void Freenect2DeviceImpl::setColorFrameListener(libfreenect2::FrameListener* rgb_frame_listener) { // TODO: should only be possible, if not started @@ -501,6 +671,7 @@ void Freenect2DeviceImpl::start() command_tx_.execute(ReadDepthCameraParametersCommand(nextCommandSeq()), result); DepthCameraParamsResponse *ir_p = reinterpret_cast(result.data); + IrCameraParams ir_camera_params_; ir_camera_params_.fx = ir_p->fx; ir_camera_params_.fy = ir_p->fy; ir_camera_params_.cx = ir_p->cx; @@ -510,6 +681,7 @@ void Freenect2DeviceImpl::start() ir_camera_params_.k3 = ir_p->k3; ir_camera_params_.p1 = ir_p->p1; ir_camera_params_.p2 = ir_p->p2; + setIrCameraParams(ir_camera_params_); command_tx_.execute(ReadP0TablesCommand(nextCommandSeq()), result); if(pipeline_->getDepthPacketProcessor() != 0) @@ -518,6 +690,7 @@ void Freenect2DeviceImpl::start() command_tx_.execute(ReadRgbCameraParametersCommand(nextCommandSeq()), result); RgbCameraParamsResponse *rgb_p = reinterpret_cast(result.data); + ColorCameraParams rgb_camera_params_; rgb_camera_params_.fx = rgb_p->color_f; rgb_camera_params_.fy = rgb_p->color_f; rgb_camera_params_.cx = rgb_p->color_cx; @@ -547,6 +720,7 @@ void Freenect2DeviceImpl::start() rgb_camera_params_.my_x1y0 = rgb_p->my_x1y0; // x rgb_camera_params_.my_x0y1 = rgb_p->my_x0y1; // y rgb_camera_params_.my_x0y0 = rgb_p->my_x0y0; // 1 + setColorCameraParams(rgb_camera_params_); command_tx_.execute(ReadStatus0x090000Command(nextCommandSeq()), result); LOG_DEBUG << "ReadStatus0x090000 response"; diff --git a/src/opencl_depth_packet_processor.cpp b/src/opencl_depth_packet_processor.cpp index ef8953e0f..a87d637d9 100644 --- a/src/opencl_depth_packet_processor.cpp +++ b/src/opencl_depth_packet_processor.cpp @@ -638,28 +638,15 @@ void OpenCLDepthPacketProcessor::loadP0TablesFromCommandResponse(unsigned char * impl_->fill_trig_table(p0table); } -void OpenCLDepthPacketProcessor::loadXTableFromFile(const char *filename) +void OpenCLDepthPacketProcessor::loadXZTables(const float *xtable, const float *ztable) { - if(!loadBufferFromResources(filename, (unsigned char *)impl_->x_table, impl_->image_size * sizeof(float))) - { - LOG_ERROR << "could not load x table from: " << filename; - } + std::copy(xtable, xtable + TABLE_SIZE, impl_->x_table); + std::copy(ztable, ztable + TABLE_SIZE, impl_->z_table); } -void OpenCLDepthPacketProcessor::loadZTableFromFile(const char *filename) +void OpenCLDepthPacketProcessor::loadLookupTable(const short *lut) { - if(!loadBufferFromResources(filename, (unsigned char *)impl_->z_table, impl_->image_size * sizeof(float))) - { - LOG_ERROR << "could not load z table from: " << filename; - } -} - -void OpenCLDepthPacketProcessor::load11To16LutFromFile(const char *filename) -{ - if(!loadBufferFromResources(filename, (unsigned char *)impl_->lut11to16, 2048 * sizeof(cl_ushort))) - { - LOG_ERROR << "could not load lut table from: " << filename; - } + std::copy(lut, lut + LUT_SIZE, impl_->lut11to16); } void OpenCLDepthPacketProcessor::process(const DepthPacket &packet) diff --git a/src/opengl_depth_packet_processor.cpp b/src/opengl_depth_packet_processor.cpp index b08c296d5..e764d1faa 100644 --- a/src/opengl_depth_packet_processor.cpp +++ b/src/opengl_depth_packet_processor.cpp @@ -111,19 +111,6 @@ std::string loadShaderSource(const std::string& filename) return std::string(reinterpret_cast(data), length); } -bool loadBufferFromFile(const std::string& filename, unsigned char *buffer, size_t n) -{ - bool success = true; - std::ifstream in(filename.c_str()); - - in.read(reinterpret_cast(buffer), n); - success = in.gcount() == n; - - in.close(); - - return success; -} - struct ShaderProgram : public WithOpenGLBindings { typedef std::map FragDataMap; @@ -322,6 +309,9 @@ struct Texture : public WithOpenGLBindings void allocate(size_t new_width, size_t new_height) { + if (size) + return; + GLint max_size; glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE, &max_size); if (new_width > max_size || new_height > max_size) @@ -930,98 +920,26 @@ void OpenGLDepthPacketProcessor::loadP0TablesFromCommandResponse(unsigned char* } -void OpenGLDepthPacketProcessor::loadP0TablesFromFiles(const char* p0_filename, const char* p1_filename, const char* p2_filename) -{ - ChangeCurrentOpenGLContext ctx(impl_->opengl_context_ptr); - - impl_->p0table[0].allocate(512, 424); - if(loadBufferFromFile(p0_filename, impl_->p0table[0].data, impl_->p0table[0].size)) - { - impl_->p0table[0].upload(); - } - else - { - LOG_ERROR << "Loading p0table 0 from '" << p0_filename << "' failed!"; - } - - impl_->p0table[1].allocate(512, 424); - if(loadBufferFromFile(p1_filename, impl_->p0table[1].data, impl_->p0table[1].size)) - { - impl_->p0table[1].upload(); - } - else - { - LOG_ERROR << "Loading p0table 1 from '" << p1_filename << "' failed!"; - } - - impl_->p0table[2].allocate(512, 424); - if(loadBufferFromFile(p2_filename, impl_->p0table[2].data, impl_->p0table[2].size)) - { - impl_->p0table[2].upload(); - } - else - { - LOG_ERROR << "Loading p0table 2 from '" << p2_filename << "' failed!"; - } -} - -void OpenGLDepthPacketProcessor::loadXTableFromFile(const char* filename) +void OpenGLDepthPacketProcessor::loadXZTables(const float *xtable, const float *ztable) { ChangeCurrentOpenGLContext ctx(impl_->opengl_context_ptr); impl_->x_table.allocate(512, 424); - const unsigned char *data; - size_t length; - - if(loadResource("xTable.bin", &data, &length)) - { - std::copy(data, data + length, impl_->x_table.data); - impl_->x_table.upload(); - } - else - { - LOG_ERROR << "Loading xtable from resource 'xTable.bin' failed!"; - } -} - -void OpenGLDepthPacketProcessor::loadZTableFromFile(const char* filename) -{ - ChangeCurrentOpenGLContext ctx(impl_->opengl_context_ptr); + std::copy(xtable, xtable + TABLE_SIZE, (float *)impl_->x_table.data); + impl_->x_table.upload(); impl_->z_table.allocate(512, 424); - - const unsigned char *data; - size_t length; - - if(loadResource("zTable.bin", &data, &length)) - { - std::copy(data, data + length, impl_->z_table.data); - impl_->z_table.upload(); - } - else - { - LOG_ERROR << "Loading ztable from resource 'zTable.bin' failed!"; - } + std::copy(ztable, ztable + TABLE_SIZE, (float *)impl_->z_table.data); + impl_->z_table.upload(); } -void OpenGLDepthPacketProcessor::load11To16LutFromFile(const char* filename) +void OpenGLDepthPacketProcessor::loadLookupTable(const short *lut) { ChangeCurrentOpenGLContext ctx(impl_->opengl_context_ptr); impl_->lut11to16.allocate(2048, 1); - - const unsigned char *data; - size_t length; - - if(loadResource("11to16.bin", &data, &length)) - { - std::copy(data, data + length, impl_->lut11to16.data); - impl_->lut11to16.upload(); - } - else - { - LOG_ERROR << "Loading 11to16 lut from resource '11to16.bin' failed!"; - } + std::copy(lut, lut + LUT_SIZE, (short *)impl_->lut11to16.data); + impl_->lut11to16.upload(); } void OpenGLDepthPacketProcessor::process(const DepthPacket &packet) diff --git a/src/packet_pipeline.cpp b/src/packet_pipeline.cpp index 70360feac..938c6619a 100644 --- a/src/packet_pipeline.cpp +++ b/src/packet_pipeline.cpp @@ -94,9 +94,6 @@ CpuPacketPipeline::~CpuPacketPipeline() { } DepthPacketProcessor *CpuPacketPipeline::createDepthPacketProcessor() { CpuDepthPacketProcessor *depth_processor = new CpuDepthPacketProcessor(); - depth_processor->load11To16LutFromFile("11to16.bin"); - depth_processor->loadXTableFromFile("xTable.bin"); - depth_processor->loadZTableFromFile("zTable.bin"); return depth_processor; } @@ -112,9 +109,6 @@ OpenGLPacketPipeline::~OpenGLPacketPipeline() { } DepthPacketProcessor *OpenGLPacketPipeline::createDepthPacketProcessor() { OpenGLDepthPacketProcessor *depth_processor = new OpenGLDepthPacketProcessor(parent_opengl_context_, debug_); - depth_processor->load11To16LutFromFile("11to16.bin"); - depth_processor->loadXTableFromFile("xTable.bin"); - depth_processor->loadZTableFromFile("zTable.bin"); return depth_processor; } @@ -133,9 +127,6 @@ OpenCLPacketPipeline::~OpenCLPacketPipeline() { } DepthPacketProcessor *OpenCLPacketPipeline::createDepthPacketProcessor() { OpenCLDepthPacketProcessor *depth_processor = new OpenCLDepthPacketProcessor(deviceId); - depth_processor->load11To16LutFromFile("11to16.bin"); - depth_processor->loadXTableFromFile("xTable.bin"); - depth_processor->loadZTableFromFile("zTable.bin"); return depth_processor; }