Beispiel #1
0
SearchDialog::SearchDialog()
{
    SET_WNDPROC("search")
    setIcon(Pict("find"));
    setButtonsPict(this);
    setCaption(i18n("Search"));
    m_current = NULL;
    m_currentResult = NULL;
    m_bAdd = true;
    m_id		= 0;
    m_result_id = 0;
    m_active	= NULL;
    m_search	= new SearchBase(this);
    m_update = new QTimer(this);
    connect(m_update, SIGNAL(timeout()), this, SLOT(update()));
    setCentralWidget(m_search);
    m_status = statusBar();
    m_result = NULL;
    setAdd(false);
    m_search->btnOptions->setIconSet(*Icon("1downarrow"));
    m_search->btnAdd->setIconSet(*Icon("add"));
    m_search->btnNew->setIconSet(*Icon("new"));
    connect(m_search->wndCondition, SIGNAL(aboutToShow(QWidget*)), this, SLOT(aboutToShow(QWidget*)));
    connect(m_search->wndResult, SIGNAL(aboutToShow(QWidget*)), this, SLOT(resultShow(QWidget*)));
    fillClients();
    connect(m_search->cmbClients, SIGNAL(activated(int)), this, SLOT(clientActivated(int)));
    m_result = new ListView(m_search->wndResult);
    m_result->addColumn(i18n("Results"));
    m_result->setShowSortIndicator(true);
    m_result->setExpandingColumn(0);
    m_result->setFrameShadow(QFrame::Sunken);
    m_result->setLineWidth(1);
    addResult(m_result);
    showResult(NULL);
    aboutToShow(m_search->wndCondition->visibleWidget());
    connect(m_search->btnSearch, SIGNAL(clicked()), this, SLOT(searchClick()));
    m_search->cmbClients->setFocus();
    connect(m_search->btnOptions, SIGNAL(clicked()), this, SLOT(optionsClick()));
    connect(m_search->btnAdd, SIGNAL(clicked()), this, SLOT(addClick()));
    m_search->btnOptions->setEnabled(false);
    m_search->btnAdd->setEnabled(false);
    connect(m_result, SIGNAL(selectionChanged()), this, SLOT(selectionChanged()));
    connect(m_result, SIGNAL(dragStart()), this, SLOT(dragStart()));
    connect(m_search->btnNew, SIGNAL(clicked()), this, SLOT(newSearch()));
    m_result->setMenu(MenuSearchItem);
	resultShow(m_result);
}
Beispiel #2
0
void TaskView::slotCheckButtonClicked()
{
	if (m_currentState == _CHECK_TASK)
	{
		// if nothing has been entered by the user, we don't check the result yet
		if (numer_edit->text().isEmpty() == true && deno_edit->text().isEmpty() ==
true)
			return;
		m_currentState = _NEXT_TASK;
		m_checkButton->setText(i18n("N&ext Task"));
		(void) showResult();
	} else {
		m_currentState = _CHECK_TASK;
		m_checkButton->setText(i18n("&Check Task"));
		(void) nextTask();
	}
}
Beispiel #3
0
void GameScene::birdDie(bool dieReasonFall){
    bird->stopAllActions();
    bird->die();
    dieCount++;
    
    setStatus(GameEnd);
  
    if (dieReasonFall) {
        showResult();
        AudioController::sharedInstance()->playEffect("sfx_hit");
    }
    else {
        birdFall();
        AudioController::sharedInstance()->playEffect("sfx_die");
    }
    
}
Beispiel #4
0
/* This timer has two jobs: it polls the thread if it is finished. Polling is
  better here as it might finish while the dialog builds up. Secondly it refreshes
  the displayed result.
 */
