[main] * Main application entry point. * * Accepted argumemnts: * - cpu Perform depth processing with the CPU. * - gl Perform depth processing with OpenGL. * - cl Perform depth processing with OpenCL. * - Serial number of the device to open. * - -noviewer Disable viewer window. */
| 108 | * - -noviewer Disable viewer window. |
| 109 | */ |
| 110 | int main(int argc, char *argv[]) |
| 111 | /// [main] |
| 112 | { |
| 113 | std::string program_path(argv[0]); |
| 114 | std::cerr << "Version: " << LIBFREENECT2_VERSION << std::endl; |
| 115 | std::cerr << "Environment variables: LOGFILE=<protonect.log>" << std::endl; |
| 116 | std::cerr << "Usage: " << program_path << " [-gpu=<id>] [gl | cl | clkde | cuda | cudakde | cpu] [<device serial>]" << std::endl; |
| 117 | std::cerr << " [-noviewer] [-norgb | -nodepth] [-help] [-version]" << std::endl; |
| 118 | std::cerr << " [-frames <number of frames to process>]" << std::endl; |
| 119 | std::cerr << "To pause and unpause: pkill -USR1 Protonect" << std::endl; |
| 120 | size_t executable_name_idx = program_path.rfind("Protonect"); |
| 121 | |
| 122 | std::string binpath = "/"; |
| 123 | |
| 124 | if(executable_name_idx != std::string::npos) |
| 125 | { |
| 126 | binpath = program_path.substr(0, executable_name_idx); |
| 127 | } |
| 128 | |
| 129 | #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) |
| 130 | // avoid flooing the very slow Windows console with debug messages |
| 131 | libfreenect2::setGlobalLogger(libfreenect2::createConsoleLogger(libfreenect2::Logger::Info)); |
| 132 | #else |
| 133 | // create a console logger with debug level (default is console logger with info level) |
| 134 | /// [logging] |
| 135 | libfreenect2::setGlobalLogger(libfreenect2::createConsoleLogger(libfreenect2::Logger::Debug)); |
| 136 | /// [logging] |
| 137 | #endif |
| 138 | /// [file logging] |
| 139 | MyFileLogger *filelogger = new MyFileLogger(getenv("LOGFILE")); |
| 140 | if (filelogger->good()) |
| 141 | libfreenect2::setGlobalLogger(filelogger); |
| 142 | else |
| 143 | delete filelogger; |
| 144 | /// [file logging] |
| 145 | |
| 146 | /// [context] |
| 147 | libfreenect2::Freenect2 freenect2; |
| 148 | libfreenect2::Freenect2Device *dev = 0; |
| 149 | libfreenect2::PacketPipeline *pipeline = 0; |
| 150 | /// [context] |
| 151 | |
| 152 | std::string serial = ""; |
| 153 | |
| 154 | bool viewer_enabled = true; |
| 155 | bool enable_rgb = true; |
| 156 | bool enable_depth = true; |
| 157 | int deviceId = -1; |
| 158 | size_t framemax = -1; |
| 159 | |
| 160 | for(int argI = 1; argI < argc; ++argI) |
| 161 | { |
| 162 | const std::string arg(argv[argI]); |
| 163 | |
| 164 | if(arg == "-help" || arg == "--help" || arg == "-h" || arg == "-v" || arg == "--version" || arg == "-version") |
| 165 | { |
| 166 | // Just let the initial lines display at the beginning of main |
| 167 | return 0; |
nothing calls this directly
no test coverage detected