void normalizeLineSet(lineSet & lineSet, ofPolyline & input){
    
    ofPolyline output = input;
    vector< float > x;
    vector< float > y;
    for (int i = 0; i < output.getVertices().size(); i++){
        x.push_back(output[i].x);
        y.push_back(output[i].y);
    }
    float sumx, meanx, varx, devx, skewx, kurtx;
    float sumy, meany, vary, devy, skewy, kurty;
    computeStats(x.begin( ), x.end( ), sumx, meanx, varx, devx, skewx, kurtx);
    computeStats(y.begin( ), y.end( ), sumy, meany, vary, devy, skewy, kurty);
    float stdDev = sqrt(devx*devx + devy*devy);
    ofPoint midPt (meanx, meany);
    ofPoint dev (stdDev, stdDev);
    
    ofMatrix4x4 mat;
    mat.makeTranslationMatrix(-midPt.x, -midPt.y, 0);
    
    ofMatrix4x4 mat2;
    mat2.makeScaleMatrix(100.0/dev.x, 100.0/dev.y, 1.0);
    
    
    lineSet.normalizeLines = lineSet.lines;
    
    for (int i = 0; i < lineSet.normalizeLines.size(); i++){
        for (int j = 0; j < lineSet.normalizeLines[i].size(); j++){
            lineSet.normalizeLines[i][j] = lineSet.normalizeLines[i][j]  * mat * mat2;
        }
    }
}
示例#2
0
文件: main.cpp 项目: jcnossen/qtrk
void TestQuadrantAlign()
{
	QTrkSettings cfg;
	cfg.width = cfg.height = 60;
	cfg.numThreads=1;
	
//	auto locMode = (LocMode_t)(LT_ZLUTAlign | LT_NormalizeProfile | LT_LocalizeZ);
//	auto resultsCOM = RunTracker<QueuedCPUTracker> ("lut000.jpg", &cfg, false, "com-zlutalign", locMode, 100 );

	const float NF=10;

#ifdef _DEBUG
	int N=1;
	cfg.numThreads=1;
#else
	int N=2000;
#endif

	auto locModeQI = (LocMode_t)(LT_QI | LT_NormalizeProfile | LT_LocalizeZ);
	auto resultsQI = RunTracker<QueuedCPUTracker> ("lut000.jpg", &cfg, false, "qa", locModeQI, N, NF);

	auto locMode = (LocMode_t)(LT_QI | LT_ZLUTAlign | LT_NormalizeProfile | LT_LocalizeZ);
	auto resultsZA = RunTracker<QueuedCPUTracker> ("lut000.jpg", &cfg, false, "qa-qalign", locMode, N, NF );
	
	resultsZA.computeStats(); 
	resultsQI.computeStats();

	dbgprintf("QuadrantAlign: X= %f. stdev: %f\tZ=%f,  stdev: %f\n", resultsZA.meanErr.x, resultsZA.stdev.x, resultsZA.meanErr.z, resultsZA.stdev.z);
	dbgprintf("Only QI:   X= %f. stdev: %f\tZ=%f,  stdev: %f\n", resultsQI.meanErr.x, resultsQI.stdev.x, resultsQI.meanErr.z, resultsQI.stdev.z);
}
transformation normalizeLineSetGetTrans (ofPolyline & input){
    
    transformation t;
    ofPolyline output = input;
    vector< float > x;
    vector< float > y;
    for (int i = 0; i < output.getVertices().size(); i++){
        x.push_back(output[i].x);
        y.push_back(output[i].y);
    }
    float sumx, meanx, varx, devx, skewx, kurtx;
    float sumy, meany, vary, devy, skewy, kurty;
    computeStats(x.begin( ), x.end( ), sumx, meanx, varx, devx, skewx, kurtx);
    computeStats(y.begin( ), y.end( ), sumy, meany, vary, devy, skewy, kurty);
    float stdDev = sqrt(devx*devx + devy*devy);
    ofPoint midPt (meanx, meany);
    ofPoint dev (stdDev, stdDev);
    
    //ofMatrix4x4 mat;
    t.mat.makeTranslationMatrix(-midPt.x, -midPt.y, 0);
    
    //ofMatrix4x4 mat2;
    t.mat2.makeScaleMatrix(100.0/dev.x, 100.0/dev.y, 1.0);
    return t;
}
示例#4
0
文件: main.cpp 项目: jcnossen/qtrk
void TestFourierLUT()
{
	QTrkSettings cfg;
	cfg.width = cfg.height = 60;
	cfg.zlut_minradius=3;
	cfg.zlut_roi_coverage=1;
	
//	auto locMode = (LocMode_t)(LT_ZLUTAlign | LT_NormalizeProfile | LT_LocalizeZ);
//	auto resultsCOM = RunTracker<QueuedCPUTracker> ("lut000.jpg", &cfg, false, "com-zlutalign", locMode, 100 );

	const float NF=28;
	float zpos=10;
	
	auto locMode = (LocMode_t)(LT_QI | LT_FourierLUT | LT_NormalizeProfile | LT_LocalizeZ);
	auto resultsZA = RunTracker<QueuedCPUTracker> ("lut000.jpg", &cfg, false, "qi-fourierlut",	locMode, 200, NF,zpos);

	auto locModeQI = (LocMode_t)(LT_QI | LT_NormalizeProfile | LT_LocalizeZ);
	auto resultsQI = RunTracker<QueuedCPUTracker> ("lut000.jpg", &cfg, false, "qi",	locModeQI, 200, NF, zpos);

	resultsZA.computeStats(); 
	resultsQI.computeStats();

	dbgprintf("FourierLUT: X= %f. stdev: %f\tZ=%f,  stdev: %f\n", resultsZA.meanErr.x, resultsZA.stdev.x, resultsZA.meanErr.z, resultsZA.stdev.z);
	dbgprintf("Only QI:   X= %f. stdev: %f\tZ=%f,  stdev: %f\n", resultsQI.meanErr.x, resultsQI.stdev.x, resultsQI.meanErr.z, resultsQI.stdev.z);
}
ofPolyline returnNormalizedLine (ofPolyline & input){
    ofPolyline output = input;
    vector< float > x;
    vector< float > y;
    for (int i = 0; i < output.getVertices().size(); i++){
        x.push_back(output[i].x);
        y.push_back(output[i].y);
    }
    float sumx, meanx, varx, devx, skewx, kurtx;
    float sumy, meany, vary, devy, skewy, kurty;
    computeStats(x.begin( ), x.end( ), sumx, meanx, varx, devx, skewx, kurtx);
    computeStats(y.begin( ), y.end( ), sumy, meany, vary, devy, skewy, kurty);
    float stdDev = sqrt(devx*devx + devy*devy);
    ofPoint midPt (meanx, meany);
    ofPoint dev (stdDev, stdDev);
    
    
    ofMatrix4x4 mat;
    mat.makeTranslationMatrix(-midPt.x, -midPt.y, 0);
    
    ofMatrix4x4 mat2;
    mat2.makeScaleMatrix(100.0/dev.x, 100.0/dev.y, 1.0);
    // mat.scale(100,100,1.0);
    
    //mat *= mat2;
    
    
    for (int i = 0; i < output.getVertices().size(); i++){
        
        ofPoint input = output[i];
        
        output[i] -= midPt;
        output[i] /= dev;
        output[i]*= 100.0;
        
        //        cout << output[i] << endl;
        //        cout << "--> " << input << endl;
        //        cout << input * mat * mat2 << endl;
        //        cout << "--> " << (input * mat * mat2) * mat2.getInverse() * mat.getInverse() << endl;
        
    }
    //    ofRectangle boxOrig = input.getBoundingBox();
    //    ofRectangle box = boxOrig;
    //    ofRectangle outputBox(-100,-100,200,200);
    //    box.scaleTo(outputBox);
    //
    //    for (int i = 0; i < output.getVertices().size(); i++){
    //        output.getVertices()[i].x = ofMap( output.getVertices()[i].x, boxOrig.position.x, boxOrig.position.x + boxOrig.width,
    //                                           box.position.x, box.x + box.width);
    //        output.getVertices()[i].y = ofMap( output.getVertices()[i].y, boxOrig.position.y, boxOrig.position.y + boxOrig.height,
    //                                          box.position.x, box.y + box.height);
    //
    //    }
    
    return output;
    
}
示例#6
0
/**
 * computes a (reasonably) pretty printed portion of that part of this object
 * that deals with the computed statistics
 * @returns a string suitable for direct display as plain text
 */
