コード例 #1
0
ファイル: SpriteFont.cpp プロジェクト: GlenDC/tt--Engine
void SpriteFont::DrawText(const std::tstring& text, tt::Vector2 position, const tt::Vector4& color)
{
	if(m_NrOfCharsToDraw += text.size() > sc_MaxNrOfChars)
		throw exception();

	MyServiceLocator::GetInstance()->GetService<IGraphicsService>()->GetSpriteBatch()->AddSpriteFont(this);
	
	m_TextQueue.push_back(TextData(text, position, color));
}
コード例 #2
0
ファイル: NGram.C プロジェクト: aalto-cbir/PicSOM
/// A function that calculates results for word NGrams.
Feature::featureVector NGram::NGramData::WordNGramResult() const {
  if (LabelVerbose())
    cout << "NGramData::WordNGramResult()" << endl;

  featureVector v(ngram_vector_length);
  
  vector<string> wordvec = TextData().get_words_as_string();
  
  unsigned int temp_ngram_n = ngram_n;
  if (wordvec.size() < ngram_n)
    temp_ngram_n = wordvec.size();
  
  int tot_n = 0;
  for(unsigned int i=0; i <= wordvec.size()-temp_ngram_n; i++) {
    string text = "";
    for (unsigned int j=0; j<temp_ngram_n; j++) 
      text += (j ? " " : "") + wordvec[i+j];
    
    if (PixelVerbose())
      cout << "NGramData::WordNGramResult() [" << text << "]" << endl;
    
    if (text=="")
      continue;

    shadigest_vect_t sha = hashsum(text);
    
    for(unsigned int j=0; j<ngram_vector_length/256; j++) {
      unsigned int vec_index = j*256 + (unsigned int) sha[j];
      v[vec_index]++;
    }
    
    tot_n++;
  }

  if (ngram_normalize) {
    if (LabelVerbose())
      cout << "NGramData::WordNGramResult() normalizing with " << tot_n
	   << endl;
    if (tot_n)
      DivideFeatureVector(v, tot_n);
  }
  
  return v;
}
コード例 #3
0
ファイル: main0929.cpp プロジェクト: seungjinPack/SJLAB
int main()
{
	ProfTimer mProfTimer;
	unsigned char *sTextData = TextData();


	float mArrVecParser_CSV[nWidthParser];
	float mArrVecParserCopy[nWidthParser];
	float mArrVecParserCopy2[nWidthParser];

	DataOpen("1909175498_image_profile.csv", mArrVecParser_CSV);
	//DataOpen("-1916029922_image_profile.csv", mArrVecParser_CSV);

	while (1)
	{

		memcpy(mArrVecParserCopy, mArrVecParser_CSV, sizeof(float)* nWidthParser);

		Global::Image mImageParser(nWidthParser, nheightParser, Global::TYPE::BYTE, 3);
		Global::Image mImageParser2(nWidthParser, nheightParser, Global::TYPE::BYTE, 3);
		Global::Image mImageParserReSize(img_wid, img_hig, Global::TYPE::BYTE, 3);

		for (int i = 0; i < nWidthParser; i++)
		{
			Global::Circle(&mImageParser, i, mArrVecParserCopy[i], 1, RGB8(0, 0, 255));
		}

#if 0
		int nXTest0 = 800;
		int nXTest1 = 900;
		int nTest;
		Sample sSample;
		sSample.nX0 = nXTest0;
		sSample.nX1 = nXTest1;
		Line(&mImageParser, mArrVecParserCopy, sSample,true);
		nXTest0 = 400;
		nXTest1 = 810;
		//Line(&mImageParser, nXTest0, nXTest1, mArrVecParserCopy, nTest, true);


		//DeletePoint(nWidthParser, nheightParser, 400, 700, mArrVecParserCopy);

#endif
#if 1



		int nLineCount(1);
		const int nSample = 1000;
		Sample sSample[nSample];
		while (nLineCount)
		{
			mProfTimer.Start();
			nLineCount--;

			int nArrNumderSize(0);
			int nSampleCount(0);
			memset(sSample, 0, sizeof(Sample)* nSample);

			int nMaxSample = 0;
			int nMaxSampleArrNum = 0;
			while (nSample - nArrNumderSize)
			{
				float fCutLine = nheightParser / 1.2;
				int nRandX0 = (std::rand() % nWidthParser);//중복은 나중에 고려
				int nRandX1 = (std::rand() % nWidthParser);//중복은 나중에 고려


				if (nRandX0 == nRandX1 || mArrVecParserCopy[nRandX0] < fCutLine || mArrVecParserCopy[nRandX1] < fCutLine)
				{
					continue;
				}

				sSample[nSampleCount].nX0 = nRandX0;
				sSample[nSampleCount].nX1 = nRandX1;
				if (Line(&mImageParser, mArrVecParserCopy, sSample[nSampleCount]))
				{
					if (sSample[nSampleCount].nSn > nMaxSample && sSample[nSampleCount].nSn > 10)
					{
						nMaxSample = sSample[nSampleCount].nSn;
						nMaxSampleArrNum = nSampleCount;
						nSampleCount++;
						//printf(" nMaxSampleArrNum : %d \n", nMaxSampleArrNum);
					}

					nArrNumderSize++;
					
				}
				


			}
			//mVecParserCopy

		
			if (nSampleCount > 0)
			{
				Line(0, mArrVecParserCopy, sSample[nMaxSampleArrNum], true);
				memcpy(mArrVecParserCopy2, mArrVecParser_CSV, sizeof(float)* nWidthParser);
				ReAgainst(nWidthParser, nheightParser, sSample[nMaxSampleArrNum], mArrVecParserCopy2);
			}
			mProfTimer.Stop();
			printf("mProfTimer : %f \n", mProfTimer.GetDurationInSecs());


			if (nSampleCount > 0)
			{
				Line(&mImageParser, mArrVecParserCopy, sSample[nMaxSampleArrNum], true);
				DeletePoint(nWidthParser, nheightParser, sSample[nMaxSampleArrNum], mArrVecParserCopy);


				for (int i = 0; i < nWidthParser; i++)
				{
					Global::Circle(&mImageParser2, i, mArrVecParserCopy2[i], 2, RGB8(0, 0, 255));
				}
			}
			//break;
		}
	




#endif
#if 0
		Global::Show("Parser ", &mImageParser);
		Global::Show("Test ", &mImageParser2);
#else	
		Global::Filter2D(&mImageParser2, &mImageParser2, Global::FILTER::GAUSSIAN, 1);
		Global::ReSize(&mImageParser2, &mImageParserReSize);
		Global::Show("Test ", &mImageParserReSize);

		Global::Filter2D(&mImageParser, &mImageParser, Global::FILTER::GAUSSIAN, 1);
		Global::ReSize(&mImageParser, &mImageParserReSize);
		Global::Show("Parser ", &mImageParserReSize);
#endif



		//Sleep(1);
	}

	delete sTextData;
	return 0;
}
コード例 #4
0
NodeDataType
TextDisplayDataModel::
dataType(PortType, PortIndex) const
{
  return TextData().type();
}