void Characterization::execute() { Mat img; // load image try { VerboseOutput::println(string("Characterization"), "loading image: " + string(const_cast<char*>(filename->c_str()))); img = imread(const_cast<char*>(filename->c_str()), CV_LOAD_IMAGE_COLOR); VerboseOutput::println(string("Characterization"), "image loaded" ); } catch (Exception& e) { throw runtime_error("Error while reading image"); } // check image if ((img.rows == 0) || (img.cols == 0)) { throw runtime_error("Corrupt Image"); } // execute feature extraction try { list<Feature*>::iterator i; VerboseOutput::println(string("Characterization"), "extract features" ); // iterate through all tasks for(i=tasks.begin(); i != tasks.end(); ++i) { Feature* task = *i; if(canExecute(task)) { VerboseOutput::println(string("Characterization"), "execute task: " + task->getName()); task->execute(img); VerboseOutput::println(string("Characterization"), "persist data from task: " + task->getName()); task->persist(featureFileOutputDirectory); } } VerboseOutput::println(string("Characterization"), "feature extraction finished"); } catch (Exception& ex) { stringstream msg; msg << "Error while executing feature extraction: " << ex.msg; throw runtime_error(msg.str()); } }
AddIndicationCommand::AddIndicationCommand(std::string indicationType, EventSelection &selection) : BasicCommand(getGlobalName(indicationType), selection.getSegment(), std::min(selection.getStartTime(), selection.getNotationStartTime()), std::max(selection.getEndTime(), selection.getNotationEndTime())), m_indicationType(indicationType), m_indicationStart(selection.getNotationStartTime()), m_indicationDuration(selection.getTotalNotationDuration()), m_lastInsertedEvent(0) { if (!canExecute()) { throw CommandFailed //!!! need to use text from trunk/src/gui/editors/notation/NotationView.cpp (but this requires an informal human-readable version of the indication name) (qstrtostr(tr("Can't add identical overlapping indications"))); } }
void NewstuffModelPrivate::installMap() { if ( m_unpackProcess ) { m_unpackProcess->close(); delete m_unpackProcess; m_unpackProcess = 0; } else if ( m_currentFile->fileName().endsWith( QLatin1String( "tar.gz" ) ) && canExecute( "tar" ) ) { m_unpackProcess = new QProcess; QObject::connect( m_unpackProcess, SIGNAL(finished(int)), m_parent, SLOT(contentsListed(int)) ); QStringList arguments = QStringList() << "-t" << "-z" << "-f" << m_currentFile->fileName(); m_unpackProcess->setWorkingDirectory( m_targetDirectory ); m_unpackProcess->start( "tar", arguments ); } else { if ( !m_currentFile->fileName().endsWith( QLatin1String( "tar.gz" ) ) ) { mDebug() << "Can only handle tar.gz files"; } else { mDebug() << "Cannot extract archive: tar executable not found in PATH."; } } }