From dd9485cc837d6126a277ea41f6a73540ed97569b Mon Sep 17 00:00:00 2001 From: Gabor Papp Date: Mon, 8 Dec 2014 20:10:07 +0100 Subject: [PATCH 1/5] test_opengl OSX fix --- examples/protonect/src/test_opengl_depth_packet_processor.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/protonect/src/test_opengl_depth_packet_processor.cpp b/examples/protonect/src/test_opengl_depth_packet_processor.cpp index 7c91d3fd7..479b369ad 100644 --- a/examples/protonect/src/test_opengl_depth_packet_processor.cpp +++ b/examples/protonect/src/test_opengl_depth_packet_processor.cpp @@ -58,6 +58,9 @@ int main(int argc, char **argv) { glfwInit(); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); +#ifdef __APPLE__ + glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); +#endif glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_RESIZABLE, GL_FALSE); From befdc810fb25f3e80166e31fa2fd0f343611ecc6 Mon Sep 17 00:00:00 2001 From: Gabor Papp Date: Thu, 5 Feb 2015 11:37:45 +0100 Subject: [PATCH 2/5] modified test_opengl hardcoded bin paths --- .../protonect/src/test_opengl_depth_packet_processor.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/protonect/src/test_opengl_depth_packet_processor.cpp b/examples/protonect/src/test_opengl_depth_packet_processor.cpp index 479b369ad..51ce61a9f 100644 --- a/examples/protonect/src/test_opengl_depth_packet_processor.cpp +++ b/examples/protonect/src/test_opengl_depth_packet_processor.cpp @@ -77,7 +77,7 @@ int main(int argc, char **argv) { libfreenect2::OpenGLDepthPacketProcessor processor(window, true); processor.setConfiguration(cfg); processor.setFrameListener(&fl); - processor.loadP0TablesFromFiles((binpath + "../p00.bin").c_str(), (binpath + "../p01.bin").c_str(), (binpath + "../p02.bin").c_str()); + processor.loadP0TablesFromFiles((binpath + "p00.bin").c_str(), (binpath + "p01.bin").c_str(), (binpath + "p02.bin").c_str()); processor.load11To16LutFromFile(""); processor.loadXTableFromFile(""); processor.loadZTableFromFile(""); @@ -85,7 +85,7 @@ int main(int argc, char **argv) { libfreenect2::CpuDepthPacketProcessor ref_processor; ref_processor.setConfiguration(cfg); ref_processor.setFrameListener(&fl); - ref_processor.loadP0TablesFromFiles((binpath + "../p00.bin").c_str(), (binpath + "../p01.bin").c_str(), (binpath + "../p02.bin").c_str()); + ref_processor.loadP0TablesFromFiles((binpath + "p00.bin").c_str(), (binpath + "p01.bin").c_str(), (binpath + "p02.bin").c_str()); ref_processor.load11To16LutFromFile(""); ref_processor.loadXTableFromFile(""); ref_processor.loadZTableFromFile(""); @@ -96,7 +96,7 @@ int main(int argc, char **argv) { p.buffer_length = 352*424*10*2; p.buffer = new unsigned char[p.buffer_length]; - loadBufferFromFile(binpath + "../rawir/rawir_4599.bin", p.buffer, p.buffer_length); + loadBufferFromFile(binpath + "rawir.bin", p.buffer, p.buffer_length); libfreenect2::Frame *ir, *depth; cv::Mat cpu_ir, cpu_depth, ogl_ir, ogl_depth; From a86083732de9b1b458f562fb894cac759e9e9a2d Mon Sep 17 00:00:00 2001 From: Gabor Papp Date: Thu, 5 Feb 2015 11:39:46 +0100 Subject: [PATCH 3/5] readded test_opengl to cmake --- examples/protonect/CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/examples/protonect/CMakeLists.txt b/examples/protonect/CMakeLists.txt index 1c29e413d..0b9a26fa1 100644 --- a/examples/protonect/CMakeLists.txt +++ b/examples/protonect/CMakeLists.txt @@ -155,6 +155,14 @@ ADD_DEFINITIONS(-DRESOURCES_INC) ADD_LIBRARY(freenect2 SHARED ${SOURCES}) TARGET_LINK_LIBRARIES(freenect2 ${LIBRARIES}) +ADD_EXECUTABLE(test_opengl + src/test_opengl_depth_packet_processor.cpp +) + +TARGET_LINK_LIBRARIES(test_opengl + freenect2 +) + ADD_EXECUTABLE(Protonect Protonect.cpp ) From 6ee73bd21cdec3c4b851a366d6afda6327bcee82 Mon Sep 17 00:00:00 2001 From: Gabor Papp Date: Thu, 19 Feb 2015 15:30:07 +0100 Subject: [PATCH 4/5] added application to dump input data for test_opengl --- examples/protonect/CMakeLists.txt | 8 ++ examples/protonect/src/test_opengl_dump.cpp | 130 ++++++++++++++++++++ 2 files changed, 138 insertions(+) create mode 100644 examples/protonect/src/test_opengl_dump.cpp diff --git a/examples/protonect/CMakeLists.txt b/examples/protonect/CMakeLists.txt index 0b9a26fa1..8e53ea3ae 100644 --- a/examples/protonect/CMakeLists.txt +++ b/examples/protonect/CMakeLists.txt @@ -163,6 +163,14 @@ TARGET_LINK_LIBRARIES(test_opengl freenect2 ) +ADD_EXECUTABLE(test_opengl_dump + src/test_opengl_depth_packet_processor.cpp +) + +TARGET_LINK_LIBRARIES(test_opengl_dump + freenect2 +) + ADD_EXECUTABLE(Protonect Protonect.cpp ) diff --git a/examples/protonect/src/test_opengl_dump.cpp b/examples/protonect/src/test_opengl_dump.cpp new file mode 100644 index 000000000..d9dc05275 --- /dev/null +++ b/examples/protonect/src/test_opengl_dump.cpp @@ -0,0 +1,130 @@ +/* + * This file is part of the OpenKinect Project. http://www.openkinect.org + * + * Copyright (c) 2014 individual OpenKinect contributors. See the CONTRIB file + * for details. + * + * This code is licensed to you under the terms of the Apache License, version + * 2.0, or, at your option, the terms of the GNU General Public License, + * version 2.0. See the APACHE20 and GPL2 files for the text of the licenses, + * or the following URLs: + * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.gnu.org/licenses/gpl-2.0.txt + * + * If you redistribute this file in source form, modified or unmodified, you + * may: + * 1) Leave this header intact and distribute it under the same terms, + * accompanying it with the APACHE20 and GPL20 files, or + * 2) Delete the Apache 2.0 clause and accompany it with the GPL2 file, or + * 3) Delete the GPL v2 clause and accompany it with the APACHE20 file + * In all cases you must keep the copyright notice intact and include a copy + * of the CONTRIB file. + * + * Binary distributions must follow the binary distribution requirements of + * either License. + */ + +#include +#include + +#include +#include +#include +#include +#include + +static bool data_dumped = false; + +class LIBFREENECT2_API DumpPacketProcessor : public libfreenect2::DepthPacketProcessor +{ +public: + DumpPacketProcessor() {} + + virtual void loadP0TablesFromCommandResponse(unsigned char* buffer, size_t buffer_length) + { + libfreenect2::protocol::P0TablesResponse* p0table = (libfreenect2::protocol::P0TablesResponse*)buffer; + + if(buffer_length < sizeof(libfreenect2::protocol::P0TablesResponse)) + { + std::cerr << "[CpuDepthPacketProcessor::loadP0TablesFromCommandResponse] P0Table response too short!" << std::endl; + return; + } + + std::cerr << "[DumpPacketProcessor::loadP0TablesFromCommandResponse] Exporting p0 tables" << std::endl; + std::ofstream p00out("p00.bin", std::ios::out | std::ios::binary); + p00out.write(reinterpret_cast(p0table->p0table0), 512*424*sizeof(uint16_t)); + p00out.close(); + + std::ofstream p01out("p01.bin", std::ios::out | std::ios::binary); + p01out.write(reinterpret_cast(p0table->p0table1), 512*424*sizeof(uint16_t)); + p01out.close(); + + std::ofstream p02out("p02.bin", std::ios::out | std::ios::binary); + p02out.write(reinterpret_cast(p0table->p0table2), 512*424*sizeof(uint16_t)); + p02out.close(); + } + + virtual void process(const libfreenect2::DepthPacket &packet) + { + if(!::data_dumped && (packet.sequence > 16)) + { + std::cerr << "[DumpPacketProcessor::process] Exporting depth packet " << packet.sequence << std::endl; + std::ofstream rawIrOut("rawir.bin", std::ios::out | std::ios::binary); + rawIrOut.write(reinterpret_cast(packet.buffer), packet.buffer_length); + rawIrOut.close(); + ::data_dumped = true; + } + } +}; + +class LIBFREENECT2_API DumpPacketPipeline : public libfreenect2::BasePacketPipeline +{ +protected: + virtual libfreenect2::DepthPacketProcessor *createDepthPacketProcessor() + { + DumpPacketProcessor *depth_processor = new DumpPacketProcessor(); + return depth_processor; + } + +public: + DumpPacketPipeline() + { + initialize(); + } +}; + +int main(int argc, char **argv) +{ + std::string program_path(argv[0]); + size_t executable_name_idx = program_path.rfind("test_opengl"); + std::string binpath = "./"; + + if(executable_name_idx != std::string::npos) + { + binpath = program_path.substr(0, executable_name_idx); + } + + libfreenect2::Freenect2 freenect2; + libfreenect2::Freenect2Device *dev; + dev = freenect2.openDefaultDevice(new DumpPacketPipeline()); + + if(dev == 0) + { + std::cout << "no device connected or failure opening the default one!" << std::endl; + return -1; + } + + dev->start(); + + while(!data_dumped) + { + std::cerr << "."; + libfreenect2::this_thread::sleep_for(libfreenect2::chrono::milliseconds(100)); + } + std::cerr << std::endl; + + dev->stop(); + dev->close(); + + return 0; +} From d78ba6eb3918ad844e0547a4111beed53feb49ea Mon Sep 17 00:00:00 2001 From: Gabor Papp Date: Sun, 22 Mar 2015 17:08:17 +0100 Subject: [PATCH 5/5] fixed test_opengl_dump cmake source reported by @bellekci --- examples/protonect/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/protonect/CMakeLists.txt b/examples/protonect/CMakeLists.txt index 8e53ea3ae..7e352a8d5 100644 --- a/examples/protonect/CMakeLists.txt +++ b/examples/protonect/CMakeLists.txt @@ -164,7 +164,7 @@ TARGET_LINK_LIBRARIES(test_opengl ) ADD_EXECUTABLE(test_opengl_dump - src/test_opengl_depth_packet_processor.cpp + src/test_opengl_dump.cpp ) TARGET_LINK_LIBRARIES(test_opengl_dump