Esempio n. 1
0
void ASEF_Algorithm::findEyes(Mat faceImage) {
    vector<Rect> eyeRectsVector(2);
    eyeFound = false;
    if (faceImage.size().area() >0) {
        input_image = faceImage;
        int widthBase  = 150;
        double imageSizeScale = 1.0*faceImage.size().width*1.0/faceImage.size().height;
        Mat color_img = faceImage.clone(), eye_img, gray_img;
        resize(color_img, eye_img, Size(widthBase, cvRound(widthBase/imageSizeScale)));
        cvtColor(eye_img, gray_img, CV_BGR2GRAY);
        equalizeHist(gray_img, gray_img);
        this->detecteyes(gray_img);
        
        double x = 1.0*this->left_eye.x/(double)widthBase*faceImage.size().width;
        double y = 1.0*this->left_eye.y/(double)widthBase*imageSizeScale*faceImage.size().height;
        Point cC(faceImage.size().width/8,faceImage.size().width/14);
        
        leftEyePoint = Point(cvRound(x),cvRound(y));
        leftEyeRect = Rect(0,0,faceImage.size().width/4,faceImage.size().width/7);
        leftEyeRect += leftEyePoint;
        leftEyeRect -= cC;
        
        x = 1.0*this->right_eye.x*1.0/(double)widthBase*faceImage.size().width;
        y = 1.0*this->right_eye.y/(double)widthBase*imageSizeScale*faceImage.size().height;
        
        rightEyePoint = Point(cvRound(x),cvRound(y));
        rightEyeRect = Rect(0,0,faceImage.size().width/4,faceImage.size().width/7);
        rightEyeRect += rightEyePoint;
        rightEyeRect -= cC;
        
        eyeFound = true;
    }
    
}
Esempio n. 2
0
/* Procedural texture function */
int ptex_fun(float u, float v, GzColor color)
{
	//Complex cC(-0.1011, 0.9563), cX(u, v);
	//Complex cC(-0.123, 0.745), cX(2*(u-0.5), 2*(v-0.5));
	Complex cC(-0.72375, 0.26805), cX(2*(u-0.5), 2*(v-0.5));
	int N = 10;
	float len;

	for (int i = 0; i < N; i++) {
		Complex cTemp1 = (cX * cX);
		Complex cTemp2 = (cTemp1 + cC);

		len = cTemp2.length();
		cX = cTemp2;
		if ((len < lowerLim) || (len > upperLim))
			break;
		//cX = cTemp2;
	}
	len = cX.length();
	linearInterpolate(len, color);

	return GZ_SUCCESS;
}
Esempio n. 3
0
void getCluAvgEff(Char_t* signalFile="signalShapes.root", Int_t diskNr=3, Bool_t onlyQuadB=false)
{
  gStyle->SetPalette(1);
  gStyle->SetOptStat(0);
   plFgtQuads_dbMap();

   TFile f(signalFile);
   //TFile f("signalShapes.root");
 char buffer[100];

 sprintf(buffer,"allClusterCountsDisk_%d",diskNr);//counting different for this histo
 TH2D* hEff=(TH2D*)f.Get(buffer);

 sprintf(buffer,"radioDiskNonEff_%d",diskNr-1);
 TH2D* hNonEff=(TH2D*)f.Get(buffer);
 // hEff->Rebin2D(2,2); //merge wo bins...
 // hNonEff->Rebin2D(2,2);

 Double_t max=hEff->GetXaxis()->GetXmax();
 Double_t min=hEff->GetXaxis()->GetXmin();
 Int_t minCounts=10;
 // cout <<"max: " << max << " min: " << min << " numBins: "<< h->GetNbinsX() <<endl;

 TH2D OverallEff("overallEff","overallEff",hEff->GetNbinsX(),min,max,hEff->GetNbinsY(),min,max);
 TH2D OverallCounts("overallCounts","overallCounts",hEff->GetNbinsX(),min,max,hEff->GetNbinsY(),min,max);
 TH2D OverallFound("overallFound","overallFound",hEff->GetNbinsX(),min,max,hEff->GetNbinsY(),min,max);
 OverallEff.GetXaxis()->SetTitle("x [cm]");
 OverallEff.GetYaxis()->SetTitle("y [cm]");
 OverallCounts.GetXaxis()->SetTitle("x [cm]");
 OverallCounts.GetYaxis()->SetTitle("y [cm]");
 OverallFound.GetXaxis()->SetTitle("x [cm]");
 OverallFound.GetYaxis()->SetTitle("y [cm]");



Double_t eff=0;
Int_t count=0;

 Int_t sumEff=0;
 Int_t sumNonEff=0;

 Double_t overallErr=0;
for(Int_t i=1;i<hEff->GetNbinsX()+1;i++)
  {
    for(Int_t j=1;j<hEff->GetNbinsY()+1;j++)
      {
	///do you only want to use Quad B?
	if(onlyQuadB)
	  {
	    if(i<(hEff->GetNbinsX()-1)/2|| j>(hEff->GetNbinsY()-1)/2)
	      continue;
	  }
	//Int_t gBin=h->GetBin(i,j);
	//	Double_t xpos=h->GetXaxis()->GetBinCenter(gBin);
	//	Double_t ypos=h->GetYaxis()->GetBinCenter(gBin);
	//	if(xpos<0 || ypos >0)
	//	  continue;


	    Int_t numEff=hEff->GetBinContent(i,j);
	    Int_t numNonEff=hNonEff->GetBinContent(i,j);
	    Int_t numCounts=numEff+numNonEff;
	    //	    cout <<"numEff: " << numEff <<" nonEff: " << numNonEff << " counts: " << numCounts<<endl;
	    Double_t efficiency=0;
	    if(numCounts>minCounts)
	      {
		efficiency=(Double_t)numEff/(Double_t)numCounts;
	      }
	    if(numEff>0)
	      {
		sumEff+=numEff;
		sumNonEff+=numNonEff;
	      }
	    OverallEff.SetBinContent(i,j,efficiency);
	    OverallCounts.SetBinContent(i,j,numCounts);
	    OverallFound.SetBinContent(i,j,numEff);

	if(numCounts>minCounts)
	  {
	    //
	    Double_t relErr=999;
	    Double_t err=999;
	    if(numEff>0)
	      {
		relErr=sqrt((1/(Double_t)(numEff+numNonEff)+1/(Double_t)numEff));
		err=relErr*efficiency;

	      }
	    else
	      {
		err=1/sqrt(numNonEff);
	      }
	    eff+=efficiency/(err*err);
	    overallErr+=(1/(err*err));

	    count++;
	  }
      }
  }

 Double_t avgEff=sumEff/(Double_t)(sumEff+sumNonEff);
 //binomial error, beware of 0
 Double_t errOnEffNum=sqrt(avgEff*(1-avgEff)*(sumEff+sumNonEff));
 Double_t altErr= ((Double_t)1/(Double_t)(sumEff+sumNonEff))*sqrt(sumEff*(Double_t)(1-sumEff/(sumEff+sumNonEff)));
 sprintf(buffer,"Average Efficiency is %f +- %f",avgEff,altErr);
 //15 degrees
 Float_t rotationRadians=-0.261799388;
 Float_t rotationRadians2=-1.83259571;
 Float_t rotation=-15;
 Float_t innerR=11.5;
 Float_t outerR=38;
 TLatex t1(-30,0,buffer);
 TArc outerA(0,0,outerR,90+rotation,-90+rotation);
 TArc innerA(0,0,innerR,90+rotation,-90+rotation);
 // cout <<"cos rot: " << cos(rotation) <<" sin: " << sin(rotation) <<endl;
 TLine l1(innerR*cos(rotationRadians),innerR*sin(rotationRadians),outerR*cos(rotationRadians),outerR*sin(rotationRadians));
 TLine l2(innerR*cos(rotationRadians2),innerR*sin(rotationRadians2),outerR*cos(rotationRadians2),outerR*sin(rotationRadians2));
 l1.SetLineWidth(3);
 l2.SetLineWidth(3);
 outerA.SetLineWidth(3);
 innerA.SetLineWidth(3);

 // plGood();

 int apvMap[]={5,6,7,8,9,12,13,14,15,16};
 char buffer2[200];
 TCanvas* c2=new TCanvas("ceff","ceff",1,1,800,800);
 for(int i=0;i<10;i++)
   {
     //     sprintf(buffer2,"cD%d_apv%d",diskNr,i);
     //     c2=new TCanvas(buffer2,buffer2,1,1,800,800);
     if(i==0)
       {
	 sprintf(buffer2,"overallEff_D%d.pdf(",diskNr);
	 Char_t buffer3[100];
	 sprintf(buffer3,"overallEff_D%d.png",diskNr);
     OverallEff.Draw("colz");
     outerA.Draw();
     innerA.Draw();
     OverallEff.Draw("same colz");

     t1.Draw();
     l1.Draw();
     l2.Draw();
	 c2.SaveAs(buffer3);
       }
     else
       {
	 if(i==9)
	   sprintf(buffer2,"overallEff_D%d.pdf)",diskNr);
	 else
	   sprintf(buffer2,"overallEff_D%d.pdf",diskNr);
       }
     OverallEff.Draw("colz");
     outerA.Draw();
     innerA.Draw();
     
     OverallEff.Draw("same colz");
     t1.Draw();
     l1.Draw();
     l2.Draw();
     sprintf(buffer,"overallEff_D%d_APV%d.pdf",diskNr,apvMap[i]);
     plAPV(apvMap[i],1,'B');
     c2->SaveAs(buffer);
     cout <<"printing to " << buffer2 <<endl;
     c2->Print(buffer2,"pdf");
 }
 TCanvas c("effs","effs",1,1,800,800);


 //counts

 TCanvas cC("counts","counts",1,1,800,800);
 OverallCounts.Draw("colz");
 outerA.Draw();
 innerA.Draw();
 
 OverallCounts.Draw("same colz");
 l1.Draw();
 l2.Draw();
 cC.SaveAs("overallCounts.png");


 TCanvas cf("found","found",1,1,800,800);
 OverallFound.Draw("colz");
 outerA.Draw();
 innerA.Draw();
 OverallFound.Draw("same colz");
 l1.Draw();
 l2.Draw();
 cf.SaveAs("overallFound.png");

 sprintf(buffer,"overall found");
 sprintf(buffer2,"cFoundD",diskNr);
 c2=new TCanvas(buffer2,buffer2,1,1,800,800);
 TLatex t2(-30,0,buffer);
 for(int i=0;i<10;i++)
   {
     if(i==0)
       {
	 sprintf(buffer2,"overallFound_D%d.pdf(",diskNr);
	 Char_t buffer3[100];
	 sprintf(buffer3,"overallFound_D%d.png",diskNr);
	 sprintf(buffer2,"overallFound_D%d.pdf(",diskNr);
	 OverallFound.Draw("colz");
     outerA.Draw();
     innerA.Draw();
	 OverallFound.Draw("same colz");
 l1.Draw();
 l2.Draw();
	 c2.SaveAs(buffer3);
       }
     else
       {
	 if(i==9)
	   sprintf(buffer2,"overallFound_D%d.pdf)",diskNr);
	 else
	   sprintf(buffer2,"overallFound_D%d.pdf",diskNr);
       }
     OverallEff.Draw("colz");
     outerA.Draw();
     innerA.Draw();
     
     //     OverallFound.Draw("same colz");
     t2.Draw();
     l1.Draw();
     l2.Draw();
     sprintf(buffer,"overallFound_D%d_APV%d.png",diskNr,apvMap[i]);
     plAPV(apvMap[i],1,'B');
     c2.SaveAs(buffer);
     cout <<"printing to " << buffer2 <<endl;
     c2->Print(buffer2,"pdf");
 }






 // c.SaveAs("overallEff.C");
//cout <<"avg eff: " << eff/count <<endl;
 cout <<"Hits found: " << sumEff <<" Hits not found: " << sumNonEff<< " efficiency: " <<avgEff<<" +- " << altErr<<endl;

}