| 350 | } |
| 351 | |
| 352 | void VisualizerWindow::openFile(const QString& filename) { |
| 353 | play(false); // stop playback. |
| 354 | |
| 355 | if (!filename.isNull()) { |
| 356 | QString title = "Semantic SuMa"; |
| 357 | title.append(" - "); |
| 358 | QStringList parts = filename.split("/"); |
| 359 | title.append(QString::fromStdString(FileUtil::dirName(filename.toStdString()))); |
| 360 | setWindowTitle(title); |
| 361 | |
| 362 | std::shared_ptr<Model> model; |
| 363 | ui_.wCanvas->setRobotModel(model); |
| 364 | |
| 365 | std::string extension = "INVALID"; |
| 366 | |
| 367 | QFileInfo file_info(filename); |
| 368 | if (file_info.isDir()) { |
| 369 | QDir directory(filename); |
| 370 | QStringList files = directory.entryList(QDir::NoFilter, QDir::Name); |
| 371 | |
| 372 | std::map<std::string, int32_t> suffix_count; |
| 373 | for (int32_t i = 0; i < files.size(); ++i) { |
| 374 | QFileInfo info(directory.filePath(files[i])); |
| 375 | if (!info.isFile()) continue; |
| 376 | |
| 377 | std::string ext = info.suffix().toStdString(); |
| 378 | if (suffix_count.find(ext) == suffix_count.end()) suffix_count[ext] = 0; |
| 379 | suffix_count[ext] += 1; |
| 380 | } |
| 381 | |
| 382 | if (suffix_count.size() > 0) { |
| 383 | int32_t maxCount = suffix_count.begin()->second; |
| 384 | extension = std::string(".") + suffix_count.begin()->first; |
| 385 | |
| 386 | for (auto& entry : suffix_count) { |
| 387 | if (entry.second > maxCount) { |
| 388 | extension = std::string(".") + entry.first; |
| 389 | maxCount = entry.second; |
| 390 | } |
| 391 | } |
| 392 | |
| 393 | std::cout << "Heuristically found '" << extension << "' as extension." << std::endl; |
| 394 | } |
| 395 | } else if (file_info.isFile()) { |
| 396 | extension = std::string(".") + file_info.suffix().toStdString(); |
| 397 | } |
| 398 | |
| 399 | if (extension == ".bin") { |
| 400 | delete reader_; |
| 401 | KITTIReader* reader_tmp = new KITTIReader(filename.toStdString(), params_, 50); |
| 402 | |
| 403 | ui_.wCanvas->setColorMap(reader_tmp->getColorMap()); // get color map from rangenet |
| 404 | fusion_->setColorMap(reader_tmp->getColorMap()); |
| 405 | |
| 406 | reader_ = reader_tmp; |
| 407 | |
| 408 | scanFrequency = 10.0f; // in Hz. |
| 409 | timer_.setInterval(10); // 1./10. second = 100 msecs. |
no test coverage detected