void TestDetection() { DetectionModule *pDM = new DetectionModule(); pDM->Init("E:\\ImDetection\\ImDetectionApp\\Test\\Rscreen_shortFinger.avi"); pDM->DoDetection(); SimpleFingerDetectionResultSet resultSet; pDM->GetDetectionResult(resultSet); for(int x=0; x<resultSet.m_nFrameNum; x++) { SimpleDetectionResult* &currDR = resultSet.m_arrSimpleDR[x]; WCHAR str[MAX_PATH]; swprintf(str, L"[shooting] %d , fingerNum = %d \n",x,currDR->GetFingerNum()); //cout << str <<endl; OutputDebugStringW(str); //_DPRINTF((L"%d , fingerNum = %d \n",x,m_pDetectionModule->m_arrDetectionResults[x]->m_nFingerNum)); } ParameterSet paramSet; pDM->GetParameters(paramSet); for(int x=0; x<paramSet.GetParamNum(); x++) { cout << "x = " <<x <<"name = " << paramSet.GetParameterName(x) << "value = " << paramSet.GetParameterByIndex(x) <<endl; //printf("%d, %s %d \n",x,paramSet.GetParameterName(x),paramSet.GetParameter(x)); } paramSet.SetParameterByIndex(4,60/255.0); pDM->DoDetection(); delete pDM; }
void TestClasses() { ParamSetAndMeasurement pam; pam = LoaderAndWriter::LoadParameterSetAndMeasurementFromFile("E:\\ImDetection\\ImDetectionApp\\OptimalParameterEstimation\\Result5\\TotalResult.txt"); for(int x=36; x >=30; x--) { vector<int> vecIndex = pam.GetParamSetAndMeasurementSetPairIndexArrByScore(x); char filaname[MAX_PATH]; sprintf(filaname,"E:\\ImDetection\\ImDetectionApp\\OptimalParameterEstimation\\Result5\\%d.txt",x); LoaderAndWriter::WriteSpecificParameterSetAndMeasurementToFile(pam,vecIndex,filaname); } CalculateScore cal; LoaderAndWriter myLoaderAndWriter; { SimpleFingerDetectionResultSet fileResultSet = myLoaderAndWriter.LoadDetectionResultSetFromFile("GT.txt"); SimpleFingerDetectionResultSet resultSetDR = myLoaderAndWriter.LoadDetectionResultSetFromFile("DR.txt"); cal.SetGroundTruth(fileResultSet); cal.SetDetectionResult(resultSetDR); } MeasurementSet ms; cal.DoCalculateScore(&ms); SimpleFingerDetectionResultSet resultSetDR; cal.GetDetectionResult(&resultSetDR); myLoaderAndWriter.WriteDetectionResultSetToFile(resultSetDR,"test_write.txt"); ParamSetAndMeasurementSet pair; { ParameterSet paramSet; paramSet.AddParameter("ABC",10); paramSet.AddParameter("DEf",10); pair.AddParamSetAndMeasurementSetPair(paramSet,ms); } LoaderAndWriter::WriteParameterSetAndMeasurementSetToFile(pair,"paraAndmeasure.txt"); ParameterSet paramSet2; //pair.GetParamSetAndScorePair(0,¶mSet2,&score2); paramSet2; NextParametersGenerator myGenerator; ParameterSet paramSet3; paramSet3.AddParameter("A",0.2); paramSet3.AddParameter("B",10); paramSet3.AddParameter("C",1); ParameterSetRange paramSetRange; paramSetRange.AddParameterRange(0,1,0.2); paramSetRange.AddParameterRange(5,15,5); paramSetRange.AddParameterRange(1,7,2); double low,high,step; paramSetRange.GetParameterRange(0,&low,&high,&step); ParameterSet iteParamSet; bool flagFinish = false; myGenerator.Init(paramSet3,paramSetRange); int counter = 0; while(!flagFinish) { myGenerator.GetNextParamSet(&iteParamSet); for(int x=0; x<iteParamSet.GetParamNum(); x++) { cout << iteParamSet.GetParameterName(x) << "," << iteParamSet.GetParameterByIndex(x) <<endl; } cout << "=================== "<< counter <<endl; myGenerator.GenerateNextParamSet(&flagFinish); counter++; } system("pause"); }