int main (int argc, char* argv[]) { int device = 0; cuda::setDevice (device); cuda::printShortCudaDeviceInfo (device); if(cuda::checkIfPreFermiGPU(device)) return std::cout << std::endl << "Kinfu is not supported for pre-Fermi GPU architectures, and not built for them by default. Exiting..." << std::endl, 1; OpenNISource capture; if(argc == 2) capture.open(string(argv[1])); else { capture.open(0); } //capture.open (0); //capture.open("/home/tristan/kintinuous.tigelbri/build/Captured.oni"); //capture.open("/home/tristan/home.oni"); KinFuApp app (capture); // executing try { app.execute (); } catch (const std::bad_alloc& /*e*/) { std::cout << "Bad alloc" << std::endl; } catch (const std::exception& /*e*/) { std::cout << "Exception" << std::endl; } return 0; }
int main (int argc, char* argv[]) { kfusion::Options* options; try { // Parse command line arguments options = new kfusion::Options(argc, argv); // Exit if options had to generate a usage message // (this means required parameters are missing) if ( options->printUsage() ) { return 0; } ::std::cout << *options << ::std::endl; } catch(exception& e) { cout << e.what() << endl; return 0; } OpenNISource capture; string device = options->getInputDevice(); if(device.find_first_not_of("0123456789") == std::string::npos) { cuda::setDevice (atoi(device.c_str())); cuda::printShortCudaDeviceInfo (atoi(device.c_str())); if(cuda::checkIfPreFermiGPU(atoi(device.c_str()))) return std::cout << std::endl << "Kinfu is not supported for pre-Fermi GPU architectures, and not built for them by default. Exiting..." << std::endl, 1; capture.open(atoi(device.c_str())); } else { capture.open(device); capture.triggerPause(); } KinFuApp app (capture, options); // executing try { app.execute (); } catch (const std::bad_alloc& /*e*/) { std::cout << "Bad alloc" << std::endl; } catch (const std::exception& /*e*/) { std::cout << "Exception" << std::endl; } return 0; }
static void keyboard_callback (const visualization::KeyboardEvent &e, void *cookie) { KinFuApp* app = reinterpret_cast<KinFuApp*> (cookie); int key = e.getKeyCode (); if (e.keyUp ()) switch (key) { case 27: app->exit_ = true; break; case (int)'t': case (int)'T': app->scan_ = true; break; case (int)'a': case (int)'A': app->scan_mesh_ = true; break; case (int)'h': case (int)'H': app->printHelp (); break; case (int)'m': case (int)'M': app->scene_cloud_view_.toggleExtractionMode (); break; case (int)'n': case (int)'N': app->scene_cloud_view_.toggleNormals (); break; case (int)'c': case (int)'C': app->scene_cloud_view_.clearClouds (true); break; case (int)'i': case (int)'I': app->toggleIndependentCamera (); break; case (int)'b': case (int)'B': app->scene_cloud_view_.toggleCube(app->kinfu_.volume().getSize()); break; case (int)'7': case (int)'8': app->writeMesh (key - (int)'0'); break; case (int)'1': case (int)'2': case (int)'3': app->writeCloud (key - (int)'0'); break; case '*': app->image_view_.toggleImagePaint (); break; case (int)'x': case (int)'X': app->scan_volume_ = !app->scan_volume_; cout << endl << "Volume scan: " << (app->scan_volume_ ? "enabled" : "disabled") << endl << endl; break; case (int)'v': case (int)'V': cout << "Saving TSDF volume to tsdf_volume.dat ... " << flush; app->tsdf_volume_.save ("tsdf_volume.dat", true); cout << "done [" << app->tsdf_volume_.size () << " voxels]" << endl; cout << "Saving TSDF volume cloud to tsdf_cloud.pcd ... " << flush; pcl::io::savePCDFile<pcl::PointXYZI> ("tsdf_cloud.pcd", *app->tsdf_cloud_ptr_, true); cout << "done [" << app->tsdf_cloud_ptr_->size () << " points]" << endl; break; default: break; } }
int main (int argc, char* argv[]) { if (pc::find_switch (argc, argv, "--help") || pc::find_switch (argc, argv, "-h")) return print_cli_help (); int device = 0; pc::parse_argument (argc, argv, "-gpu", device); pcl::gpu::setDevice (device); pcl::gpu::printShortCudaDeviceInfo (device); // if (checkIfPreFermiGPU(device)) // return cout << endl << "Kinfu is supported only for Fermi and Kepler arhitectures. It is not even compiled for pre-Fermi by default. Exiting..." << endl, 1; boost::shared_ptr<pcl::Grabber> capture; bool triggered_capture = false; std::string eval_folder, match_file, openni_device, oni_file, pcd_dir; try { if (pc::parse_argument (argc, argv, "-dev", openni_device) > 0) { capture.reset (new pcl::OpenNIGrabber (openni_device)); } else if (pc::parse_argument (argc, argv, "-oni", oni_file) > 0) { triggered_capture = true; bool repeat = false; // Only run ONI file once capture.reset (new pcl::ONIGrabber (oni_file, repeat, ! triggered_capture)); } else if (pc::parse_argument (argc, argv, "-pcd", pcd_dir) > 0) { float fps_pcd = 15.0f; pc::parse_argument (argc, argv, "-pcd_fps", fps_pcd); vector<string> pcd_files = getPcdFilesInDir(pcd_dir); // Sort the read files by name sort (pcd_files.begin (), pcd_files.end ()); capture.reset (new pcl::PCDGrabber<pcl::PointXYZ> (pcd_files, fps_pcd, false)); } else if (pc::parse_argument (argc, argv, "-eval", eval_folder) > 0) { //init data source latter pc::parse_argument (argc, argv, "-match_file", match_file); } else { capture.reset( new pcl::OpenNIGrabber() ); //triggered_capture = true; capture.reset( new pcl::ONIGrabber("d:/onis/20111013-224932.oni", true, ! triggered_capture) ); //triggered_capture = true; capture.reset( new pcl::ONIGrabber("d:/onis/reg20111229-180846.oni, true, ! triggered_capture) ); //triggered_capture = true; capture.reset( new pcl::ONIGrabber("/media/Main/onis/20111013-224932.oni", true, ! triggered_capture) ); //triggered_capture = true; capture.reset( new pcl::ONIGrabber("d:/onis/20111013-224551.oni", true, ! triggered_capture) ); //triggered_capture = true; capture.reset( new pcl::ONIGrabber("d:/onis/20111013-224719.oni", true, ! triggered_capture) ); } } catch (const pcl::PCLException& /*e*/) { return cout << "Can't open depth source" << endl, -1; } float volume_size = 3.f; pc::parse_argument (argc, argv, "-volume_size", volume_size); int icp = 1, visualization = 1; std::vector<float> depth_intrinsics; pc::parse_argument (argc, argv, "--icp", icp); pc::parse_argument (argc, argv, "--viz", visualization); KinFuApp app (*capture, volume_size, icp, visualization); if (pc::parse_argument (argc, argv, "-eval", eval_folder) > 0) app.toggleEvaluationMode(eval_folder, match_file); if (pc::find_switch (argc, argv, "--current-cloud") || pc::find_switch (argc, argv, "-cc")) app.initCurrentFrameView (); if (pc::find_switch (argc, argv, "--save-views") || pc::find_switch (argc, argv, "-sv")) app.image_view_.accumulate_views_ = true; //will cause bad alloc after some time if (pc::find_switch (argc, argv, "--registration") || pc::find_switch (argc, argv, "-r")) app.initRegistration(); if (pc::find_switch (argc, argv, "--integrate-colors") || pc::find_switch (argc, argv, "-ic")) app.toggleColorIntegration(); if (pc::find_switch (argc, argv, "--scale-truncation") || pc::find_switch (argc, argv, "-st")) app.enableTruncationScaling(); if (pc::parse_x_arguments (argc, argv, "--depth-intrinsics", depth_intrinsics) > 0) { if ((depth_intrinsics.size() == 4) || (depth_intrinsics.size() == 2)) { app.setDepthIntrinsics(depth_intrinsics); } else { pc::print_error("Depth intrinsics must be given on the form fx,fy[,cx,cy].\n"); return -1; } } // executing try { app.startMainLoop (triggered_capture); } catch (const pcl::PCLException& /*e*/) { cout << "PCLException" << endl; } catch (const std::bad_alloc& /*e*/) { cout << "Bad alloc" << endl; } catch (const std::exception& /*e*/) { cout << "Exception" << endl; } #ifdef HAVE_OPENCV for (size_t t = 0; t < app.image_view_.views_.size (); ++t) { if (t == 0) { cout << "Saving depth map of first view." << endl; cv::imwrite ("./depthmap_1stview.png", app.image_view_.views_[0]); cout << "Saving sequence of (" << app.image_view_.views_.size () << ") views." << endl; } char buf[4096]; sprintf (buf, "./%06d.png", (int)t); cv::imwrite (buf, app.image_view_.views_[t]); printf ("writing: %s\n", buf); } #endif return 0; }