⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stages0.h

📁 it will work it is recogntion code only
💻 H
字号:
//Copyright(c)2004  Alexander Kadyrov
//                STAGE TRACE

#undef  TYPEtr
#define TYPEtr unsigned char
#undef  typetr   //0="unsigned char",1="int",2="double",
#define typetr 0 // corresponds "unsigned char"
#undef  TYPEsr
#define TYPEsr int
#undef  out
#define out    int
//Rules here: 
//if TYPEtr=uchar or TYPEtr=integer type, then TYPEsr=int
//if TYPEtr=double, then TYPEsr=double
//out=TYPEsr; out is used for finding sum,max, etc.

double**trMatr;int**itrMatr;int LtrM,N2pi,Npi,dimp,dimp1,np,npshift,nfi;//-STAGETRACE SPECIFIC.

namespace TRACE{ 
#include "modioperandi0.h"
void writeObjects(void)//tr,lbeg,lend,L,dlt; - should be defined to compute functionals
{// STAGETRACE SPECIFIC:
int nf;
for (nf=0;nf<LlistU;nf++) 
  trMatr[nf][dimp*nfi+(np+npshift)]=o[listU[nf]];
for (nf=0;nf<LlistU;nf++) 
  trMatr[nf][dimp*(Npi+nfi)+(dimp1-(np+npshift))]=a[listU[nf]];
}//END.
// STAGETRACE SPECIFIC:
void stagetraceBegin(void)// used before proceeding images
{
int LstageList=LtrList,*stageList=trList;//DEBUG
int NonBackSack=1;//-Back
composingListModiOperandi(LstageList,stageList, NonBackSack);
trMatr=new double*[LlistU];//prepare them
int iM; for(iM=0;iM<LlistU;iM++) trMatr[iM]=NULL;
ML=0;//-then it will be Ltr and then grow only
}//END.

void stagetraceForAnImage(void)// used for each image
{ static int LtrM0;// first call - it is zero
int iM;LtrM=N2pi*dimp; //Memory construct and Zerofy (Zerofy is redundant)
dimp1=dimp-1;  /// ????????? Strange here???????
if (LtrM>LtrM0)
    for(iM=0;iM<LlistU;iM++)
    { // reallocate trace matrices if larger room is needed
     delete[](trMatr[iM]);trMatr[iM]=new double[LtrM];
    }
LtrM0=LtrM;
#ifndef ROTATING_BOX
for(iM=0;iM<LlistU;iM++)
{ double aB=attBlank[listU[iM]];
  int i; for(i=0;i<LtrM;i++) trMatr[iM][i]=aB;//for empty tracks
}
#endif
}//END.

}//END namespace TRACE


//                STAGE DIAM

/*#undef  TYPEtr
#define TYPEtr int
#undef  typetr   //0="unsigned char",1="int",2="double",
#define typetr 1 // corresponds "int"
#undef  TYPEsr
#define TYPEsr int
#undef  out
#define out    int
*/
#undef  TYPEtr
#define TYPEtr double
#undef  typetr   //0="unsigned char",1="int",2="double",
#define typetr 2 // corresponds "double"
#undef  TYPEsr
#define TYPEsr double
#undef  out
#define out    double

//Rules here: ///if TYPEtr=uchar or TYPEtr=integer type, then TYPEsr=int
//if TYPEtr=double, then TYPEsr=double
//out=TYPEsr; out is used for finding sum,max, etc.
namespace DIAM{ //1time
#include "modioperandi0.h"
}//namespace DIAM{ //1time

double **circ,
               **circA, //the last is a for accociated circus
               **circPN,//for plain normalised circus
               **circAN;//for accociated normalised circus

