Example #1
0
void nnor::charactersPadding(vector<Mat> chars)
{
	int nnRows = 0;
	int nnCols = 0;
	for (int i = 0; i < chars.size(); i++)
	{
		chars[i] = autoCrop(chars[i]);
		if (chars[i].rows > nnRows)
			nnRows = chars[i].rows;
		if (chars[i].cols > nnCols)
			nnCols = chars[i].cols;
	}

}
Example #2
0
void nnor::hierarchicCharactersPadding(vector<vector<vector<Mat>>> chars)
{
	int nnRows = 0;
	int nnCols = 0;
	for (int i = 0; i < chars.size(); i++)
	{
		for (int j = 0; j < chars[i].size(); j++)
		{
			for (int k = 0; k < chars[i][j].size(); k++)
			{
				chars[i][j][k] = autoCrop(chars[i][j][k]);
				if (chars[i][j][k].rows > nnRows)
					nnRows = chars[i][j][k].rows;
				if (chars[i][j][k].cols > nnCols)
					nnCols = chars[i][j][k].cols;
			}
		}
	}

	for (int i = 0; i < chars.size(); i++)
	{
		for (int j = 0; j < chars[i].size(); j++)
		{
			for (int k = 0; k < chars[i][j].size(); k++)
			{
				Mat character;
				chars[i][j][k].copyTo(character);
				int left = (nnCols - character.cols) / 2;
				int right = nnCols - left - character.cols;
				int top = (nnRows - character.rows) / 2;
				int bottom = nnRows - top - character.rows;
				copyMakeBorder(character, character, top, bottom, left, right, BORDER_CONSTANT, 255);
				chars[i][j][k] = character;
			}
		}
	}
}
Example #3
0
void FMMatchRaster::search()
{
	if((refImage.isNull()) || (!refCodepoint))
	{
		return;
	}
	buttonBox->setEnabled ( false );
	if ( !m_waitingForButton )
	{
		remainFonts = compFonts =  FMFontDb::DB()->getFilteredFonts();
		progressBar->setRange ( 0, compFonts.count() );
		stackedWidget->setCurrentIndex ( 1 );

		if ( !checkInteractive->isChecked() )
			questionWidget->setVisible ( false );
	}
	else
	{
		compFonts = remainFonts;
	}

	PuzzleViewImp ref ( refImage , curCol );

	foreach ( FontItem* fit, compFonts )
	{
		progressBar->setValue ( ++m_progressValue );
		remainFonts.removeAll ( fit );

		fontName->setText ( fit->fancyName() );
		QImage adjustedImg ( autoCrop ( fit->charImage ( refCodepoint , m_compsize ) ) );
		if ( !adjustedImg.isNull() )
		{
			PuzzleViewImp comp ( adjustedImg , QColor ( Qt::black ).rgb() );
			double compResult ( ref.CompMean ( comp ) );
			if ( compResult >= 0.0 )
			{
// 				qDebug()<<((compResult < m_matchLimit)? "****":"\t")<<compResult<<fit->fancyName();
				if ( compResult < m_matchLimit )
				{
					if ( !filteredFonts.contains ( fit ) )
					{
						if ( checkInteractive->isChecked() )
						{
							compView->setEnabled ( true );
							compView->setImage ( QPixmap::fromImage ( adjustedImg ) );
							compView->setEnabled ( false );
							scoreLabel->setText ( tr ( "The font %1 scores %2.\nDo you want to add it to the filtered fonts?" )
							                      .arg ( fit->fancyName() )
							                      .arg ( compResult ) );
							buttonBox->setEnabled ( true );
							waitingFont = fit;
							m_waitingForButton = true;
							return;
						}
						else
						{
							if ( !filteredFonts.contains ( fit ) )
								filteredFonts << fit;
						}
					}
				}
			}
		}
	}