void KoColor::convertTo(const KoColorSpace * cs) { convertTo(cs, KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags); }
bool convertTo(VideoFormat::PixelFormat fmt) { return convertTo(VideoFormat::pixelFormatToFFmpeg(fmt)); }
bool convertTo(QImage::Format fmt) { return convertTo(VideoFormat::pixelFormatFromImageFormat(fmt)); }
inline void GpuMat::convertTo(OutputArray dst, int rtype, double alpha, Stream& stream) const { convertTo(dst, rtype, alpha, 0.0, stream); }
bool convertTo(const VideoFormat& fmt) { return convertTo(fmt.pixelFormatFFmpeg()); }
inline void GpuMat::convertTo(OutputArray dst, int rtype) const { convertTo(dst, rtype, Stream::Null()); }
inline void GpuMat::convertTo(OutputArray dst, int rtype, double alpha, double beta) const { convertTo(dst, rtype, alpha, beta, Stream::Null()); }
/* dst = src */ void Mat::copyTo( OutputArray _dst ) const { int dtype = _dst.type(); if( _dst.fixedType() && dtype != type() ) { CV_Assert( channels() == CV_MAT_CN(dtype) ); convertTo( _dst, dtype ); return; } if( empty() ) { _dst.release(); return; } if( _dst.isUMat() ) { _dst.create( dims, size.p, type() ); UMat dst = _dst.getUMat(); size_t i, sz[CV_MAX_DIM], dstofs[CV_MAX_DIM], esz = elemSize(); for( i = 0; i < (size_t)dims; i++ ) sz[i] = size.p[i]; sz[dims-1] *= esz; dst.ndoffset(dstofs); dstofs[dims-1] *= esz; dst.u->currAllocator->upload(dst.u, data, dims, sz, dstofs, dst.step.p, step.p); return; } if( dims <= 2 ) { _dst.create( rows, cols, type() ); Mat dst = _dst.getMat(); if( data == dst.data ) return; if( rows > 0 && cols > 0 ) { const uchar* sptr = data; uchar* dptr = dst.data; Size sz = getContinuousSize(*this, dst); size_t len = sz.width*elemSize(); for( ; sz.height--; sptr += step, dptr += dst.step ) memcpy( dptr, sptr, len ); } return; } _dst.create( dims, size, type() ); Mat dst = _dst.getMat(); if( data == dst.data ) return; if( total() != 0 ) { const Mat* arrays[] = { this, &dst }; uchar* ptrs[2]; NAryMatIterator it(arrays, ptrs, 2); size_t sz = it.size*elemSize(); for( size_t i = 0; i < it.nplanes; i++, ++it ) memcpy(ptrs[1], ptrs[0], sz); } }
void H2BGraphicBufferProducer::getFrameTimestamps(FrameEventHistoryDelta* outDelta) { mBase->getFrameTimestamps([outDelta] ( HGraphicBufferProducer::FrameEventHistoryDelta const& tDelta) { convertTo(outDelta, tDelta); }); }
double DoubleRange::value(ConversionMode mode) const { return convertTo(d_value, mode); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); checkDialog c; c.show(); // shortcuts ui->actionOpen->setShortcut(Qt::Key_O | Qt::CTRL); ui->actionChange_directory->setShortcut(Qt::Key_D | Qt::CTRL); ui->actionClose->setShortcut(Qt::Key_Q | Qt::CTRL); ui->actionRun_F5->setShortcut(Qt::Key_F5); ui->actionClear_case_F6->setShortcut(Qt::Key_F6); ui->actionWrite_input_file_F4->setShortcut(Qt::Key_F4); ui->actionCheck->setShortcut(Qt::Key_F7); QSignalMapper *signalMapper = new QSignalMapper(this); for( int index=0; index < ui->output->count() ; ++index ){ QShortcut *shortcut =new QShortcut( QKeySequence(QString("Ctrl+%1").arg( index +1 ) ), this ); connect( shortcut, SIGNAL(activated() ), signalMapper, SLOT( map() ) ); signalMapper->setMapping( shortcut, index ); } connect( signalMapper, SIGNAL(mapped( int )),ui->output, SLOT(setCurrentIndex( int )) ); // Wave theory ui->widget_SF->setVisible(false); ui->LorP_ComboBox->setVisible(false); ui->widget_waveFile->setVisible(false); QRect SFwidget_geo = ui->widget_SF->geometry(); ui->widget_JONSWAP->setGeometry(SFwidget_geo); ui->widget_JONSWAP->setVisible(false); ui->widget_waveFile->setGeometry(SFwidget_geo); ui->widget_customSpectrum->setVisible(false); ui->widget_customSpectrum->setGeometry(SFwidget_geo); // About ui->aboutText_OCW3dGUI->setVisible(false); ui->aboutText_OCW3D_publications->setVisible(false); ui->aboutText_OCW3DVersion->setVisible(false); // Post processing ui->readProgressBar->setVisible(false); ui->tableWidget->setColumnCount(6); ui->tableWidget->setVisible(false); ui->SelectOutput->setEnabled(false); ui->convert->setEnabled(false); ui->morison_widget->setVisible(false); ui->eta_widget->setVisible(false); QRect Morison_geo = ui->morison_widget->geometry(); ui->eta_widget->setGeometry(Morison_geo); ui->convertStatus->setVisible(false); // Custom grid ui->geometry_table->setRowCount(2); ui->geometry_table->setVerticalHeaderLabels(QString("x [m];d [m]").split(";")); ui->customGridWidget->setVisible(false); // set labels ui->alpha_label->setText(QString((QChar) 0x03B1)); ui->beta_label->setText(QString((QChar) 0x03B2)); ui->gamma_label->setText(QString((QChar) 0x03B3)); connect(ui->waveType,SIGNAL(currentIndexChanged(int)),this,SLOT(on_waveTheoryChanged(int))); connect(ui->storeAscii_onOff,SIGNAL(clicked(bool)),this,SLOT(storeASCII(bool))); connect(ui->LorP_ComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(on_waveTheoryChanged())); connect(ui->nOutFiles,SIGNAL(valueChanged(int)),this,SLOT(on_outputWidgetChanged(int))); connect(ui->OpenDirBrowser,SIGNAL(clicked()),this,SLOT(openWorkDirDialog())); connect(ui->selectPPfile,SIGNAL(clicked()),this,SLOT(selectPPfile())); connect(ui->run,SIGNAL(clicked()),this,SLOT(run())); connect(ui->selectGnuplotFile,SIGNAL(clicked()),this,SLOT(openFileDialog())); connect(ui->plot,SIGNAL(clicked()),this,SLOT(gnuplot())); connect(ui->read_bottom,SIGNAL(clicked()),this,SLOT(readKinematicFile())); connect(ui->about_combobox,SIGNAL(currentIndexChanged(int)),this,SLOT(about_changed(int))); connect(ui->SelectOutput,SIGNAL(currentIndexChanged(int)),this,SLOT(convertTo_setup(int))); connect(ui->convert,SIGNAL(clicked()),this,SLOT(convertTo())); connect(ui->showGrid,SIGNAL(clicked()),this,SLOT(showGrid())); connect(ui->geometryType,SIGNAL(currentIndexChanged(int)),this,SLOT(geometryType_changed(int))); connect(ui->nGridPoints,SIGNAL(valueChanged(int)),this,SLOT(nGridPoints_changed())); connect(ui->smooth,SIGNAL(clicked()),this,SLOT(smooth())); connect(ui->generateGrid,SIGNAL(clicked()),this,SLOT(generateGrid())); connect(ui->selectWaveFile,SIGNAL(clicked()),this,SLOT(selectWaveFile())); connect(ui->selectGridFile,SIGNAL(clicked()),this,SLOT(selectGridFile())); connect(ui->selectWaveFile_eta,SIGNAL(clicked()),this,SLOT(selectWaveFile_eta())); connect(ui->DropDownListOutputType,SIGNAL(currentIndexChanged(int)),this,SLOT(WaveTypeSelected())); connect(ui->pushButton_advancedMorison,SIGNAL(clicked()),this,SLOT(advancedMorison())); // default connect(ui->checkBox_constantWidget,SIGNAL(stateChanged(int)),this,SLOT(constantWidget())); connect(ui->checkBox_breakingWidget,SIGNAL(stateChanged(int)),this,SLOT(breakingWidget())); connect(ui->checkBox_FD,SIGNAL(stateChanged(int)),this,SLOT(FDWidget())); connect(ui->checkBox_precon,SIGNAL(stateChanged(int)),this,SLOT(preconWidget())); // ations connect(ui->actionClose,SIGNAL(triggered()),this,SLOT(close())); connect(ui->actionOpen,SIGNAL(triggered()),this,SLOT(openFile())); connect(ui->actionRun_F5,SIGNAL(triggered()),this,SLOT(run())); connect(ui->actionClear_case_F6,SIGNAL(triggered()),this,SLOT(clearCase())); connect(ui->actionWrite_input_file_F4,SIGNAL(triggered()),this,SLOT(writeInputFile())); connect(ui->actionChange_directory,SIGNAL(triggered()),this,SLOT(openWorkDirDialog())); connect(ui->actionCheck,SIGNAL(triggered()),this,SLOT(checkCase())); ui->workingDir->setText(dir.currentPath()); // Special versions #if externalOutputClass ui->SelectOutput->addItem("External output"); #endif }
void Svm::train(bool divide /* = true */, float divide_percentage /* = 0.7 */, bool train /* = true */, const char* out_svm_path /* = NULL */) { if (out_svm_path == NULL) { out_svm_path = "resources/model/svm.xml"; } if (divide) { std::cout << "Dividing data to be trained and tested..." << std::endl; this->divide(forward_, divide_percentage); this->divide(inverse_, divide_percentage); } CvSVM svm; // 70% training procedure if (train) { this->get_train(); if (!this->classes_.empty() && !this->trainingData_.empty()) { // need to be trained first CvSVMParams SVM_params; SVM_params.svm_type = CvSVM::C_SVC; // SVM_params.kernel_type = CvSVM::LINEAR; //CvSVM::LINEAR; // 线型,也就是无核 SVM_params.kernel_type = CvSVM::RBF; // CvSVM::RBF 径向基函数,也就是高斯核 SVM_params.degree = 0.1; SVM_params.gamma = 1; SVM_params.coef0 = 0.1; SVM_params.C = 1; SVM_params.nu = 0.1; SVM_params.p = 0.1; SVM_params.term_crit = cvTermCriteria(CV_TERMCRIT_ITER, 100000, 0.0001); std::cout << "Generating svm model file, please wait..." << std::endl; try { // CvSVM svm(trainingData, classes, cv::Mat(), cv::Mat(), SVM_params); svm.train_auto(this->trainingData_, this->classes_, cv::Mat(), cv::Mat(), SVM_params, 10, CvSVM::get_default_grid(CvSVM::C), CvSVM::get_default_grid(CvSVM::GAMMA), CvSVM::get_default_grid(CvSVM::P), CvSVM::get_default_grid(CvSVM::NU), CvSVM::get_default_grid(CvSVM::COEF), CvSVM::get_default_grid(CvSVM::DEGREE), true); } catch (const cv::Exception& err) { std::cout << err.what() << std::endl; } utils::mkdir(out_svm_path); cv::FileStorage fsTo(out_svm_path, cv::FileStorage::WRITE); svm.write(*fsTo, "svm"); std::cout << "Generate done! The model file is located at " << out_svm_path << std::endl; } else { // don't train, use ready-made model file try { svm.load("resources/train/svm.xml", "svm"); } catch (const cv::Exception& err) { std::cout << err.what() << std::endl; } } } // if train // TODO Check whether the model file exists or not. svm.load(out_svm_path, "svm"); // make sure svm model was loaded // 30% testing procedure this->get_test(); std::cout << "Testing..." << std::endl; double count_all = test_imgaes_.size(); double ptrue_rtrue = 0; double ptrue_rfalse = 0; double pfalse_rtrue = 0; double pfalse_rfalse = 0; size_t label_index = 0; for (auto image : test_imgaes_) { //调用回调函数决定特征 auto features = easypr::histeq(image); features = features.reshape(1, 1); cv::Mat out; features.convertTo(out, CV_32FC1); Label predict = ((int)svm.predict(out)) == 1 ? kForward : kInverse; Label real = test_labels_[label_index++]; if (predict == kForward && real == kForward) ptrue_rtrue++; if (predict == kForward && real == kInverse) ptrue_rfalse++; if (predict == kInverse && real == kForward) pfalse_rtrue++; if (predict == kInverse && real == kInverse) pfalse_rfalse++; } std::cout << "count_all: " << count_all << std::endl; std::cout << "ptrue_rtrue: " << ptrue_rtrue << std::endl; std::cout << "ptrue_rfalse: " << ptrue_rfalse << std::endl; std::cout << "pfalse_rtrue: " << pfalse_rtrue << std::endl; std::cout << "pfalse_rfalse: " << pfalse_rfalse << std::endl; double precise = 0; if (ptrue_rtrue + ptrue_rfalse != 0) { precise = ptrue_rtrue / (ptrue_rtrue + ptrue_rfalse); std::cout << "precise: " << precise << std::endl; } else { std::cout << "precise: " << "NA" << std::endl; } double recall = 0; if (ptrue_rtrue + pfalse_rtrue != 0) { recall = ptrue_rtrue / (ptrue_rtrue + pfalse_rtrue); std::cout << "recall: " << recall << std::endl; } else { std::cout << "recall: " << "NA" << std::endl; } double Fsocre = 0; if (precise + recall != 0) { Fsocre = 2 * (precise * recall) / (precise + recall); std::cout << "Fsocre: " << Fsocre << std::endl; } else { std::cout << "Fsocre: " << "NA" << std::endl; } }