namespace DIAM{ //2time
int LlistF0,*listF0=new int[Amount];
unsigned char oneeded0[Amount];
int LlistF1,*listF1=new int[Amount];//Llistout1,listout1[Amount];
unsigned char oneeded1[Amount];
int LlistF2,*listF2=new int[Amount];//Llistout2,listout2[Amount];
unsigned char oneeded2[Amount];


void stagediam(void)//
{   UfVArrAssign();
int LstageList=LdiList,*stageList=diList;//DEBUG
int NonBackSack=0,j;//-None
composingListModiOperandi(LstageList,stageList, NonBackSack);//DEBUG 
  LlistF0=LlistF;  for(j=0;j<LlistF;j++)    listF0[j]=listF[j];
                     for(j=0;j<Amount;j++)oneeded0[j]=oneeded[j]; 
NonBackSack=1;
composingListModiOperandi(LstageList,stageList, NonBackSack);//DEBUG 
  LlistF1=LlistF;  for(j=0;j<LlistF;j++)    listF1[j]=listF[j];
//Llistout1=Llistout;for(j=0;j<Llistout;j++)listout1[j]=listout[j];
                     for(j=0;j<Amount;j++)oneeded1[j]=oneeded[j]; 
NonBackSack=2;
composingListModiOperandi(LstageList,stageList, NonBackSack);//DEBUG 
  LlistF2=LlistF;  for(j=0;j<LlistF;j++)    listF2[j]=listF[j];
//Llistout2=Llistout;for(j=0;j<Llistout;j++)listout2[j]=listout[j];
                     for(j=0;j<Amount;j++)oneeded2[j]=oneeded[j]; 
//Memory allocation:
for(j=0;j<Amount;j++)oneeded[j]=(oneeded0[j]||oneeded1[j]||oneeded2[j]);

/////the folowing two lines should be done for each image
/////ML=dimp;//trace length = length of trace matrices along p-coordinate 
/////objectsMemoryConstructor();


//memory allocation for circuses:
circ=new double*[TRACE::LlistU];//prepare them
circA=new double*[TRACE::LlistU];//prepare them
circAN=new double*[TRACE::LlistU];//prepare them
circPN=new double*[TRACE::LlistU];//prepare them
//itrMatr=new int*[Llistout];//prepare them

int iM;
for(iM=0;iM<TRACE::LlistU;iM++) 
{ circ[iM]=new double[LlistU*N2pi];
  circA[iM]=new double[LlistU*N2pi];
  circAN[iM]=new double[LlistU*N2pi];
  circPN[iM]=new double[LlistU*N2pi];
}
for(iM=0;iM<TRACE::LlistU;iM++) 
     {for(int i=0;i<LlistU*N2pi;i++) circ[iM][i]=33;}


}//END.

void fillCircuses(void)//before calling this, fill DIAM::dlt=dp;
{int  iM=0,attSym,j;
  for (iM=0;iM<TRACE::LlistU;iM++)
{
   //Find out degree of symmetry of this trMatr[iM]:
   attSym=attBack[TRACE::listU[iM]];//because only "Back" (not "Sack")
                                    //was possible in the stage "TRACE" 
    // attSym EQ 0 - adjacent column(ie fixed fi) 
    //                               of trace matrix is made as "br"
    // attSym EQ 1 - adjacent column of trace matrix is made as "sr"
    // attSym>1 - adjacent column of trace matrix is different
if (attSym EQ 0)
    { 
    LlistF=LlistF1;for(j=0;j<LlistF;j++)listF[j]=listF1[j]; 
//    Llistout=Llistout1;for(j=0;j<Llistout;j++)listout[j]=listout1[j];
    for (nfi=0;nfi<Npi;nfi++)
        { tr=&(trMatr[iM][nfi*dimp]);
        computeObjects_giveBackAdj();//"o" and "a" are ready
        for(j=0;j<LlistU;j++)circ[iM][j*N2pi+nfi]=o[listU[j]];
        for(j=0;j<LlistU;j++)circ[iM][j*N2pi+nfi+Npi]=a[listU[j]];
        }
    }
if (attSym EQ 1)
    { 
    LlistF=LlistF2;for(j=0;j<LlistF;j++)listF[j]=listF2[j]; 
    //Llistout=Llistout2;for(j=0;j<Llistout;j++)listout[j]=listout2[j];
    for (nfi=0;nfi<Npi;nfi++)
        { tr=&(trMatr[iM][nfi*dimp]);
        computeObjects_giveSackAdj();//"o" and "a" are ready
        for(j=0;j<LlistU;j++)circ[iM][j*N2pi+nfi]=o[listU[j]];
        for(j=0;j<LlistU;j++)circ[iM][j*N2pi+nfi+Npi]=a[listU[j]];
        }
    }

if (attSym >1 )
    {
    LlistF=LlistF0;for(j=0;j<LlistF;j++)listF[j]=listF0[j]; 
    for (nfi=0;nfi<N2pi;nfi++)//here 2pi - all the circus
        { tr=&(trMatr[iM][nfi*dimp]);
        computeObjects_giveNonAdj();//"o" is ready, no need for "a"
        for(j=0;j<LlistU;j++)circ[iM][j*N2pi+nfi]=o[listU[j]]; 
        }
    }
}//for (iM=0;iM<TRACE::LlistU;iM++)

}//END.

}//namespace DIAM{ //2time

//                STAGE TRIPLE
#undef  TYPEtr
#define TYPEtr double
#undef  typetr   //0="unsigned char",1="int",2="double",
#define typetr 2 // corresponds "double"
#undef  TYPEsr
#define TYPEsr double
#undef  out
#define out    double

//Rules here: ///if TYPEtr=uchar or TYPEtr=integer type, then TYPEsr=int
//if TYPEtr=double, then TYPEsr=double
//out=TYPEsr; out is used for finding sum,max, etc.
double *triple,//triple feature for (plain) circus
               *triplePN,//triple feature for plain normalised circus
               *tripleAN;//triple feature for accociated normalised circus

namespace TRIPLE{
#include "modioperandi0.h"
void stagetriple(void)
 {  UfVArrAssign();
   int LstageList=LcirList,*stageList=cirList;//DEBUG
   int NonBackSack=0;//-Non
   composingListModiOperandi(LstageList,stageList, NonBackSack);
   int Ltf=TRACE::LlistU * DIAM::LlistU * LlistU;
   triple=new double[Ltf];//prepare them
   triplePN=new double[Ltf]; 
   tripleAN=new double[Ltf];
   ML=N2pi;
   objectsMemoryConstructor();
 }//END.

void fillTriple(double**circuses,double*tripleFeats)//before calling this, fill TRIPLE::dlt=dfi;
 {  double*tF=tripleFeats; int itF=0;
    for (int nf=0;nf<TRACE::LlistU;nf++) 
     for (int cf=0;cf<DIAM::LlistU;cf++)
      { tr=circuses[nf]+cf*N2pi;
        computeObjects_giveNonAdj();//"o" is ready, no need for "a"
        for(int j=0;j<LlistU;j++)tF[itF++]=o[listU[j]];
        //for(int j=0;j<LlistU;j++)tF[itF++]=777;
      }
 }//END.



}//namespace TRIPLE{

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -