//_________________________________________________________________
Double_t* KVVarGlobMean::GetValuePtr(void)
{
// On retourne un tableau de valeurs. Ce tableau est organise comme suit:
//
// Index  Meaning
//--------------------------
// 0      Mean value of var = SumVar/SumOfWeights
// 1      standard deviation of var = sqrt(SumVarSquared/SumOfWeights-Mean*Mean)
// 2      Sum of weighted var values
// 3      Sum of weighted squared var values
// 4      Sum of weights
//  5    Maximum value
//  6    Max             6                       Minimum value
//
// The array is an internal variable of the class, do not delete it!

   CalcVar();
   fTab[0] = var;
   fTab[1] = ect;
   fTab[2] = svar;
   fTab[3] = svar2;
   fTab[4] = sw;
   fTab[5] = min;
   fTab[6] = max;
   return fTab;
}
//_________________________________________________________________
Double_t KVVarGlobMean::getvalue_int(Int_t i)
{
// on retourne la ieme valeur du tableau
//
// Index  Meaning
//--------------------------
// 0      Mean value of var = SumVar/SumOfWeights
// 1      standard deviation of var = sqrt(SumVarSquared/SumOfWeights-Mean*Mean)
// 2      Sum of weighted var values
// 3      Sum of weighted squared var values
// 4      Sum of weights
// 5      Minimum value
// 6      Maximum value
//
   CalcVar();
   Double_t rval = 0;
   switch (i) {
      case 0:
         rval = var;
         break;

      case 1:
         rval = ect;
         break;

      case 2:
         rval = svar;
         break;

      case 3:
         rval = svar2;
         break;

      case 4:
         rval = sw;
         break;

      case 5:
         rval = min;
         break;

      case 6:
         rval = max;
         break;

      default:
         rval = 0.;
         break;
   }
   return rval;
}
Beispiel #3
0
int AutoGainImage(int i)
{
	int m1,v1,iTemp;
	
	while(i--)
	{
		if(CaptureSensor(gImageBuffer,ONLY_LOCAL,&SensorBufInfo))
		{
			CalcVar((BYTE*)gImageBuffer, gOWidth, gOHeight, &v1, &m1, &iTemp,32);
			if(m1==0) return FALSE;
			if(GainAutoAdjust(m1))
				return TRUE;
		}

	}
	return FALSE;
}
Beispiel #4
0
int DetectFP(BYTE *ImgBuf,int Width,int Height, int HasFingerThreshold,int NoFingerThreshold,int Reverse,int DetectCount,int IsSingle)
{
	int v,avg_cur,avg_cur_div,avg_diff,m1,m2,size,pixel_diff,whiteSum=0,iTemp=0;
	int avgPixel=0;
/*	int ImgSize= Width*Height;

	BYTE *prev_fp = ImgBuf + (ImgSize),
		 *diff_fp = ImgBuf + (ImgSize) + DETECT_IMG_SIZE,
		 *cur_fp  = ImgBuf + (ImgSize) + (DETECT_IMG_SIZE <<1); */
//	printf(" ********** DetectFP ImgBuf=%p,prev_fp=%p,diff_fp=%p,cur_fp=%p \n",ImgBuf,prev_fp,diff_fp,cur_fp);
	static int LeaveFinger=0,
		   validCount=0,
		   pre_avg_cur_div=0;

	if(!CutDetectArea(ImgBuf,cur_fp,(Width>>1)-64 ,(Height>>1),Width,Height,DETECT_WIDTH,DETECT_HEIGHT))
	{
		return 0;
	}
	if(Reverse)
	{
		ReverseImage(cur_fp,DETECT_WIDTH,DETECT_HEIGHT);
	}
#ifdef DEBUGME
	WriteBitmap(cur_fp,DETECT_WIDTH,DETECT_HEIGHT,"fp_cut.bmp");
	WriteBitmap(ImgBuf,Width,Height,"fp_cut_src.bmp");
#endif
	CalcVar(cur_fp,DETECT_WIDTH,DETECT_HEIGHT,&avg_cur,&m1,&whiteSum,0);
	RegionDivideAdaptive((BYTE*)cur_fp,DETECT_WIDTH,DETECT_HEIGHT,-12,&avgPixel);
	size = DETECT_IMG_SIZE;
	for(v=0;v<size;v++)
	{
		if(cur_fp[v]==prev_fp[v])
			pixel_diff=255;
		else
			pixel_diff=0;
		diff_fp[v]=(BYTE)pixel_diff;
	}
	CalcVar(cur_fp,DETECT_WIDTH,DETECT_HEIGHT,&avg_cur_div,&m1,&iTemp,0);
	CalcVar(diff_fp,DETECT_WIDTH, DETECT_HEIGHT,&avg_diff,&m2,&iTemp,0);
	
#ifdef DEBUGME
	WriteBitmap(cur_fp, DETECT_WIDTH, DETECT_HEIGHT,"cur.bmp");
	WriteBitmap( prev_fp, DETECT_WIDTH, DETECT_HEIGHT,"prev.bmp");
	WriteBitmap( diff_fp,DETECT_WIDTH, DETECT_HEIGHT,"diff.bmp");
#endif
	if(!IsSingle && !LeaveFinger && (avg_cur_div<NoFingerThreshold || avg_diff>NoFingerThreshold))
	{
		LeaveFinger=TRUE;
		memcpy(prev_fp,cur_fp,DETECT_WIDTH*DETECT_HEIGHT);
		validCount=0; 
		pre_avg_cur_div=0;
	//	printf("No finger\n"); 
		return 0;
	}else if (IsSingle && ((avg_cur_div>HasFingerThreshold ) ||			//正常探测
			(avgPixel>180 && avg_cur_div>HasFingerThreshold-1200 ) || //适当考虑过湿指纹
			(avgPixel<80 &&  avg_cur_div>HasFingerThreshold+800 )))
	{
		return TRUE;
		
	}else if(LeaveFinger && ((avg_cur_div>HasFingerThreshold && avg_diff>NoFingerThreshold) ||			//正常探测
			(avgPixel>180 && avg_cur_div>HasFingerThreshold-1200 && avg_diff>NoFingerThreshold-1200) || //适当考虑过湿指纹
			(avgPixel<80 &&  avg_cur_div>HasFingerThreshold+800 && avg_diff>NoFingerThreshold+800)))	//适当过滤残留指纹
	{
	//	printf("debug me avg_cur_div=%d,count=%d,avgPixel=%d\n",avg_cur_div,validCount,avgPixel);
		validCount++;
		if(validCount==DetectCount)
		{
			//filter black background
			if(avgPixel>216 || (avg_cur<696 && avgPixel>136 && whiteSum<104) || (avg_cur<480 && avgPixel>120))
			{
				validCount=0;
				DBPRINTF("a fake finger\n");
				//write_bitmap("/mnt/ramdisk/finger_fake.bmp",ImgBuf,Width,Height);
				return FALSE;
			}
			//write_bitmap("/mnt/ramdisk/finger.bmp",ImgBuf,Width,Height);
					
			LeaveFinger=FALSE;
			memcpy(prev_fp,cur_fp,DETECT_IMG_SIZE);
#ifdef DEBUGME 	//get a best finger image
			if(validCount>1 && pre_avg_cur_div> avg_cur_div)
				memcpy(ImgBuf,ImgBuf+ImgSize,ImgSize);
#endif
			pre_avg_cur_div = 0;
			validCount=0;

			return TRUE;
		}else
		{
			pre_avg_cur_div = avg_cur_div;
#ifdef DEBUGME
			memcpy(ImgBuf+ImgSize,ImgBuf,ImgSize);
#endif
			return 0;
		}
	}else
	{
		//_RPT3(0,"else debug me avg_cur_div=%d,avg_diff=%d,avgPixel=%d\n",avg_cur_div,avg_diff,avgPixel);
	//	printf("else debug me avg_cur_div=%d,avg_diff=%d,avgPixel=%d\n",avg_cur_div,avg_diff,avgPixel);
		validCount=0;
		pre_avg_cur_div=0;
		if(LeaveFinger && avgPixel>180)
			return FALSE;// -1;
		else
			return FALSE;
	}
}