Example #1
0
int32_t GetNearestClusters (int num, welet *wel, int numWel ,
                            RecVersions *collection )
{
    RecRaster recRast;
    RECRESULT recres[REC_MAX_VERS];
    int xbit;
    int bytesx;
    int ret, j;
    int let = wel[num].let;
    memset(collection, 0, sizeof(RecVersions));
    j = FONGetClusterAsBW( NULL, num, 0, &recRast);

    if (j < 0) return 0;

    xbit = recRast.lnPixWidth;
    bytesx = ((xbit + 63) / 64) * 8;
    ret = RecogClu(recRast.Raster, (int16_t)bytesx, (int16_t)xbit, (int16_t)recRast.lnPixHeight,
                   recres, (int16_t)REC_MAX_VERS, wel, numWel, -1, 0, -1024, -1024, 1 );

    if (ret <= 0) return 0;

    for (xbit = j = 0; xbit < ret; xbit++) {
        if ( let == recres[xbit].name ) continue;

        collection->Alt[j].Code = recres[xbit].name;
        // for every point - add straf
        collection->Alt[j].Prob = recres[xbit].prob;
        collection->Alt[j].Info = recres[xbit].nClust + 1;
        j++;
    }

    collection->lnAltCnt = j;
    return j;
}
Example #2
0
FON_FUNC(int32_t) FONGetNearestClusters( RecRaster* recRast, // symbol
		ClustAlt result[], // result table of K nearest klusters
		int nClustAltLen, // length of table
		int nDistLevel // don't report about clusters with distance more than nDistLevel
)
{

	int xbit=recRast->lnPixWidth;
	int bytesx=((xbit+63)/64)*8;
	int ret;
	RECRESULT recres[32]; // really 4


	if(nClustAltLen > 32)
	nClustAltLen = 32;

	memset(result,0,sizeof(ClustAlt)*nClustAltLen);

	if( recRast->lnPixHeight > WR_MAX_HEIGHT-2 ||
			xbit > WR_MAX_WIDTH -2 )
	return 0;

	ret=RecogClu(recRast->Raster,(int16_t)bytesx,(int16_t)xbit,(int16_t)recRast->lnPixHeight,
			recres,(int16_t)nClustAltLen,
			fonbase.start,fonbase.inBase,
			nDistLevel,0,-1024,-1024,1);

	//  ret=recog_raster(recRast->Raster,(uint16_t)bytesx,(uint16_t)xbit,(uint16_t)recRast->lnPixHeight,
	//				  &fonbase,recres,nClustAltLen);

	if(ret <= 0) return 0;

	for(xbit=0;xbit<ret;xbit++)
	{
		result[xbit].nClust=recres[xbit].nClust+1;
		result[xbit].nDist =255-recres[xbit].prob;
	}

	//  FineFONCollection(collection);

	return ret;
}
Example #3
0
FON_FUNC(int32_t) FONRecogChar(RecRaster *recRast,RecVersions *collection,FonSpecInfo *specInfo)
{
	int xbit =recRast->lnPixWidth;
	int bytesx=((xbit+63)/64)*8;
	int ret;
	RECRESULT recres[REC_MAX_VERS];
	int32_t nInCTB,nField;
	int16_t col,row;
	int32_t countRazmaz;

	memset(collection,0,sizeof(RecVersions));

#ifdef _OLD_LEO_
	nInCTB=(int)specInfo;
	nField=0;
	specInfo=NULL;
#else
	if(specInfo)
	{
		nInCTB = specInfo->nInCTB;
		nField = specInfo->nFieldRow;
		specInfo->wFonFlags=0;
		specInfo->nClust =0;
		col=specInfo->col;
		row=specInfo->row;
		countRazmaz = specInfo->countRazmaz;
	}
	else
	{
		nInCTB=0;
		nField=0;
		col=row=-1024;
		countRazmaz = 1;
	}
#endif

#ifdef _NO_RECOG_
	return 0;
#endif

	if( recRast->lnPixHeight > WR_MAX_HEIGHT-2 ||
			xbit > WR_MAX_WIDTH -2 )
	return 0;

	ret=RecogClu(recRast->Raster,(int16_t)bytesx,(int16_t)xbit,(int16_t)recRast->lnPixHeight,
			recres,(int16_t)REC_MAX_VERS, fonbase.start,fonbase.inBase,-1,
			nInCTB,col,row, countRazmaz);

	if(ret < 0) return ret;
	collection->lnAltCnt=0;
	for(xbit=0;xbit<ret;xbit++)
	{
		// очень слабые не нужны
		if( recres[xbit].prob < 40 )
		break;
		collection->lnAltCnt++;
		collection->Alt[xbit].Code=recres[xbit].name;
		collection->Alt[xbit].Prob=recres[xbit].prob;

#ifdef _ADD_STRAF_SMALL_
		{
			int nClus;
			if( (nClus=recres[xbit].nClust) >= 0 &&
					nClus < fonbase.inBase &&
					( fonbase.start[nClus].weight < POROG_WEIGHT ||
							fonbase.start[nClus].prob < POROG_PROB
					) &&
					collection->Alt[xbit].Prob>0
			)
			collection->Alt[xbit].Prob--;
		}
#endif
	}
#ifdef _ADD_STRAF_SMALL_
	// могли испортить порядок
	ReorderCollection(collection);
#endif
	FineFONCollection(collection);

	if(specInfo)
	{
		// расставим флажки
		SetFonFlags(specInfo,collection,recRast);

		if( collection->lnAltCnt > 0)
		{
			// какой кластер остался лучшим
			for(xbit=0;xbit<ret;xbit++)
			{
				if(collection->Alt[0].Code==recres[xbit].name)
				{
					specInfo->nClust=recres[xbit].nClust+1;
					break;
				}
			}
		}
	}

	return collection->lnAltCnt;
}