static char *statsToString(Timings *t) {
   computeStats(t);
   if (t->iterations == 1) (char *)calloc(1, sizeof(char)); /* in case some twit tries to free this */
   else {
 	 char *answer = calloc(500+ 8*128*t->iterations, sizeof(char));
      int leaderSize = 0;
      int n, length, delta, descSize;
      int cursor;
      for(n = 0; n<t->phases; n++) {
         length = strlen(t->phaseDescriptions[n]);
         if (length>leaderSize) leaderSize = length;
      }
      delta = leaderSize%4 != 0 ? 4-leaderSize%4 : 0;
      for(n=0; n<leaderSize+delta; n++) answer[n] = ' ';
      strcat(answer, "     Min      Mean      Median     Max     Sigma\r\n");
      for(n= 0;  n<t->phases; n++) {
         strcat(answer, t->phaseDescriptions[n]);
         cursor = strlen(answer);
         descSize = strlen(t->phaseDescriptions[n]);
         while(descSize++<leaderSize) answer[cursor++] = ' ';
         catPaddedInt(answer, t->maxs[n]);
         catPaddedInt(answer, t->means[n]);
         catPaddedInt(answer, t->medians[n]);
         catPaddedInt(answer, t->mins[n]);
         catPaddedInt(answer, floor(t->sigmas[n]));
         strcat(answer, "\r\n");
      }
      return answer;
   }
}
示例#7
0
void Report::end()
{
    if (!initialized || written)
        return;
    // Make report iff (#mismatches>0) || (#fuzzymatches>0) || (#errors>0 && settings say report errors)
    bool doReport = (numMismatches > 0);
    if (!doReport) {
        bool reportErrors = settings->value("ReportMissingResults").toBool();
        computeStats();
        foreach (const QString &func, itemLists.keys()) {
            FuncStats stat = stats.value(func);
            if (stat.value(ImageItem::FuzzyMatch) > 0) {
                doReport = true;
                break;
            }
            foreach (const ImageItem &item, itemLists.value(func)) {
                if (reportErrors && item.status == ImageItem::Error) {
                    doReport = true;
                    break;
                }
            }
            if (doReport)
                break;
        }
    }
示例#8
0
文件: dtree.cpp 项目: ngoix/OCRF
u_int 		DTree::stat_getNbLeavesTarget()
{
	if(stats.bLeavesTarget == false)
		computeStats(root);

	return stats.nbLeavesTarget;
}
示例#9
0
文件: dtree.cpp 项目: ngoix/OCRF
/* ********************************************************
 * Gives the number of level in the tree structure. This method automatically call the computeStats method if it has not been done before.
 */
u_int 		DTree::stat_getNbLevels()
{
	if(stats.bLevels == false)
		computeStats(root);

	return stats.nbLevels;
}
示例#10
0
文件: dtree.cpp 项目: ngoix/OCRF
u_int 		DTree::stat_getNbLeavesOutlier()
{
	if(stats.bLeavesOutlier == false)
		computeStats(root);

	return stats.nbLeavesOutlier;
}
示例#11
0
文件: dtree.cpp 项目: ngoix/OCRF
/* ********************************************************
 * Gives the number of nodes in the tree. This method automatically call the computeStats method if it has not been done before.
 */
u_int 		DTree::stat_getNbNodes()
{
	if(stats.bNodes == false)
		computeStats(root);

	return stats.nbNodes;
}
示例#12
0
文件: dtree.cpp 项目: ngoix/OCRF
/* ********************************************************
 * Recursive method that allow to compute the statistics of the tree structure after it has already been built
 * param
 *		node: the current node, reached during the recursive process
 */
void 		DTree::computeStats(Node * node)
{
	stats.nbNodes++;
	if(node->is_leaf()) {



	    stats.nbLeaves++;

	    u_int c=node->getPrediction();
	    if(c==1) stats.nbLeavesOutlier++;
	    if(c==0) stats.nbLeavesTarget++;


	    //cerr<<"node is leaf:"<<node->getId()<<"/"<<stats.nbLeaves<<"/"<<stats.nbLeavesTarget<<"/"<<stats.nbLeavesOutlier<<endl;

	}
	if(stats.nbLevels <= node->getLvl()) stats.nbLevels = node->getLvl()+1;

	for(u_int i=0;i<node->getNbChildren();i++)
		computeStats(node->getChild(i));

	stats.bNodes = true;
	stats.bLeaves = true;
	stats.bLeavesTarget = true;
	stats.bLeavesOutlier = true;
	stats.bLevels = true;
}
示例#13
0
文件: dtree.cpp 项目: ngoix/OCRF
/* ********************************************************
 * Gives a printable string of tree structure. If the number of nodes is more than 30, only statistics are returned in the string.
 */
string 		DTree::toString()
{
	string out = "";
	if(!stats.bLevels || !stats.bLeaves || !stats.bNodes) computeStats(root);
	if(stats.nbNodes < 30) out += (*root).toString();

	out += statsToString();

	return out;
}
示例#14
0
文件: dtree.cpp 项目: ngoix/OCRF
/* ********************************************************
 * Gives a printable string of the statistics of the tree.
 */
string 		DTree::statsToString()
{
	if(!stats.bLevels || !stats.bLeaves || !stats.bNodes) computeStats(root);

	string out;
	out += "\n Arbre de Décision construit en "; out += Utils::to_string((double) stats.timeTrain); out += " secondes";
	out += " \n Description : \n";
	out += "\t "; out += Utils::to_string((int)stats.nbNodes); out += " nodes \n";
	out += "\t "; out += Utils::to_string((int)stats.nbLeaves); out += " leaves \n";
	out += "\t "; out += Utils::to_string((int)stats.nbLevels); out += " levels \n";
	out += "\n\t for a training set of " ; out += Utils::to_string((int) trainSet->w_size()); out += " instances\n";
	return out;
}
示例#15
0
文件: main.cpp 项目: jcnossen/qtrk
void TestZLUTAlign()
{
	QTrkSettings cfg;
	cfg.width = cfg.height = 60;
	
//	auto locMode = (LocMode_t)(LT_ZLUTAlign | LT_NormalizeProfile | LT_LocalizeZ);
//	auto resultsCOM = RunTracker<QueuedCPUTracker> ("lut000.jpg", &cfg, false, "com-zlutalign", locMode, 100 );

	const float NF=28;

	auto locModeQI = (LocMode_t)(LT_QI | LT_NormalizeProfile | LT_LocalizeZ);
	auto resultsQI = RunTracker<QueuedCPUTracker> ("lut000.jpg", &cfg, false, "qi", locModeQI, 200, NF);

	auto locMode = (LocMode_t)(LT_QI | LT_ZLUTAlign | LT_NormalizeProfile | LT_LocalizeZ);
	auto resultsZA = RunTracker<QueuedCPUTracker> ("lut000.jpg", &cfg, false, "qi-zlutalign", locMode, 200, NF );

	resultsZA.computeStats(); 
	resultsQI.computeStats();

	dbgprintf("ZLUTAlign: X= %f. stdev: %f\tZ=%f,  stdev: %f\n", resultsZA.meanErr.x, resultsZA.stdev.x, resultsZA.meanErr.z, resultsZA.stdev.z);
	dbgprintf("Only QI:   X= %f. stdev: %f\tZ=%f,  stdev: %f\n", resultsQI.meanErr.x, resultsQI.stdev.x, resultsQI.meanErr.z, resultsQI.stdev.z);
}
示例#16
0
文件: main.cpp 项目: jcnossen/qtrk
void SimpleTest()
{
	QTrkSettings cfg;
	cfg.qi_minradius=0;
	cfg.zlut_minradius = 0;
	cfg.width = cfg.height = 30;
	auto locModeQI = (LocMode_t)(LT_QI | LT_NormalizeProfile | LT_LocalizeZ);
	auto results = RunTracker<QueuedCPUTracker> ("lut000.jpg", &cfg, false, "qi", locModeQI, 1000, 10000/255 );

	results.computeStats();
	dbgprintf("X= %f. stdev: %f\tZ=%f,  stdev: %f\n", 
		results.meanErr.x, results.stdev.x, results.meanErr.z, results.stdev.z);
}
示例#17
0
HLayeredBlWStructure::HLayeredBlWStructure( const double *m_vec, 
    size_t q, size_t n, const double *w_vec  ) : myQ(q), myN(n), mySA(NULL)  {
  mySA = new Layer[myQ];
 
  for (size_t l_1 = 0; l_1 < myQ; ++l_1) {
    mySA[l_1].blocks_in_row = m_vec[l_1];
    if (w_vec != NULL && !(w_vec[l_1] > 0)) {
      throw new Exception("This value of weight is not supported: %lf\n", w_vec[l_1]);
    }
    mySA[l_1].inv_w = (w_vec != NULL) ? (1 / w_vec[l_1]) : 1.0;
  }    
   
  computeStats(); 
  computeVkParams();
}