void KrCalcSpaceDialog::timer()
{
    // thread finished?
    if (m_thread->isFinished()) {
        // close dialog or switch buttons
        calculationFinished();
        m_pollTimer->stop(); // stop the polling. No longer needed
        return;
    }

    // Every 10 pollings (1 second) refresh the displayed result
    if (++m_timerCounter > 10) {
        m_timerCounter = 0;
        showResult();
        m_thread->updateItems(m_view);
    }
}
Beispiel #5
0
DatabaseWidget::DatabaseWidget(QWidget *parent)
    : QWidget(parent, Qt::WindowMinMaxButtonsHint)
    , ui(new Ui::DatabaseWidget)
    , stackedWidget(qobject_cast<SlidingStackedWidget*>(parent))
    , dataWidget(nullptr)
    , showResultWiget(nullptr)
{
  ui -> setupUi(this) ;

  connect(ui -> closeDialogButton, SIGNAL(clicked() ), this, SLOT(closeDialog() ) ) ;
  connect(ui -> addDataButton, SIGNAL(clicked() ), this, SLOT(addDataToDatabaseInit() ) ) ;
  connect(ui -> editDataButton, SIGNAL(clicked() ), this, SLOT(editDataInit() ) ) ;
  connect(ui -> deleteDataButton, SIGNAL(clicked() ), this, SLOT(deleteDataFromDatabase() ) ) ;
  connect(ui -> showResultButton, SIGNAL(clicked() ), this, SLOT(showResult() ) ) ;
  connect(ui -> editResultButton, SIGNAL(clicked() ), this, SLOT(editResultInit() ) ) ;
  connect(ui -> deleteResultButton, SIGNAL(clicked() ), this, SLOT(deleteResult() ) ) ;
}
void ScriptCounter::processObjectPropertiesFamily(LLMessageSystem* msg, void** user_data)
{
	LLUUID object_id;
	msg->getUUIDFast(_PREHASH_ObjectData, _PREHASH_ObjectID,object_id );
	std::string name;
	msg->getStringFast(_PREHASH_ObjectData, _PREHASH_Name, name);
	if(reqObjectID.notNull())
	if(object_id == reqObjectID)
	{
		if(doDelete)
			sstr << "Deleted scripts from object "+name+": ";
		else
			sstr << "Counted scripts on object "+name+": ";
		reqObjectID.setNull();
		if(countingDone)
			showResult();
	}
}
Beispiel #7
0
int KrCalcSpaceDialog::exec()
{
    m_thread->start(); // start the thread
    if (m_autoClose) { // autoclose
        // set the cursor to busy mode and wait 1 second or until the thread finishes
        krMainWindow->setCursor(Qt::WaitCursor);
        m_thread->wait(1000);
        krMainWindow->setCursor(Qt::ArrowCursor);    // return the cursor to normal mode
        m_thread->updateItems(m_view);
        if(m_thread->isFinished())
            return -1;                                        // thread finished: do not show the dialog
        showResult(); // fill the invisible dialog with useful data
    }
    // prepare and start the poll timer
    connect(m_pollTimer, SIGNAL(timeout()), this, SLOT(timer()));
    m_pollTimer->start(100);
    return QDialog::exec();                                 // show the dialog
}
void SectorizationManagerDlg::OnBnClickedButtonDel()
{
	if (MessageBox("您确定要删除吗?","删除警告",MB_OKCANCEL)!=IDOK)
		return;

	int iCount = m_wndReportCtrl.GetRecords()->GetCount();
	for(int i=0; i<iCount; i++)
	{
		if( m_wndReportCtrl.GetRecords()->GetAt(i)->GetItem(0)->IsChecked() )
		{
			CString strName = m_wndReportCtrl.GetRecords()->GetAt(i)->GetItem(1)->GetCaption(0);
			

			SectorizationManager::getInstance()->deleteSectorization(strName);
		}
	}

	showResult();
}
Beispiel #9
0
int main(void) {
	char hex1[ROZMIAR], hex2[ROZMIAR];

	unsigned char *bin1, *bin2;
	int bin1Size, bin2Size, resultSize;

	scanf("%s", hex1);
    	scanf("%s", hex2);
	
	bin1 = hexToBin(hex1,&bin1Size);
	bin2 = hexToBin(hex2,&bin2Size);

	resultSize = (bin1Size>bin2Size)?bin1Size+1:bin2Size+1;
	unsigned char * result = (unsigned char*)malloc(resultSize);

	add(bin1,bin2,result,bin1Size,bin2Size,resultSize);

	showResult(result,resultSize);

	return 0;
}
Beispiel #10
0
void ExerciseFactorize::slotCheckButtonClicked()
{
    if (m_currentState == _CHECK_TASK)
    {
        // if nothing has been entered by the user, we don't check the result yet
        if (m_factorsEntered.count() == 0)
            return;
        m_currentState = _NEXT_TASK;
        m_checkButton->setText(i18n("N&ext Task"));
        (void) showResult();
    } else {
        m_currentState = _CHECK_TASK;
        m_checkButton->setText(i18n("&Check Task"));
        (void) nextTask();
    }

    // update the line edit
    updateEnteredEdit();

    return;
}
void ImageViewer_ex2::adjustimageAffineSimilarity()
{
    Vector3f l(3,1);
    Vector3f m(3,1);
    Vector3f r1(3,1);
    Vector3f r2(3,1);
    MatrixXf A(2,3);

    l = pinmanager->getLine(0);
    m = pinmanager->getLine(1);

    r2 << l(0) * m(0), l(0) * m(1) + l(1) * m(0), l(1) * m(1);

    l = pinmanager->getLine(2);
    m = pinmanager->getLine(3);

    r1 << l(0) * m(0), l(0) * m(1) + l(1) * m(0), l(1) * m(1);

    A << r1.transpose(), r2.transpose();
    JacobiSVD<MatrixXf> SVD(A, ComputeFullV);
    VectorXf S = SVD.matrixV().col(SVD.matrixV().cols() - 1);

    //S /= S(2);
    S(2) = 1;

    MatrixXf kkt(2,2);
    kkt << S(0), S(1), S(1), S(2);

    LLT<MatrixXf> lltOfA(kkt);
    MatrixXf L = lltOfA.matrixU();

    H << L(0), L(1), 0, L(2), L(3), 0, 0, 0, 1;
    //std::cout << H << std::endl;
    H = H.inverse();

    QSize imgSize(this->width(), this->height());
    QVector<QPoint> areaRender;
    areaRender << QPoint(0,0) << QPoint(0, imgSize.height()) << QPoint(imgSize.width(), imgSize.height()) << QPoint(imgSize.width(), 0);
    showResult(imgSize, areaRender);
}
Beispiel #12
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    resultdialog = new ResultDialog;

    loadFeature();
    loadDic();
    loadVSM();
    loadBayes();

    //connect(ui->FileBrowse,SIGNAL(clicked()),this,SLOT(onFileBrowseButton()));
    connect(ui->Run,SIGNAL(clicked()),this,SLOT(textClassify()));
    connect(this,SIGNAL(textClassifyCompleted(QString)),resultdialog,SLOT(showResult(QString)));

    QTextCodec *codec=QTextCodec::codecForName("System");
    QTextCodec::setCodecForCStrings(codec);
    QTextCodec::setCodecForLocale(codec);
    QTextCodec::setCodecForTr(codec);

}
void ImageViewer_ex2::adjustImage(float w, float h)
{
    Vector3f hl(3,1);
    hl = pinmanager->getHorizonLine().transpose();
    hl = hl/ hl(2);

    MatrixXf temp(3,3);
    temp << 1, 0, 0, 0, 1, 0, hl(0), hl(1), hl(2);
    Hp = temp;

    H = Hp;
    Hi = H.inverse();

    QSize imgSize(this->width(), this->height());
    QVector<QPoint> areaRender;
    areaRender << QPoint(0,0) << QPoint(0, imgSize.height()) << QPoint(imgSize.width(), imgSize.height()) << QPoint(imgSize.width(), 0);
    showResult(imgSize, areaRender);
    imageBase = imageResult;
    pinmanager->setType(pinmanager->TYPE_FOUR);
    if(isDebug){
        prepareDebug();
    }
}
void PartionedManualMPSimExecutor::simulate()
{
    try {

        PartionedMRTKernel kern("PartionedKern");
        TextTrace ttrace("run_log.txt");
        JSONTrace jtrace("run_trace.json");

        createSimCPUScheduler();
        createSimTaskCPU();
        createSimVMCPU();

        GUI_CONTEXT.addPeriodicTasks();
        GUI_CONTEXT.addVMs();

        addCPUs2Kernel(kern);
        addVMs2Kernel(kern, jtrace, ttrace);
        addTasks2Kernel(kern, jtrace, ttrace);

        SIMUL.run(_simulTime + 1);

    } catch (BaseExc &e) {

        GUI_CONTEXT.showMessageBox(e.what());
        GUI_CONTEXT.erasePeriodicTask();
        GUI_CONTEXT.erasePeriodicServerVM();

        cleanExecutionData();
        return;
    }

    showResult();

    GUI_CONTEXT.erasePeriodicTask();
    GUI_CONTEXT.erasePeriodicServerVM();
    cleanExecutionData();
}
Beispiel #15
0
KeyAddDialog::KeyAddDialog( CryptoDoc *_doc, QWidget *parent )
:	QWidget( parent )
,	doc( _doc )
{
	setupUi( this );
	setAttribute( Qt::WA_DeleteOnClose );
	setWindowFlags( Qt::Dialog );

	cardButton = buttonBox->addButton( tr("Add cert from card"), QDialogButtonBox::ActionRole );
	connect( cardButton, SIGNAL(clicked()), SLOT(addCardCert()) );
	connect( buttonBox->addButton( tr("Add cert from file"), QDialogButtonBox::ActionRole ),
		SIGNAL(clicked()), SLOT(addFile()) );
	connect( qApp, SIGNAL(dataChanged()), SLOT(enableCardCert()) );
	enableCardCert();

	skView->setModel( keyModel = new KeyModel( this ) );
	skView->header()->setStretchLastSection( false );
	skView->header()->setResizeMode( 0, QHeaderView::Stretch );
	skView->header()->setResizeMode( 1, QHeaderView::ResizeToContents );
	skView->header()->setResizeMode( 2, QHeaderView::ResizeToContents );
	connect( skView, SIGNAL(doubleClicked(QModelIndex)), SLOT(on_add_clicked()) );

	usedView->header()->setStretchLastSection( false );
	usedView->header()->setResizeMode( 0, QHeaderView::Stretch );
	usedView->header()->setResizeMode( 1, QHeaderView::ResizeToContents );
	usedView->header()->setResizeMode( 2, QHeaderView::ResizeToContents );
	loadHistory();

	ldap = new LdapSearch( this );
	connect( ldap, SIGNAL(searchResult(QList<CKey>)), SLOT(showResult(QList<CKey>)) );
	connect( ldap, SIGNAL(error(QString)), SLOT(showError(QString)) );

	validator = new IKValidator( this );
	on_searchType_currentIndexChanged( 0 );
	add->setEnabled( false );
	progress->setVisible( false );
}
void ShareJob::start()
{
    //KService::Ptr service = KService::serviceByStorageId("plasma-share-pastebincom.desktop");
    KService::Ptr service = KService::serviceByStorageId(destination());
    if (!service) {
        showError(i18n("Could not find the provider with the specified destination"));
        return;
    }

    QString pluginName =
        service->property("X-KDE-PluginInfo-Name", QVariant::String).toString();

    const QString path =
        KStandardDirs::locate("data", "plasma/shareprovider/" + pluginName + '/' );

    if (path.isEmpty()) {
        showError(i18n("Invalid path for the requested provider"));
        return;
    }

    m_package = new Plasma::Package(path, ShareProvider::packageStructure());
    if (m_package->isValid()) {
        const QString mainscript =
            m_package->path() + m_package->structure()->contentsPrefixPaths().at(0) +
            m_package->structure()->path("mainscript");

        if (!QFile::exists(mainscript)) {
            showError(i18n("Selected provider does not have a valid script file"));
            return;
        }

        const QString interpreter =
            Kross::Manager::self().interpreternameForFile(mainscript);

        if (interpreter.isEmpty()) {
            showError(i18n("Selected provider does not provide a supported script file"));
            return;
        }

        m_action = new Kross::Action(parent(), pluginName);
        if (m_action) {
            m_provider = new ShareProvider(this);
            connect(m_provider, SIGNAL(readyToPublish()), this, SLOT(publish()));
            connect(m_provider, SIGNAL(finished(QString)),
                    this, SLOT(showResult(QString)));
            connect(m_provider, SIGNAL(finishedError(QString)),
                    this, SLOT(showError(QString)));

            // automatically connects signals and slots with the script
            m_action->addObject(m_provider, "provider",
                                Kross::ChildrenInterface::AutoConnectSignals);

            // set the main script file and load it
            m_action->setFile(mainscript);
            m_action->trigger();

            // check for any errors
            if(m_action->hadError()) {
                showError(i18n("Error trying to execute script"));
                return;
            }

            // do the work together with the loaded plugin
            const QStringList functions = m_action->functionNames();
            if (!functions.contains("url") || !functions.contains("contentKey") ||
                !functions.contains("setup")) {
                showError(i18n("Could not find all required functions"));
                return;
            }

            // call the methods from the plugin
            const QString url =
                m_action->callFunction("url", QVariantList()).toString();
            m_provider->setUrl(url);

            // setup the method (get/post)
            QVariant vmethod;
            if (functions.contains("method")) {
                vmethod =
                    m_action->callFunction("method", QVariantList()).toString();
            }

            // default is POST (if the plugin does not specify one method)
            const QString method = vmethod.isValid() ? vmethod.toString() : "POST";
            m_provider->setMethod(method);

            // setup the provider
            QVariant setup = m_action->callFunction("setup", QVariantList());

            // get the content from the parameters, set the url and add the file
            // then we can wait the signal to publish the information
            const QString contentKey =
                m_action->callFunction("contentKey", QVariantList()).toString();

            const QString content(parameters()["content"].toString());
            m_provider->addPostFile(contentKey, content);
        }
    }
}
void deleteFile(string ID){
	string sql="DELETE FROM filelist WHERE author='"+ID+"';";
	cout<<sql<<endl;
	sql_exec(sql);
	showResult();
}
QWidget *toTemplate::frame(void)
{
    if (Result->isHidden())
        showResult(true);
    return Frame;
}
void AdiumxtraProtocolHandler::install()
{
    if (m_url.isEmpty()) {
        Q_EMIT finished();
        return; // BundleInstaller:: xxxxx
    }

    QUrl url = QUrl::fromUserInput(m_url);
    if(url.scheme() == QLatin1String("adiumxtra")) {
        url.setScheme(QStringLiteral("http"));
    }

    QTemporaryFile *tmpFile = new QTemporaryFile();
    if (tmpFile->open()) {
        KIO::Job* getJob = KIO::file_copy(url, QUrl::fromLocalFile(tmpFile->fileName()), -1,
                                          KIO::Overwrite | KIO::HideProgressInfo);
        if (getJob->exec()) {
            qWarning() << "Download failed";
            Q_EMIT finished();
            return; // BundleInstaller::BundleCannotOpen;
        }
        getJob->deleteLater();
    }

    KArchive *archive = 0L;

    QMimeDatabase db;

    QString currentBundleMimeType =  db.mimeTypeForFile(tmpFile->fileName()).name();
    if (currentBundleMimeType == QLatin1String("application/zip")) {
        archive = new KZip(tmpFile->fileName());
    } else if (currentBundleMimeType == QLatin1String("application/x-compressed-tar") ||
               currentBundleMimeType == QLatin1String("application/x-bzip-compressed-tar") ||
               currentBundleMimeType == QLatin1String("application/x-gzip") ||
               currentBundleMimeType == QLatin1String("application/x-bzip")) {
        archive = new KTar(tmpFile->fileName());
    } else {
        KNotification *notification = new KNotification(QLatin1String("packagenotrecognized"), NULL, KNotification::Persistent);
        notification->setText( i18n("Package type not recognized or not supported") );
        notification->setActions( QStringList() << i18n("OK") );
        QObject::connect(notification, SIGNAL(action1Activated()), notification, SLOT(close()));
        QObject::connect(notification, SIGNAL(ignored()), notification, SLOT(close()));
        notification->setComponentName(ktelepathyComponentName());
        notification->sendEvent();
        qWarning() << "Unsupported file type" << currentBundleMimeType;
        Q_EMIT finished();
        return;// BundleInstaller::BundleNotValid;
    }

    if (!archive->open(QIODevice::ReadOnly)) {
        delete archive;
        qWarning() << "Cannot open theme file";
        Q_EMIT finished();
        return;// BundleInstaller::BundleCannotOpen;
    }

    ChatStyleInstaller *chatStyleInstaller = new ChatStyleInstaller(archive, tmpFile);
    if (chatStyleInstaller->validate() == BundleInstaller::BundleValid) {
        chatStyleInstaller->showRequest();

        QObject::connect(chatStyleInstaller, SIGNAL(finished(BundleInstaller::BundleStatus)),
                         chatStyleInstaller, SLOT(showResult()));
        QObject::connect(chatStyleInstaller, SIGNAL(showedResult()), this, SIGNAL(finished()));
        QObject::connect(chatStyleInstaller, SIGNAL(showedResult()),
                         chatStyleInstaller, SLOT(deleteLater()));
        QObject::connect(chatStyleInstaller, SIGNAL(ignoredRequest()), this, SIGNAL(finished()));
        QObject::connect(chatStyleInstaller, SIGNAL(ignoredRequest()),
                         chatStyleInstaller, SLOT(deleteLater()));

        return;// BundleInstaller::BundleValid;
    }
    delete chatStyleInstaller;

    EmoticonSetInstaller *emoticonSetInstaller = new EmoticonSetInstaller(archive, tmpFile);
    if(emoticonSetInstaller->validate() == BundleInstaller::BundleValid) {
        emoticonSetInstaller->showRequest();

        QObject::connect(emoticonSetInstaller, SIGNAL(finished(BundleInstaller::BundleStatus)),
                         emoticonSetInstaller, SLOT(showResult()));
        QObject::connect(emoticonSetInstaller, SIGNAL(showedResult()), this, SIGNAL(finished()));
        QObject::connect(emoticonSetInstaller, SIGNAL(showedResult()),
                         emoticonSetInstaller, SLOT(deleteLater()));
        QObject::connect(emoticonSetInstaller, SIGNAL(ignoredRequest()), this, SIGNAL(finished()));
        QObject::connect(emoticonSetInstaller, SIGNAL(ignoredRequest()),
                         emoticonSetInstaller, SLOT(deleteLater()));

        return;// BundleInstaller::BundleValid;
    }
    delete emoticonSetInstaller;

    KNotification *notification = new KNotification(QLatin1String("packagenotrecognized"),
                                                    NULL,
                                                    KNotification::Persistent);
    notification->setText( i18n("Package type not recognized or not supported") );
    QObject::connect(notification, SIGNAL(action1Activated()), notification, SLOT(close()));
    QObject::connect(notification, SIGNAL(ignored()), notification, SLOT(close()));
    notification->setActions( QStringList() << i18n("OK") );
    notification->setComponentName(ktelepathyComponentName());
    notification->sendEvent();

    Q_EMIT finished();
    return;// BundleInstaller::BundleUnknownError;
}
Beispiel #20
0
int CPlateRecognize::plateRecognize(Mat src, std::vector<std::string> &licenseVec) {

  std::vector<CPlate> plateVec;

  int resultPD = plateDetect(src, plateVec, 0, kDebug, 0);

  if (resultPD == 0) {
    size_t num = plateVec.size();
    int index = 0;

    for (size_t j = 0; j < num; j++) {
      CPlate item = plateVec[j];
      Mat plate = item.getPlateMat();


      std::string plateType = getPlateColor(plate);

      std::string plateIdentify = "";
      int resultCR = charsRecognise(plate, plateIdentify);
      if (resultCR == 0) {
        std::string license = plateType + ":" + plateIdentify;
        licenseVec.push_back(license);
      }
    }

    if (getResultShow()) {
      Mat result;
      src.copyTo(result);

      for (size_t j = 0; j < num; j++) {
        CPlate item = plateVec[j];
        Mat plate = item.getPlateMat();

        int height = 36;
        int width = 136;
        if (height * index + height < result.rows) {
          Mat imageRoi = result(Rect(0, 0 + height * index, width, height));
          addWeighted(imageRoi, 0, plate, 1, 0, imageRoi);
        }
        index++;

        RotatedRect minRect = item.getPlatePos();
        Point2f rect_points[4];
        minRect.points(rect_points);

        Scalar lineColor = Scalar(255, 255, 255);

        if (item.getPlateLocateType() == SOBEL) lineColor = Scalar(255, 0, 0);
        if (item.getPlateLocateType() == COLOR) lineColor = Scalar(0, 255, 0);
        if (item.getPlateLocateType() == CMSER) lineColor = Scalar(0, 0, 255);

        for (int j = 0; j < 4; j++)
          line(result, rect_points[j], rect_points[(j + 1) % 4], lineColor, 2,
               8);
      }

      showResult(result);
    }
  }

  return resultPD;
}
Beispiel #21
0
int CPlateRecognize::plateRecognize(Mat src, std::vector<CPlate> &plateVecOut, int img_index) {

  std::vector<CPlate> plateVec;

  int resultPD = plateDetect(src, plateVec, img_index);

  if (resultPD == 0) {
    size_t num = plateVec.size();
    int index = 0;

    for (size_t j = 0; j < num; j++) {
      CPlate item = plateVec.at(j);
      Mat plateMat = item.getPlateMat();

      if (0) {
        imshow("plate", plateMat);
        waitKey(0);
        destroyWindow("plate");
      }

      Color color = item.getPlateColor();
      if (color == UNKNOWN) {
        color = getPlateType(plateMat, true);
        item.setPlateColor(color);
      }

      std::string plateColor = getPlateColor(color);
      if (0) {
        std::cout << "plateColor:" << plateColor << std::endl;
      }

      std::string plateIdentify = "";
      int resultCR = charsRecognise(item, plateIdentify);

      if (resultCR == 0) {
        std::string license = plateColor + ":" + plateIdentify;
        item.setPlateStr(license);
        plateVecOut.push_back(item);
      }
      else {
        std::string license = plateColor;
        item.setPlateStr(license);
        plateVecOut.push_back(item);
        if (0) {
          std::cout << "resultCR:" << resultCR << std::endl;
        }
      }
    }

    if (getResultShow()) {
      Mat result;
      src.copyTo(result);

      for (size_t j = 0; j < num; j++) {
        CPlate item = plateVec[j];
        Mat plateMat = item.getPlateMat();

        int height = 36;
        int width = 136;
        if (height * index + height < result.rows) {
          Mat imageRoi = result(Rect(0, 0 + height * index, width, height));
          addWeighted(imageRoi, 0, plateMat, 1, 0, imageRoi);
        }
        index++;

        RotatedRect minRect = item.getPlatePos();
        Point2f rect_points[4];
        minRect.points(rect_points);

        Scalar lineColor = Scalar(255, 255, 255);

        if (item.getPlateLocateType() == SOBEL) lineColor = Scalar(255, 0, 0);
        if (item.getPlateLocateType() == COLOR) lineColor = Scalar(0, 255, 0);
        if (item.getPlateLocateType() == CMSER) lineColor = Scalar(0, 0, 255);

        for (int j = 0; j < 4; j++)
          line(result, rect_points[j], rect_points[(j + 1) % 4], lineColor, 2, 8);
      }

      showResult(result);
    }
  }


  return resultPD;
}
Beispiel #22
0
// !车牌识别模块
int CPlateRecognize::plateRecognize(Mat src, vector<string>& licenseVec, int index)
{
	// 车牌方块集合
	vector<CPlate> plateVec;
	
	// 如果设置了Debug模式,就依次显示所有的图片
	bool showDetectArea = getPDDebug();

	// 进行深度定位,使用颜色信息与二次Sobel
	int resultPD = plateDetectDeep(src, plateVec, showDetectArea, 0);

	Mat result;
	src.copyTo(result);

	if (resultPD == 0)
	{
		int num = plateVec.size();
		int index = 0;

		for (int j = 0; j < num; j++)
		{
			CPlate item = plateVec[j];		
			Mat plate = item.getPlateMat();
			
			//获取车牌颜色
			string plateType = getPlateColor(plate);

			//获取车牌号
			string plateIdentify = "";
			int resultCR = charsRecognise(plate, plateIdentify);
			if (resultCR == 0)
			{
				string license = plateType + ":" + plateIdentify;
				licenseVec.push_back(license);

				/*int height = 36;
				int width = 136;
				if(height*index + height < result.rows)
				{
					Mat imageRoi = result(Rect(0, 0 + height*index, width, height));
					addWeighted(imageRoi, 0, plate, 1, 0, imageRoi);				 				
				}
				index++;*/

				RotatedRect minRect = item.getPlatePos();
				Point2f rect_points[4]; 
				minRect.points( rect_points );

				if(item.bColored)
				{
					for (int j = 0; j < 4; j++)
						line(result, rect_points[j], rect_points[(j + 1) % 4], Scalar(255, 255, 0), 2, 8);
				}
				else
				{
					for( int j = 0; j < 4; j++ )
						line(result, rect_points[j], rect_points[(j+1)%4], Scalar(0,0,255), 2, 8 );//sobel定位车牌,红色方框
				}							
			}
		}
	}

	if (showDetectArea)
		showResult(result);

	return resultPD;
}
Beispiel #23
0
void Hachmei::on_actionAbout_triggered()
{
	showResult(-1, ResultType::About);
}
void
CompliantPlannerDlg::bestButtonClicked()
{
	mBestGraspNum=0;
	showResult();
}
void
CompliantPlannerDlg::prevButtonClicked()
{
	mBestGraspNum--;
	showResult();
}
int main(int argc, char** argv)
{
    GenericSolver solver;
    
    // WARNING: ARRAY MUST BE INSTANTIATE COLUMN-WISE //
    
    std::cout<<"------------------ test non initialized problem ------------------"<<std::endl;
    solver.printProblem();
    solver.solveProblem();  // should fail without crash
    std::cout<<"Problem solved? "<<solver.problemIsSolved()<<std::endl;
    showResult(solver);
    
    std::cout<<"------------------ test void problem ------------------"<<std::endl;
    solver.initProblem(3,2,1);
    solver.printProblem();
    solver.solveProblem();  // should fail without crash
    std::cout<<"Problem solved? "<<solver.problemIsSolved()<<std::endl;
    showResult(solver);
    
    std::cout<<"------------------ test unconstrained problem ------------------"<<std::endl;
    solver.initProblem(3,0,0);
    double P[]={1,0,0, 0,1,0, 0,0,1};
    double q[]={1,2,3};
    solver.setCostFunction(P, q);
    solver.printProblem();
    solver.solveProblem();
    std::cout<<"Problem solved? "<<solver.problemIsSolved()<<std::endl;
    showResult(solver);
    
    std::cout<<"------------------ test problem  with equality constraint ------------------"<<std::endl;
    solver.initProblem(3,2,0);
    double A[]={1,0, 0,1, 0,1};
    double b[]={7,8};
    solver.setCostFunction(P, q);
    solver.setEqualityConstraint(A, b);
    solver.printProblem();
    solver.solveProblem();
    std::cout<<"Problem solved? "<<solver.problemIsSolved()<<std::endl;
    showResult(solver);

    std::cout<<"------------------ test problem  with inequality constraint ------------------"<<std::endl;
    solver.initProblem(3,0,2);
    double G[]={1,0, 0,-1, 0,-1};
    double h[]={-7,8};
    solver.setCostFunction(P, q);
    solver.setInequalityConstraint(G, h);
    solver.printProblem();
    solver.solveProblem();
    std::cout<<"Problem solved? "<<solver.problemIsSolved()<<std::endl;
    showResult(solver);

    std::cout<<"------------------ test problem  with inequality constraint ------------------"<<std::endl;
    solver.initProblem(3,1,2);
    double A2[]={-1,1,-1};
    double b2[]={-5};
    solver.setCostFunction(P, q);
    solver.setEqualityConstraint(A2, b2);
    solver.setInequalityConstraint(G, h);
    solver.printProblem();
    solver.solveProblem();
    std::cout<<"Problem solved? "<<solver.problemIsSolved()<<std::endl;
    showResult(solver);

    std::cout<<"------------------ test void problem (again) ------------------"<<std::endl;
    solver.initProblem(4,3,3);
    solver.printProblem();
    solver.solveProblem();  // should fail without crash
    std::cout<<"Problem solved? "<<solver.problemIsSolved()<<std::endl;
    showResult(solver);

#if defined WIN32
    System("pause");
#endif

    return 0;
}
void
CompliantPlannerDlg::nextButtonClicked()
{
	mBestGraspNum++;
	showResult();
}
int CPlateDetect::plateDetectDeep(Mat src, vector<Mat>& resultVec, bool showDetectArea, int index)
{

	vector<Mat> resultPlates;

	vector<CPlate> color_Plates;
	vector<CPlate> sobel_Plates;
	vector<CPlate> color_result_Plates;
	vector<CPlate> sobel_result_Plates;

	vector<CPlate> all_result_Plates;

	//如果颜色查找找到n个以上(包含n个)的车牌,就不再进行Sobel查找了。
	const int color_find_max = 4;

	Mat result;
	src.copyTo(result);

	m_plateLocate->plateColorLocate(src, color_Plates, index);
	m_plateJudge->plateJudge(color_Plates, color_result_Plates);

	
	for (int i = 0; i< color_result_Plates.size(); i++)
	{
		CPlate plate = color_result_Plates[i];

		RotatedRect minRect = plate.getPlatePos();
		Point2f rect_points[4];
		minRect.points(rect_points);
		for (int j = 0; j < 4; j++)
			line(result, rect_points[j], rect_points[(j + 1) % 4], Scalar(0, 255, 255), 2, 8);

		all_result_Plates.push_back(plate);
	}

	if (color_result_Plates.size() >= color_find_max)
	{
		//如果颜色查找找到n个以上(包含n个)的车牌,就不再进行Sobel查找了。
	} 
	else
	{
		m_plateLocate->plateSobelLocate(src, sobel_Plates, index);
		m_plateJudge->plateJudge(sobel_Plates, sobel_result_Plates);

		for (int i = 0; i< sobel_result_Plates.size(); i++)
		{
			CPlate plate = sobel_result_Plates[i];

			RotatedRect minRect = plate.getPlatePos();
			Point2f rect_points[4]; 
			minRect.points( rect_points );
			for( int j = 0; j < 4; j++ )
				line(result, rect_points[j], rect_points[(j+1)%4], Scalar(0,0,255), 2, 8 );

			all_result_Plates.push_back(plate);
		}
	}

	for (int i = 0; i < all_result_Plates.size(); i++)
	{
		// 把截取的车牌图像依次放到左上角
		CPlate plate = all_result_Plates[i];

		Mat plate_area = plate.getPlateMat();

		int height = m_plateLocate->HEIGHT;
		int width = m_plateLocate->WIDTH;

		assert(height*i + height < result.rows);

		Mat imageRoi = result(Rect(0, 0 + height*i, width, height));
		addWeighted(imageRoi, 0, plate_area, 1, 0, imageRoi);

		resultVec.push_back(plate_area);
	}

	if (showDetectArea)
	{
		namedWindow("EasyPR", CV_WINDOW_AUTOSIZE);
		showResult(result);
		destroyWindow("EasyPR");
	}
	

	if (0)
	{
		stringstream ss(stringstream::in | stringstream::out);
		ss << "image/tmp/" << index << "_" << 9 <<"_result" << ".jpg";
		imwrite(ss.str(), result);
	}

	return 0;
}
Beispiel #29
0
// !车牌识别模块
int CPlateRecognize::plateRecognize(Mat src, std::vector<string> &licenseVec) {
    // 车牌方块集合
    vector<CPlate> plateVec;

    // 进行深度定位,使用颜色信息与二次Sobel
    int resultPD = plateDetect(src, plateVec, getPDDebug(), 0);

    if (resultPD == 0) {
        int num = plateVec.size();
        int index = 0;

        //依次识别每个车牌内的符号
        for (int j = 0; j < num; j++) {
            CPlate item = plateVec[j];
            Mat plate = item.getPlateMat();

            //获取车牌颜色
            string plateType = getPlateColor(plate);

            //获取车牌号
            string plateIdentify = "";
            int resultCR = charsRecognise(plate, plateIdentify);
            if (resultCR == 0) {
                string license = plateType + ":" + plateIdentify;
                licenseVec.push_back(license);
            }
        }
        //完整识别过程到此结束

        //如果是Debug模式,则还需要将定位的图片显示在原图左上角
        if (getPDDebug() == true) {
            Mat result;
            src.copyTo(result);

            for (int j = 0; j < num; j++) {
                CPlate item = plateVec[j];
                Mat plate = item.getPlateMat();

                int height = 36;
                int width = 136;
                if (height * index + height < result.rows) {
                    Mat imageRoi = result(Rect(0, 0 + height * index, width, height));
                    addWeighted(imageRoi, 0, plate, 1, 0, imageRoi);
                }
                index++;

                RotatedRect minRect = item.getPlatePos();
                Point2f rect_points[4];
                minRect.points(rect_points);

                Scalar lineColor = Scalar(255, 255, 255);

                if (item.getPlateLocateType() == SOBEL) lineColor = Scalar(255, 0, 0);

                if (item.getPlateLocateType() == COLOR) lineColor = Scalar(0, 255, 0);

                for (int j = 0; j < 4; j++)
                    line(result, rect_points[j], rect_points[(j + 1) % 4], lineColor, 2,
                         8);
            }

            //显示定位框的图片
            showResult(result);
        }
    }

    return resultPD;
}
void MainWindow::tick()
{
    if((pig_count==0&&bird_count==6) || score==33000)
    {
        qDebug() << "pig_count : " << pig_count;
        qDebug() << "bird_count : " << bird_count;
        qDebug() << "score : " << score;
        showResult();
    }
    ui->lcdNumber->display(score);
    ui->lcdNumber_2->display(pig_count);
    ui->lcdNumber_3->display(6-bird_count);
    if(shot)
    {
        CD = (*Bit)->available;
        b2Vec2 speed = (*Bit)->Body->GetLinearVelocity();
        VB = qSqrt(qPow(speed.x,2)+qPow(speed.y,2));
        b2Vec2 X = (*Bit)->Body->GetPosition();;
        if((X.y>120 || X.x<-20) || X.x>100)
            outer = true;
        if((VB==0 || outer) && bird_count == 2)
        {
            bird2 = new Bird(2,6.8f, 10.7f,BIRD_DENSITY, BIRD_RADIUS, &timer, QPixmap(":/bird/img/Angry Birds Seasons/angry-bird-yellow-icon.png"), world, scene);
            BIRD.push_back(bird2);
            delete (*Bit);
            BIRD.erase(Bit);
            shot = false;
            newed = true;
            outer = false;
        }
        else if((VB==0 || outer) && bird_count == 3)
        {
            bird3 = new Bird(3,6.8f, 10.7f,BIRD_DENSITY*4, 1.5, &timer, QPixmap(":/bird/img/Angry Birds Seasons/BLOCK_STEEL_BALL.png"), world, scene);
            BIRD.push_back(bird3);
            delete (*Bit);
            BIRD.erase(Bit);
            shot = false;
            newed = true;
            outer = false;
        }
        else if((VB==0 || outer) && bird_count == 4)
        {
            bird4 = new Bird(4,6.8f, 10.7f,BIRD_DENSITY, BIRD_RADIUS*1.75, &timer, QPixmap(":/bird/img/Angry Birds Seasons/BIRD_GREY_YELL.png"), world, scene);
            BIRD.push_back(bird4);
            delete (*Bit);
            BIRD.erase(Bit);
            shot = false;
            newed = true;
            outer = false;
        }
        else if((VB==0 || outer) && bird_count == 5)
        {
            bird5 = new Bird(5,7.1f, 10.9f,BIRD_DENSITY, BIRD_RADIUS*2, &timer, QPixmap(":/bird/img/Angry Birds Seasons/TA.png"), world, scene);
            BIRD.push_back(bird5);
            delete (*Bit);
            BIRD.erase(Bit);
            shot = false;
            newed = true;
            outer = false;
        }
        else if((VB==0 || outer) && bird_count == 6)
        {
            bird6 = new Bird(6,6.8f, 10.7f,BIRD_DENSITY, BIRD_RADIUS, &timer, QPixmap(""), world, scene);
            BIRD.push_back(bird6);
            delete (*Bit);
            BIRD.erase(Bit);
            shot = false;
            newed = true;
            outer = false;
            showResult();
        }
    }
    for(it = WOOD.begin(); it!= WOOD.end(); ++it)
    {
        if((*it)->death)
        {
            delete (*it);
            WOOD.erase(it);
            score += 2000;
            //qDebug() << score;
        }
    }
    for(it = PIG.begin(); it!= PIG.end(); ++it)
    {
        if((*it)->death)
        {
            delete (*it);
            PIG.erase(it);
            score += 5000;
            --pig_count;
            //qDebug() << score;
        }
    }
    world->Step(1.0/60.0, 6, 2);
    scene->update();
}