Esempio n. 1
0
int main (int argc, char** argv)
{
    arg_base::set_help_option("-h");
    arg_parse(argc, argv);
    ntk_debug_level = opt::debug_level();
    cv::setBreakOnError(true);

    QApplication::setGraphicsSystem("raster");
    QApplication app (argc, argv);

    RGBDGrabberFactory grabber_factory;
    RGBDGrabberFactory::Params params;

    if (opt::directory())
        params.directory = opt::directory();

    if (opt::openni())
        params.default_type = RGBDGrabberFactory::OPENNI;

    if (opt::freenect())
        params.default_type = RGBDGrabberFactory::FREENECT;

    if (opt::kin4win())
        params.default_type = RGBDGrabberFactory::KIN4WIN;

    if (opt::softkinetic())
        params.default_type = RGBDGrabberFactory::SOFTKINETIC;

    if (opt::pmd())
        params.default_type = RGBDGrabberFactory::PMD;

    if (opt::calibration_file())
        params.calibration_file = opt::calibration_file();

    if (opt::high_resolution())
        params.high_resolution = true;

    if (opt::sync())
        params.synchronous = true;

    std::vector<RGBDGrabberFactory::GrabberData> grabbers;
    grabbers = grabber_factory.createGrabbers(params);

    if (grabbers.size() < 1)
    {
        QMessageBox::critical(0, "Fatal error",
                                  "Cannot connect to any RGBD device.\n\nPlease check that it is correctly plugged to the computer.");
        return 1;
    }

    RGBDGrabber* grabber = grabbers[0].grabber;
    RGBDProcessor* processor = grabbers[0].processor;

    bool ok = grabber->connectToDevice();
    if (!ok)
    {
        ntk_dbg(0) << "WARNING: connectToDevice failed.";
        return 1;
    }

    RGBDFrameRecorder frame_recorder (opt::dir_prefix());
    frame_recorder.setFrameIndex(opt::first_index());
    frame_recorder.setSaveOnlyRaw(true);
    frame_recorder.setUseBinaryRaw(true);
    frame_recorder.setSavePCLPointCloud(opt::savePCD());

    ObjectDetector detector;

    MeshGenerator* mesh_generator = 0;

    ntk::RGBDCalibrationPtr calib_data = grabber->calibrationData();

    if (calib_data)
    {
        mesh_generator = new MeshGenerator();
    }

    GuiController gui_controller (*grabber, *processor);
    grabber->addEventListener(&gui_controller);
    gui_controller.setFrameRecorder(frame_recorder);
    gui_controller.setObjectDetector(detector);

    if (opt::sync())
        gui_controller.setPaused(true);

    if (mesh_generator)
    {
        mesh_generator->setUseColor(true);
        gui_controller.setMeshGenerator(*mesh_generator);
    }

    grabber->start();

    app.exec();
    delete mesh_generator;
}
Esempio n. 2
0
int main (int argc, char** argv)
{
    arg_base::set_help_option("-h");
    arg_parse(argc, argv);
    ntk_debug_level = opt::debug_level();
    cv::setBreakOnError(true);

    QApplication app (argc, argv);

    // Config dir is supposed to be next to the binaries.
    QDir prev_dir = QDir::current();
    QDir::setCurrent(QApplication::applicationDirPath());

    MultipleGrabber* multi_grabber = new MultipleGrabber();
    MultiKinectScanner scanner;

    RGBDGrabberFactory& grabber_factory = RGBDGrabberFactory::instance();
    RGBDGrabberFactory::Params params;

    if (opt::directory())
        params.directory = opt::directory();

    if (opt::openni())
        params.default_type = RGBDGrabberFactory::OPENNI;

    if (opt::freenect())
        params.default_type = RGBDGrabberFactory::FREENECT;

    if (opt::kin4win())
        params.default_type = RGBDGrabberFactory::KIN4WIN;

    if (opt::softkinetic())
        params.default_type = RGBDGrabberFactory::SOFTKINETIC;

    if (opt::pmd())
        params.default_type = RGBDGrabberFactory::PMD;

    if (opt::calibration_dir())
        params.calibration_dir = opt::calibration_dir();

    if (opt::high_resolution())
        params.high_resolution = true;

    if (opt::no_registration())
        params.hardware_registration = false;

    if (opt::sync())
        params.synchronous = true;

    std::vector<RGBDGrabberFactory::GrabberData> grabbers;
    grabbers = grabber_factory.createGrabbers(params);

    ntk_dbg_print(grabbers.size(), 1);

    for (int i = 0; i < grabbers.size(); ++i)
    {
        RGBDGrabber* grabber = grabbers[i].grabber;       
        bool ok = grabber->connectToDevice();
        if (!ok)
        {
            ntk_dbg(0) << "WARNING: connectToDevice failed.";
            continue;
        }

        multi_grabber->addGrabber(grabber);
        scanner.addGrabber(grabber);
    }

    QDir::setCurrent(prev_dir.absolutePath());

    GuiMultiKinectController* controller = new GuiMultiKinectController(&scanner);
    if (opt::bbox())
    {
        ntk::Rect3f bbox = readBoundingBoxFromYamlFile(opt::bbox());
        controller->setBoundingBox(bbox, true);
    }

    scanner.plugController(controller);
    controller->scanner().calibratorBlock().setCalibrationPattern(0.034, 10, 7);

    if (opt::sync())
        controller->scanner().setPaused(true);

    scanner.start();
    return app.exec();
}
Esempio n. 3
0
int main (int argc, char** argv)
{
    arg_base::set_help_option("-h");
    arg_parse(argc, argv);
    ntk_debug_level = opt::debug_level();
    cv::setBreakOnError(true);

    QApplication::setGraphicsSystem("raster");
    QApplication app (argc, argv);

    RGBDGrabberFactory& grabber_factory = RGBDGrabberFactory::instance();
    RGBDGrabberFactory::Params params;

    if (opt::directory())
        params.directory = opt::directory();

    if (opt::openni())
        params.default_type = RGBDGrabberFactory::OPENNI;

    if (opt::freenect())
        params.default_type = RGBDGrabberFactory::FREENECT;

    if (opt::kin4win())
        params.default_type = RGBDGrabberFactory::KIN4WIN;

    if (opt::softkinetic())
        params.default_type = RGBDGrabberFactory::SOFTKINETIC;

    if (opt::pmd())
        params.default_type = RGBDGrabberFactory::PMD;

    if (opt::calibration_file())
        params.calibration_file = opt::calibration_file();

    if (opt::sync())
        params.synchronous = true;

    std::vector<RGBDGrabberFactory::GrabberData> grabbers;
    grabbers = grabber_factory.createGrabbers(params);

    if (grabbers.size() < 1)
    {
        QMessageBox::critical(0, "Fatal error",
                                  "Cannot connect to any RGBD device.\n\nPlease check that it is correctly plugged to the computer.");
        return 1;
    }

    RGBDGrabber* grabber = grabbers[0].grabber;
    RGBDProcessor* rgbd_processor = grabbers[0].processor;

    bool ok = grabber->connectToDevice();
    if (!ok)
    {
        ntk_dbg(0) << "WARNING: connectToDevice failed.";
        return 1;
    }

    rgbd_processor->setMaxNormalAngle(40);
    rgbd_processor->setFilterFlag(RGBDProcessorFlags::ComputeMapping, true);
    rgbd_processor->setFilterFlag(RGBDProcessorFlags::FilterThresholdDepth, true);
    rgbd_processor->setMinDepth(0.05f);
    rgbd_processor->setMaxDepth(1.5f);

    MeshGenerator* mesh_generator = 0;
    ntk::RGBDCalibrationPtr calib_data = grabber->calibrationData();

    if (calib_data)
    {
        mesh_generator = new MeshGenerator();
    }

    RGBDFrameRecorder frame_recorder (opt::dir_prefix());
    frame_recorder.setFrameIndex(opt::first_index());
    frame_recorder.setSaveOnlyRaw(true);
    frame_recorder.setUseBinaryRaw(true);

    GuiController gui_controller (*grabber, *rgbd_processor);
    grabber->addEventListener(&gui_controller);
    gui_controller.setFrameRecorder(frame_recorder);

    if (opt::sync())
        gui_controller.setPaused(true);

    TableObjectRGBDModeler modeler;
    modeler.setDepthFilling(true);
    modeler.setRemoveSmallStructures(true);

    ModelAcquisitionController* acq_controller = 0;
    acq_controller = new ModelAcquisitionController (gui_controller, modeler);
    acq_controller->setPaused(true);

    IncrementalPoseEstimatorFromImage* pose_estimator = new DummyIncrementalPoseEstimator();

    acq_controller->setPoseEstimator(pose_estimator);
    gui_controller.setModelAcquisitionController(*acq_controller);

    if (mesh_generator)
        gui_controller.setMeshGenerator(*mesh_generator);

    grabber->start();

    app.exec();
    delete mesh_generator;
    delete acq_controller;
}