MnAlgebraicVector SimplexParameters::dirin() const { MnAlgebraicVector dirin(theSimplexParameters.size() - 1); for(unsigned int i = 0; i < theSimplexParameters.size() - 1; i++) { double pbig = theSimplexParameters[0].second(i), plit = pbig; for(unsigned int j = 0; j < theSimplexParameters.size(); j++){ if(theSimplexParameters[j].second(i) < plit) plit = theSimplexParameters[j].second(i); if(theSimplexParameters[j].second(i) > pbig) pbig = theSimplexParameters[j].second(i); } dirin(i) = pbig - plit; } return dirin; }
CELLP readch_f(CELLP arg) { char ch[2] = {0}; int i; FILE* nfp = cur_fpi; ATOMP ap; dirin(arg); ec; if (_isatty(_fileno(cur_fpi))) { i = _getch(); } else { i = fgetc(cur_fpi); } if (i == EOF) { return (CELLP)eofread; } ch[0] = i; ch[1] = '\0'; cur_fpi = nfp; if ((ap = old_atom((STR)ch)) == NULL) { return (CELLP)make_atom((STR)ch); } return (CELLP)ap; }
CELLP dirin_f(CELLP arg) { CELLP cp; if ((cp = dirin(arg)) == (CELLP)nil) { return error(NEA); } return cp; }
void OpticalFlowUI::on_btStart_clicked() { if (m_thread != NULL) { //wake it up or do nothing ui->btPause->setEnabled(true); m_thread->resume(); return; } //check folder if (ui->txtInput->text().isEmpty() || ui->txtOutput->text().isEmpty()) { qDebug() << "input or output directory"; QMessageBox::information(this, "Start", "Cannot start, input folder empty."); return; } QDir dirin(m_inputDir); if (!dirin.exists()) { qDebug() << "Input dir does not exist."; QMessageBox::information(this, "Start", "Extract the video frames first."); return; } //check compute type if (ui->rdGPU->isChecked()) { m_optflowtools->setComputationMod(OpticalFlowTools::GPU); } else if (ui->rdCPU->isChecked()) { m_optflowtools->setComputationMod(OpticalFlowTools::CPU); } else if (ui->rdMatlab->isChecked()) { m_optflowtools->setComputationMod(OpticalFlowTools::Matlab); } //fill vars m_inputDir = ui->txtInput->text(); m_outputDir = ui->txtOutput->text(); //m_optflowtools->computeFlow(img1, img2, flow); //ui->lblFlow->setPixmap(QPixmap::fromImage(flow)); m_thread = new OpticalFlowThread(m_optflowtools, this); m_thread->setInputDir(m_inputDir); m_thread->setOutputDir(m_outputDir); connect(m_thread, &OpticalFlowThread::flowComputed, this, &OpticalFlowUI::handleNewFlow); m_thread->start(); ui->btPause->setEnabled(true); }
CELLP read_f(CELLP arg) { FILE* nfp = cur_fpi; CELLP cp; // ファイルディスクリプタが指定された時 if (dirin(arg) != (CELLP)nil) { ec; cp = read_s(TOP); pushbuf(); cur_fpi = nfp; return cp; } cp = read_s(TOP); return read_s(TOP); }
void OpticalFlowThread::run() { qDebug() << "Optflow thread started."; if (m_inputDir.isEmpty() || m_outputDir.isEmpty()) { qDebug() << "Dirs incorrect."; return; } QDir dirin(m_inputDir); if (!dirin.exists()) { qDebug() << "Input dir does not exist."; return; } QFileInfoList images = dirin.entryInfoList(getSupportedImagesFilter() , QDir::Files , QDir::Name); sortFiles(images); QImage* img1; QImage* img2; QImage* flow; img1 = NULL; img2 = NULL; QString filename1; m_running = true; int counter(0); while (m_alive) { foreach (QFileInfo file, images) { if (m_pause) { m_mutexSleep.lock(); m_condition.wait(&m_mutexSleep); m_mutexSleep.unlock(); } if (!m_alive) { break; } QString filename2 = QString("%1%2").arg(m_inputDir, file.fileName()); //compute optical flow if (img1 == NULL) { img1 = new QImage(filename2); filename1 = filename2; continue; } qDebug() << "image1 : " << filename1 << " image2 : " << filename2; img2 = new QImage(filename2); flow = m_optflowtools->computeFlow(img1, img2 , filename1 , filename2); //emit result float perc = (float)(counter + 1) / (float)images.size() * 100.f; emit flowComputed(img1, img2, flow, ceil(perc)); counter++; //manage images img1 = img2; filename1 = filename2; } emit flowComputed(NULL, NULL, NULL, 100); m_alive = false; } qDebug() << "Optflow thread ended."; m_running = false; }