Esempio n. 1
0
/*
* Portion based on the work of Nenad Markus n3ar. 
*/
static void compute_index_matrix(ascii_render *pRender, uint8_t pixels[], int nrows, int ncols, int ldim)
{
	int i = 0;
	int r, c;
	for (r = 0; r < nrows; r += pRender->nRows) {
		for (c = 0; c < ncols; c += pRender->nCols) {
			if (pRender->pTree)
				pRender->zMatrix[i] = get_tree_output(pRender->pTree, &pixels[r*ldim + c], ldim);
			else
				pRender->zMatrix[i] = 0;
			++i;
		}
	}
}
Esempio n. 2
0
int match_templates(int rs[], int cs[], int ss[], int qs[], int32_t* ptrs[], int maxndetections,
					uint8_t pixels[], int nrows, int ncols, int ldim,
					float scalefactor, float stridefactor, float minsize, float maxsize, int n0max)
{
	int s;
	int ndetections;

	int k = 0;

	int numtags;
	int tags[8192];

	//
	ndetections = 0;

	s = minsize;

	while(s<=maxsize)
	{
		int r, c, dr, dc;

		//
		dr = MAX(stridefactor*s, 1);
		dc = MAX(stridefactor*s, 1);

		//
		for(r=s/2+1; r<=nrows-s/2-1; r+=dr)
			for(c=s/2+1; c<=ncols-s/2-1; c+=dc)
			{
				int lutidx, i, n1, pass, T[6];

				//
				compute_rcs_transformation(T, r, c, s);
				///compute_rcso_transformation(T, r, c, s, -3.14f/2);

				//
				//*
				numtags = 0;
				get_tree_output(root, THRESHOLD, 3, T, pixels, nrows, ncols, ldim, tags, &numtags);

				for(i=0; i<numtags; ++i)
				{
					pass = match_template_at(templates[tags[i]], THRESHOLD, T, &n1, n0max, pixels, nrows, ncols, ldim);

					if(pass)
					{
						int _n1;

						match_template_at(smoothnesstemplates[tags[i]], THRESHOLD, T, &_n1, MAXNUMTESTS, pixels, nrows, ncols, ldim);

						if(_n1 > smoothnesstemplates[tags[i]][0]/2)
							pass = 0;
					}

					if(pass)
					{
						if(ndetections < maxndetections)
						{
							rs[ndetections] = r;
							cs[ndetections] = c;
							ss[ndetections] = s;

							qs[ndetections] = n1;

							ptrs[ndetections] = templates[tags[i]];

							++ndetections;
						}
					}
				}
				//*/

				//
				/*
				for(i=0; i<numtemplates; ++i)
				{
					pass = match_template_at(templates[i], THRESHOLD, T, &n1, n0max, pixels, nrows, ncols, ldim);

					if(pass)
					{
						int _n1;

						match_template_at(smoothnesstemplates[i], THRESHOLD, T, &_n1, MAXNUMTESTS, pixels, nrows, ncols, ldim);

						if(_n1 > smoothnesstemplates[tags[i]][0]/2)
							pass = 0;
					}

					if(pass)
					{
						if(ndetections < maxndetections)
						{
							rs[ndetections] = r;
							cs[ndetections] = c;
							ss[ndetections] = s;

							qs[ndetections] = n1;

							ptrs[ndetections] = templates[i];

							++ndetections;
						}
					}
				}
				//*/
			}

		//
		s = MAX(scalefactor*s, s+1);
	}

	//
	return ndetections;
}