DAT1::DAT1(VFS* vfs, const std::string& file) : VFSSource(vfs), m_datpath(file), m_data(vfs->open(file)) { FL_LOG(_log, LMsg("MFFalloutDAT1") << "loading: " << file << " filesize: " << m_data->getDataLength()); m_data->setIndex(0); const uint32_t dircount = m_data->read32Big(); m_data->moveIndex(4*3); FL_LOG(_log, LMsg("MFFalloutDAT1") << "number of directories " << dircount); // Sanity check. Each dir entry needs min. 16 bytes. if( dircount*16 > m_data->getDataLength() ) { throw InvalidFormat("directory count larger than filesize."); } std::list<std::string> dir_names; for (uint32_t i = 0; i < dircount; ++i) { std::string name = readString(); if (name == ".") { name = ""; } dir_names.push_back(name); } for(std::list<std::string>::iterator i= dir_names.begin(); i!= dir_names.end(); ++i) loadFileList(*i); }
mainWindow::mainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::mainWindow) { ui->setupUi(this); sc = new QScrollArea(this); m_label = new QLabel("", this); m_image = new QImage(); m_animated = new QMovie(m_label); m_current = -1; QStringList args = QApplication::arguments(); if(args.count() > 1) { loadFileList(args); } sc->setWidget(m_label); sc->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); sc->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); this->setCentralWidget(sc); this->resize(800, 600); m_oldSize = this->size(); setupConnexions(); }
bool SRTMProvider::fillTile(int index, SRTMTile **tile){ bool tileFilled = false; QString fileName; // Name incl. Pfad (wird aus _cachedir und Index erstellt) loadFileList(); // per loadFilelist(): fileListe vorhanden? falls nicht: erstellen! if (fileList.contains(index)){ fileName = _cachedir+fileList[index]; QFile zipFile(fileName); int fileIndex = index; //Bugfixversuch: fileIndex if(!zipFile.open(QIODevice::ReadOnly) && !downloadZipFile(fileIndex, fileName, zipFile)){ //Bugfixversuch: fileIndex return tileFilled; } tileFilled = (*tile)->fillTile(fileName); } return tileFilled; }
void VFH::loadTrainingData() { if (!boost::filesystem::exists ("training_data.h5") || !boost::filesystem::exists ("training_data.list")) { pcl::console::print_error ("Could not find training data models files %s and %s!\n", training_data_h5_file_name.c_str (), training_data_list_file_name.c_str ()); return; } else { loadFileList (models, training_data_list_file_name); flann::load_from_file (data, training_data_h5_file_name, "training_data"); pcl::console::print_highlight ("Training data found. Loaded %d VFH models from %s/%s.\n", (int)data.rows, training_data_h5_file_name.c_str (), training_data_list_file_name.c_str ()); } if (!boost::filesystem::exists (kdtree_idx_file_name)) { pcl::console::print_error ("Could not find kd-tree index in file %s!", kdtree_idx_file_name.c_str ()); return; } else { flann::Index<flann::ChiSquareDistance<float> > index (data, flann::SavedIndexParams (kdtree_idx_file_name)); index.buildIndex (); } }
void soundKonverter::setupActions() { KStandardAction::quit( this, SLOT(close()), actionCollection() ); KStandardAction::preferences( this, SLOT(showConfigDialog()), actionCollection() ); KAction *logviewer = actionCollection()->addAction("logviewer"); logviewer->setText(i18n("View logs...")); logviewer->setIcon(KIcon("view-list-text")); connect( logviewer, SIGNAL(triggered()), this, SLOT(showLogViewer()) ); KAction *replaygainscanner = actionCollection()->addAction("replaygainscanner"); replaygainscanner->setText(i18n("Replay Gain tool...")); replaygainscanner->setIcon(KIcon("soundkonverter-replaygain")); connect( replaygainscanner, SIGNAL(triggered()), this, SLOT(showReplayGainScanner()) ); KAction *aboutplugins = actionCollection()->addAction("aboutplugins"); aboutplugins->setText(i18n("About plugins...")); aboutplugins->setIcon(KIcon("preferences-plugin")); connect( aboutplugins, SIGNAL(triggered()), this, SLOT(showAboutPlugins()) ); KAction *add_files = actionCollection()->addAction("add_files"); add_files->setText(i18n("Add files...")); add_files->setIcon(KIcon("audio-x-generic")); connect( add_files, SIGNAL(triggered()), m_view, SLOT(showFileDialog()) ); KAction *add_folder = actionCollection()->addAction("add_folder"); add_folder->setText(i18n("Add folder...")); add_folder->setIcon(KIcon("folder")); connect( add_folder, SIGNAL(triggered()), m_view, SLOT(showDirDialog()) ); KAction *add_audiocd = actionCollection()->addAction("add_audiocd"); add_audiocd->setText(i18n("Add CD tracks...")); add_audiocd->setIcon(KIcon("media-optical-audio")); connect( add_audiocd, SIGNAL(triggered()), m_view, SLOT(showCdDialog()) ); KAction *add_url = actionCollection()->addAction("add_url"); add_url->setText(i18n("Add url...")); add_url->setIcon(KIcon("network-workgroup")); connect( add_url, SIGNAL(triggered()), m_view, SLOT(showUrlDialog()) ); KAction *add_playlist = actionCollection()->addAction("add_playlist"); add_playlist->setText(i18n("Add playlist...")); add_playlist->setIcon(KIcon("view-media-playlist")); connect( add_playlist, SIGNAL(triggered()), m_view, SLOT(showPlaylistDialog()) ); KAction *load = actionCollection()->addAction("load"); load->setText(i18n("Load file list")); load->setIcon(KIcon("document-open")); connect( load, SIGNAL(triggered()), m_view, SLOT(loadFileList()) ); KAction *save = actionCollection()->addAction("save"); save->setText(i18n("Save file list")); save->setIcon(KIcon("document-save")); connect( save, SIGNAL(triggered()), m_view, SLOT(saveFileList()) ); actionCollection()->addAction("start", m_view->start()); actionCollection()->addAction("stop_menu", m_view->stopMenu()); }
PlotAlignmentValidation::PlotAlignmentValidation(const char *inputFile,std::string legendName, int lineColor, int lineStyle) { setOutputDir("$TMPDIR"); setTreeBaseDir(); sourcelist = NULL; loadFileList( inputFile, legendName, lineColor, lineStyle); moreThanOneSource=false; }
//------------------------------------------------------------------------------ PlotAlignmentValidation::PlotAlignmentValidation(const char *inputFile,std::string legendName, int lineColor, int lineStyle) { setOutputDir("$TMPDIR"); setTreeBaseDir(); sourcelist = NULL; loadFileList( inputFile, legendName, lineColor, lineStyle); moreThanOneSource=false; useFit_ = false; // Force ROOT to use scientific notation even with smaller datasets TGaxis::SetMaxDigits(4); // (This sets a static variable: correct in .eps-images but must be set // again manually when viewing the .root-files) }
CoaDebugSettingsModel::CoaDebugSettingsModel ( QObject *parent ) :CoaAbstractItemModel ( parent ) { // BEGIN; m_columns = 2; loadFileList(); connect (CoaDebugThread::getInstance(), SIGNAL(gotNewFileForDebugging(const QString, const int)), this, SLOT (setNewFile(const QString, const int)), Qt::QueuedConnection ); }
fcitx::FileListModel::FileListModel(QObject *parent) : QAbstractListModel(parent) { loadFileList(); }
FileListModel::FileListModel(QObject* parent): QAbstractListModel(parent) ,m_langType(LPLT_Simplified) { loadFileList(); }
int main (int argc, char** argv) { PointCloudT::Ptr cloud (new PointCloudT); PointCloudT::Ptr new_cloud (new PointCloudT); bool new_cloud_available_flag = false; //pcl::Grabber* grab = new pcl::OpenNIGrabber (); PointCloudT::Ptr ddd; boost::function<void (const PointCloudT::ConstPtr&)> f = boost::bind(&grabberCallback, _1, cloud, &new_cloud_available_flag); grab->registerCallback (f); viewer->registerKeyboardCallback(keyboardEventOccurred); grab->start (); bool first_time = true; FILE* objects; objects = fopen ("objects.txt","a"); while(!new_cloud_available_flag) boost::this_thread::sleep(boost::posix_time::milliseconds(1)); new_cloud_available_flag=false; //////////////////// // invert correction //////////////////// Eigen::Matrix4f transMat = Eigen::Matrix4f::Identity(); transMat (1,1) = -1; //////////////////// // pass filter //////////////////// PointCloudT::Ptr passed_cloud; pcl::PassThrough<PointT> pass; passed_cloud = boost::shared_ptr<PointCloudT>(new PointCloudT); //////////////////// // voxel grid //////////////////// PointCloudT::Ptr voxelized_cloud; voxelized_cloud = boost::shared_ptr<PointCloudT>(new PointCloudT); pcl::VoxelGrid<PointT> vg; vg.setLeafSize (0.001, 0.001, 0.001); //////////////////// // sac segmentation //////////////////// PointCloudT::Ptr cloud_f; PointCloudT::Ptr cloud_plane; PointCloudT::Ptr cloud_filtered; cloud_f = boost::shared_ptr<PointCloudT>(new PointCloudT); cloud_plane = boost::shared_ptr<PointCloudT> (new PointCloudT); cloud_filtered = boost::shared_ptr<PointCloudT> (new PointCloudT); pcl::SACSegmentation<PointT> seg; pcl::PointIndices::Ptr inliers (new pcl::PointIndices); pcl::ModelCoefficients::Ptr coefficients (new pcl::ModelCoefficients); seg.setOptimizeCoefficients (true); seg.setModelType (pcl::SACMODEL_PLANE); seg.setMethodType (pcl::SAC_RANSAC); seg.setMaxIterations (100); seg.setDistanceThreshold (0.02); //////////////////// // euclidean clustering //////////////////// std::vector<pcl::PointIndices> cluster_indices; std::vector<PointCloudT::Ptr> extracted_clusters; pcl::search::KdTree<PointT>::Ptr eucl_tree (new pcl::search::KdTree<PointT>); pcl::EuclideanClusterExtraction<PointT> ec; ec.setClusterTolerance (0.04); ec.setMinClusterSize (100); ec.setMaxClusterSize (25000); ec.setSearchMethod (eucl_tree); PointCloudT::Ptr cloud_cluster; //////////////////// // vfh estimate //////////////////// pcl::NormalEstimation<PointT, pcl::Normal> ne; pcl::search::KdTree<PointT>::Ptr vfh_tree1 (new pcl::search::KdTree<PointT> ()); pcl::VFHEstimation<PointT, pcl::Normal, pcl::VFHSignature308> vfh; pcl::search::KdTree<PointT>::Ptr vfh_tree2 (new pcl::search::KdTree<PointT> ()); std::vector<pcl::PointCloud<pcl::VFHSignature308>::Ptr> computed_vfhs; ne.setSearchMethod (vfh_tree1); ne.setRadiusSearch (0.05); vfh.setSearchMethod (vfh_tree2); vfh.setRadiusSearch (0.05); pcl::PointCloud<pcl::Normal>::Ptr normals; pcl::PointCloud<pcl::VFHSignature308>::Ptr vfhs; //////////////////// // nearest neighbour //////////////////// int k = 6; std::string kdtree_idx_file_name = "kdtree.idx"; std::string training_data_h5_file_name = "training_data.h5"; std::string training_data_list_file_name = "training_data.list"; // std::vector<vfh_model> models; // flann::Matrix<float> data; // loadFileList (models, training_data_list_file_name); // flann::load_from_file (data, // training_data_h5_file_name, // "training_data"); // // flann::Index<flann::ChiSquareDistance<float> > index (data, // flann::SavedIndexParams // ("kdtree.idx")); //////////////////// // process nearest neighbour //////////////////// std::vector<hypothesis> final_hypothesis; final_hypothesis.clear(); double last = pcl::getTime(); while (! viewer->wasStopped()) { if (new_cloud_available_flag) { new_cloud_available_flag = false; double now = pcl::getTime(); //////////////////// // pass filter //////////////////// //passed_cloud = boost::shared_ptr<PointCloudT>(new PointCloudT); //////////////////// // voxel grid //////////////////// //voxelized_cloud = boost::shared_ptr<PointCloudT>(new PointCloudT); //////////////////// // sac segmentation //////////////////// //cloud_f = boost::shared_ptr<PointCloudT>(new PointCloudT); //cloud_plane = boost::shared_ptr<PointCloudT> (new PointCloudT); //cloud_filtered = boost::shared_ptr<PointCloudT> (new PointCloudT); //////////////////// // euclidean clustering //////////////////// extracted_clusters.clear(); cluster_indices.clear(); //////////////////// // vfh estimate //////////////////// computed_vfhs.clear(); //////////////////// // nearest neighbour //////////////////// cloud_mutex.lock(); //displayCloud(viewer,cloud); boost::thread displayCloud_(displayCloud,viewer,cloud); if(now-last > 13 || first_time) { first_time = false; last=now; //////////////////// // invert correction //////////////////// pcl::transformPointCloud(*cloud,*new_cloud,transMat); //////////////////// // pass filter //////////////////// pass.setInputCloud (new_cloud); pass.setFilterFieldName ("x"); pass.setFilterLimits (-0.5, 0.5); //pass.setFilterLimitsNegative (true); pass.filter (*passed_cloud); //////////////////// // voxel grid //////////////////// vg.setInputCloud (passed_cloud); vg.filter (*voxelized_cloud); //////////////////// // sac segmentation //////////////////// *cloud_filtered = *voxelized_cloud; int i=0, nr_points = (int) voxelized_cloud->points.size (); while (cloud_filtered->points.size () > 0.3 * nr_points) { // Segment the largest planar component from the remaining cloud seg.setInputCloud (cloud_filtered); seg.segment (*inliers, *coefficients); if (inliers->indices.size () == 0) { std::cout << "Couldnt estimate a planar model for the dataset.\n"; break; } // Extract the planar inliers from the input cloud pcl::ExtractIndices<PointT> extract; extract.setInputCloud (cloud_filtered); extract.setIndices (inliers); extract.setNegative (false); // Get the points associated with the planar surface extract.filter (*cloud_plane); // Remove the planar inliers, extract the rest extract.setNegative (true); extract.filter (*cloud_f); *cloud_filtered = *cloud_f; } //////////////////// // euclidean clustering //////////////////// // Creating the KdTree object for the search method of the extraction eucl_tree->setInputCloud (cloud_filtered); ec.setInputCloud (cloud_filtered); ec.extract (cluster_indices); for (std::vector<pcl::PointIndices>::const_iterator it = cluster_indices.begin (); it != cluster_indices.end (); ++it) { //PointCloudT::Ptr cloud_cluster (new PointCloudT); cloud_cluster = boost::shared_ptr<PointCloudT>(new PointCloudT); for (std::vector<int>::const_iterator pit = it->indices.begin (); pit != it->indices.end (); pit++) cloud_cluster->points.push_back (cloud_filtered->points [*pit]); cloud_cluster->width = cloud_cluster->points.size (); cloud_cluster->height = 1; cloud_cluster->is_dense = true; extracted_clusters.push_back(cloud_cluster); } cloud_cluster.reset(); //////////////////// // vfh estimate //////////////////// for (int z=0; z<extracted_clusters.size(); ++z) { vfhs = boost::shared_ptr<pcl::PointCloud<pcl::VFHSignature308> > (new pcl::PointCloud<pcl::VFHSignature308>); normals = boost::shared_ptr<pcl::PointCloud<pcl::Normal> > (new pcl::PointCloud<pcl::Normal>); ne.setInputCloud (extracted_clusters.at(z)); ne.compute (*normals); vfh.setInputCloud (extracted_clusters.at(z)); vfh.setInputNormals (normals); vfh.compute (*vfhs); computed_vfhs.push_back(vfhs); } vfhs.reset(); normals.reset(); //////////////////// // nearest neighbour //////////////////// std::vector<vfh_model> models; flann::Matrix<int> k_indices; flann::Matrix<float> k_distances; flann::Matrix<float> data; loadFileList (models, training_data_list_file_name); flann::load_from_file (data, training_data_h5_file_name, "training_data"); flann::Index<flann::ChiSquareDistance<float> > index (data, flann::SavedIndexParams ("kdtree.idx")); for(int z=0; z<computed_vfhs.size(); ++z) { vfh_model histogram; histogram.second.resize(308); for (size_t i = 0; i < 308; ++i) { histogram.second[i] = computed_vfhs.at(z)->points[0].histogram[i]; } index.buildIndex (); nearestKSearch (index, histogram, k, k_indices, k_distances); hypothesis x; x.distance = k_distances[0][0]; size_t index = models.at(k_indices[0][0]).first.find("_v",5); x.object_name = models.at(k_indices[0][0]).first.substr(5,index-5); ddd = boost::shared_ptr<PointCloudT>(new PointCloudT); pcl::transformPointCloud(*extracted_clusters.at(z),*ddd,transMat); x.cluster = ddd; ddd.reset(); std::string filename =""; filename += "inputcloud_" + boost::lexical_cast<std::string>(j+1); filename += "_" + boost::lexical_cast<std::string>(z) + ".pcd"; x.cluster_name = filename.c_str(); final_hypothesis.push_back(x); x.cluster.reset(); //delete x; // std::string filename =""; // filename += "inputcloud_" + boost::lexical_cast<std::string>(j+1); // filename += "_" + boost::lexical_cast<std::string>(z) + ".pcd"; // const char* filen = filename.c_str(); // fprintf(objects,"%s",filen); // fprintf(objects,"::"); // fprintf(objects,models.at (k_indices[0][0]).first.c_str()); // fprintf(objects,"::"); // fprintf(objects,"%f",k_distances[0][0]); // fprintf(objects,"\n"); } delete[] k_indices.ptr (); delete[] k_distances.ptr (); delete[] data.ptr (); std::cout << final_hypothesis.size() << std::endl; viewer->removeAllShapes(); for(int z=0; z<final_hypothesis.size();++z) { if(final_hypothesis.at(z).distance < 100) { fprintf(objects,"%s",final_hypothesis.at(z).cluster_name.c_str()); fprintf(objects,"::"); fprintf(objects,"%s",final_hypothesis.at(z).object_name.c_str()); fprintf(objects,"::"); fprintf(objects,"%f",final_hypothesis.at(z).distance); fprintf(objects,"\n"); std::stringstream ddd; ddd << final_hypothesis.at(z).object_name; ddd << "\n" << "("; ddd << final_hypothesis.at(z).distance; ddd << ")"; viewer->addText3D(ddd.str().c_str(), final_hypothesis.at(z).cluster->points[0], 0.02,1,1,1, boost::lexical_cast<std::string>(z)); drawBoundingBox(final_hypothesis.at(z).cluster,viewer,z); } } //boost::thread allBoxes_(allBoxes,viewer,final_hypothesis); //allBoxes_.join(); viewer->spinOnce(); final_hypothesis.clear(); j++; } // for(int z=0; z<extracted_clusters.size(); ++z) // { // //viewer->addPointCloud<PointT>(extracted_clusters.at(z), // // boost::lexical_cast<std::string>(z)); // // std::string filename =""; // filename += "inputcloud_" + boost::lexical_cast<std::string>(j); // filename += "_" + boost::lexical_cast<std::string>(z) + ".pcd"; // pcl::io::savePCDFile(filename,*extracted_clusters.at(z),false); // } // for(int z=0; z<computed_vfhs.size(); ++z) // { // //viewer->addPointCloud<PointT>(extracted_clusters.at(z), // // boost::lexical_cast<std::string>(z)); // // std::string filename =""; // filename += "inputcloud_" + boost::lexical_cast<std::string>(j); // filename += "_" + boost::lexical_cast<std::string>(z) + "_vfhs.pcd"; // pcl::io::savePCDFileASCII<pcl::VFHSignature308> (filename, *computed_vfhs.at(z)); // } //viewer->removeAllShapes(); // viewer->removeAllPointClouds(); // viewer->setCameraPosition(0, 0, 0, 0, 0, 1, 0, -1, 0); // pcl::visualization::PointCloudColorHandlerRGBField<PointT> rgb(cloud); // viewer->addPointCloud<PointT>(cloud,rgb,"input_cloud"); // viewer->spinOnce(); //std::cout << final_hypothesis.at(0).cluster->points[0]; //boost::this_thread::sleep(boost::posix_time::milliseconds(10)); displayCloud_.join(); cloud_mutex.unlock(); } } grab->stop(); return 0; }
bool Resource::reset() { unloadAllPakFiles(); Common::FSNode dir(ConfMan.get("path")); if (!dir.exists() || !dir.isDirectory()) error("invalid game path '%s'", dir.getPath().c_str()); if (_vm->game() == GI_KYRA1) { // We only need kyra.dat for the demo. if (_vm->gameFlags().isDemo && !_vm->gameFlags().isTalkie) return true; if (!_vm->gameFlags().isDemo && _vm->gameFlags().isTalkie) { // List of files in the talkie version, which can never be unload. static const char * const list[] = { "ADL.PAK", "CHAPTER1.VRM", "COL.PAK", "FINALE.PAK", "INTRO1.PAK", "INTRO2.PAK", "INTRO3.PAK", "INTRO4.PAK", "MISC.PAK", "SND.PAK", "STARTUP.PAK", "XMI.PAK", "CAVE.APK", "DRAGON1.APK", "DRAGON2.APK", "LAGOON.APK", 0 }; loadProtectedFiles(list); } else { Common::ArchiveMemberList files; _files.listMatchingMembers(files, "*.PAK"); _files.listMatchingMembers(files, "*.APK"); for (Common::ArchiveMemberList::const_iterator i = files.begin(); i != files.end(); ++i) { Common::String name = (*i)->getName(); name.toUppercase(); // No PAK file if (name == "TWMUSIC.PAK") continue; // We need to only load the script archive for the language the user specified if (name == ((_vm->gameFlags().lang == Common::EN_ANY) ? "JMC.PAK" : "EMC.PAK")) continue; Common::Archive *archive = loadArchive(name, *i); if (archive) _files.add(name, archive, 0, false); else error("Couldn't load PAK file '%s'", name.c_str()); } } } else if (_vm->game() == GI_KYRA2) { if (_vm->gameFlags().useInstallerPackage) _files.add("installer", loadInstallerArchive("WESTWOOD", "%03d", 6), 2, false); // mouse pointer, fonts, etc. required for initialization if (_vm->gameFlags().isDemo && !_vm->gameFlags().isTalkie) { loadPakFile("GENERAL.PAK"); } else { loadPakFile("INTROGEN.PAK"); loadPakFile("OTHER.PAK"); } } else if (_vm->game() == GI_KYRA3) { if (_vm->gameFlags().useInstallerPackage) { if (!loadPakFile("WESTWOOD.001")) error("Couldn't load file: 'WESTWOOD.001'"); } if (!loadFileList("FILEDATA.FDT")) error("Couldn't load file: 'FILEDATA.FDT'"); } else if (_vm->game() == GI_LOL) { if (_vm->gameFlags().useInstallerPackage) _files.add("installer", loadInstallerArchive("WESTWOOD", "%d", 0), 2, false); if (!_vm->gameFlags().isTalkie && !_vm->gameFlags().isDemo) { static const char * const list[] = { "GENERAL.PAK", 0 }; loadProtectedFiles(list); } } else { error("Unknown game id: %d", _vm->game()); return false; // for compilers that don't support NORETURN } return true; }
void Finder::findFiles() { if(!QDir(m_targetFolder).mkdir("Pliki_PDF")) { emit finished(false, "Folder \"Pliki_PDF\" już istnieje."); return; } bool isFileListLoaded = loadFileList(); if(!isFileListLoaded) return; if(isFileListLoaded && m_fileList.size() == 0) { removeCopiedFiles(); emit finished(false, "Nie znaleziono pasujących pozycji w harmonogramie."); return; } emit signalProgress( 100, "Określenie liczby plików do przeszukania ..."); QDir dir(m_searchedFolder, QString("*.pdf"), QDir::NoSort, QDir::Files | QDir::NoSymLinks); QDirIterator counterIt(dir, QDirIterator::Subdirectories); filesCounter = 0; while (counterIt.hasNext()) { bool abort = m_abort; if (abort) { removeCopiedFiles(); emit finished(false); return; } filesCounter++; counterIt.next(); } if(filesCounter == 0) { emit finished(false, "Nie znaleziono plików PDF w wybranej lokalizacji."); return; } QStringList indexList; QStringList copiedFilesList; QString renamedFile; int count = 0; QDirIterator finalIt(dir, QDirIterator::Subdirectories); while (finalIt.hasNext()) { bool abort = m_abort; if (abort) { removeCopiedFiles(); emit finished(false); return; } if(m_fileList.contains(QFileInfo(finalIt.filePath()).fileName(), Qt::CaseInsensitive)) { indexList = getFileListIdx(QFileInfo(finalIt.filePath()).fileName()); for(int i = 0; i < indexList.size(); ++i) { renamedFile = renameFile(indexList.at(i).toInt(), QFileInfo(finalIt.filePath()).fileName()); if(!QFile(m_targetFolder + "/Pliki_PDF/" + renamedFile).exists()) { QFile::copy(QFileInfo(finalIt.filePath()).filePath(), m_targetFolder + "/Pliki_PDF/" + renamedFile); copiedFilesList.append(renamedFile); emit itemFound(renamedFile, true); } } } finalIt.next(); count++; emit signalProgress( int((double(count)/double(filesCounter)*100)), "Przeszukiwanie plików: " + QString::number(count) + "/" + QString::number(filesCounter)); } QStringList missedFiless = checkMissingFiles(copiedFilesList); QString information = generateCSV(missedFiless,copiedFilesList); emit finished(true,information); }
int main (int argc, char** argv) { int k = 6; double thresh = DBL_MAX; // No threshold, disabled by default if (argc < 2) { pcl::console::print_error ("Need at least three parameters! Syntax is: %s <query_vfh_model.pcd> [options] {kdtree.idx} {training_data.h5} {training_data.list}\n", argv[0]); pcl::console::print_info (" where [options] are: -k = number of nearest neighbors to search for in the tree (default: "); pcl::console::print_value ("%d", k); pcl::console::print_info (")\n"); pcl::console::print_info (" -thresh = maximum distance threshold for a model to be considered VALID (default: "); pcl::console::print_value ("%f", thresh); pcl::console::print_info (")\n\n"); return (-1); } // this won't be needed for flann > 1.6.10 flann::ObjectFactory<flann::IndexParams, flann_algorithm_t>::instance().register_<flann::LinearIndexParams>(FLANN_INDEX_LINEAR); std::string extension (".pcd"); transform (extension.begin (), extension.end (), extension.begin (), (int(*)(int))tolower); // Load the test histogram std::vector<int> pcd_indices = pcl::console::parse_file_extension_argument (argc, argv, ".pcd"); vfh_model histogram; if (!loadHist (argv[pcd_indices.at (0)], histogram)) { pcl::console::print_error ("Cannot load test file %s\n", argv[pcd_indices.at (0)]); return (-1); } pcl::console::parse_argument (argc, argv, "-thresh", thresh); // Search for the k closest matches pcl::console::parse_argument (argc, argv, "-k", k); pcl::console::print_highlight ("Using "); pcl::console::print_value ("%d", k); pcl::console::print_info (" nearest neighbors.\n"); std::string kdtree_idx_file_name = "kdtree.idx"; std::string training_data_h5_file_name = "training_data.h5"; std::string training_data_list_file_name = "training_data.list"; std::vector<vfh_model> models; flann::Matrix<int> k_indices; flann::Matrix<float> k_distances; flann::Matrix<float> data; // Check if the data has already been saved to disk if (!boost::filesystem::exists ("training_data.h5") || !boost::filesystem::exists ("training_data.list")) { pcl::console::print_error ("Could not find training data models files %s and %s!\n", training_data_h5_file_name.c_str (), training_data_list_file_name.c_str ()); return (-1); } else { loadFileList (models, training_data_list_file_name); flann::load_from_file (data, training_data_h5_file_name, "training_data"); pcl::console::print_highlight ("Training data found. Loaded %d VFH models from %s/%s.\n", (int)data.rows, training_data_h5_file_name.c_str (), training_data_list_file_name.c_str ()); } // Check if the tree index has already been saved to disk if (!boost::filesystem::exists (kdtree_idx_file_name)) { pcl::console::print_error ("Could not find kd-tree index in file %s!", kdtree_idx_file_name.c_str ()); return (-1); } else { flann::Index<flann::ChiSquareDistance<float> > index (data, flann::SavedIndexParams ("kdtree.idx")); index.buildIndex (); nearestKSearch (index, histogram, k, k_indices, k_distances); } // Output the results on screen pcl::console::print_highlight ("The closest %d neighbors for %s are:\n", k, argv[pcd_indices[0]]); for (int i = 0; i < k; ++i) pcl::console::print_info (" %d - %s (%d) with a distance of: %f\n", i, models.at (k_indices[0][i]).first.c_str (), k_indices[0][i], k_distances[0][i]); // Load the results pcl::visualization::PCLVisualizer p (argc, argv, "VFH Cluster Classifier"); int y_s = (int)floor (sqrt ((double)k)); int x_s = y_s + (int)ceil ((k / (double)y_s) - y_s); double x_step = (double)(1 / (double)x_s); double y_step = (double)(1 / (double)y_s); pcl::console::print_highlight ("Preparing to load "); pcl::console::print_value ("%d", k); pcl::console::print_info (" files ("); pcl::console::print_value ("%d", x_s); pcl::console::print_info ("x"); pcl::console::print_value ("%d", y_s); pcl::console::print_info (" / "); pcl::console::print_value ("%f", x_step); pcl::console::print_info ("x"); pcl::console::print_value ("%f", y_step); pcl::console::print_info (")\n"); int viewport = 0, l = 0, m = 0; for (int i = 0; i < k; ++i) { std::string cloud_name = models.at (k_indices[0][i]).first; boost::replace_last (cloud_name, "_vfh", ""); p.createViewPort (l * x_step, m * y_step, (l + 1) * x_step, (m + 1) * y_step, viewport); l++; if (l >= x_s) { l = 0; m++; } sensor_msgs::PointCloud2 cloud; pcl::console::print_highlight (stderr, "Loading "); pcl::console::print_value (stderr, "%s ", cloud_name.c_str ()); if (pcl::io::loadPCDFile (cloud_name, cloud) == -1) break; // Convert from blob to PointCloud pcl::PointCloud<pcl::PointXYZ> cloud_xyz; pcl::fromROSMsg (cloud, cloud_xyz); if (cloud_xyz.points.size () == 0) break; pcl::console::print_info ("[done, "); pcl::console::print_value ("%d", (int)cloud_xyz.points.size ()); pcl::console::print_info (" points]\n"); pcl::console::print_info ("Available dimensions: "); pcl::console::print_value ("%s\n", pcl::getFieldsList (cloud).c_str ()); // Demean the cloud Eigen::Vector4f centroid; pcl::compute3DCentroid (cloud_xyz, centroid); pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_xyz_demean (new pcl::PointCloud<pcl::PointXYZ>); pcl::demeanPointCloud<pcl::PointXYZ> (cloud_xyz, centroid, *cloud_xyz_demean); // Add to renderer* p.addPointCloud (cloud_xyz_demean, cloud_name, viewport); // Check if the model found is within our inlier tolerance std::stringstream ss; ss << k_distances[0][i]; if (k_distances[0][i] > thresh) { p.addText (ss.str (), 20, 30, 1, 0, 0, ss.str (), viewport); // display the text with red // Create a red line pcl::PointXYZ min_p, max_p; pcl::getMinMax3D (*cloud_xyz_demean, min_p, max_p); std::stringstream line_name; line_name << "line_" << i; p.addLine (min_p, max_p, 1, 0, 0, line_name.str (), viewport); p.setShapeRenderingProperties (pcl::visualization::PCL_VISUALIZER_LINE_WIDTH, 5, line_name.str (), viewport); } else p.addText (ss.str (), 20, 30, 0, 1, 0, ss.str (), viewport); // Increase the font size for the score* p.setShapeRenderingProperties (pcl::visualization::PCL_VISUALIZER_FONT_SIZE, 18, ss.str (), viewport); // Add the cluster name p.addText (cloud_name, 20, 10, cloud_name, viewport); } // Add coordianate systems to all viewports p.addCoordinateSystem (0.1, 0); p.spin (); return (0); }