GoalSideHistogramPredictor::IntersectionPriorityQueue GoalSideHistogramPredictor::getSortedHistogramIntersections( Histogram histogram, std::vector<Histogram> histograms) { GoalSideHistogramPredictor::IntersectionPriorityQueue intersections; for (size_t i = 0; i < histograms.size(); ++i) { int intersection = histogramIntersection(histogram, histograms[i]); intersections.push(make_pair(i, intersection)); } return intersections; }
double* CSSGen::getWindowFeatureOnFullImageAt(int winI, int winJ) { int flen = getWindowFeatLen(); double* feat = new double[flen]; /*Rect roi(winJ*this->cellSize,winI*this->cellSize,this->winW,this->winH); cout << "Roi is " << roi.x << "," << roi.y << " " << roi.width << " x " << roi.height << endl; Mat roiImg = (*this->img)(roi); this->vizImages.push_back(*this->img); this->vizImages.push_back(roiImg); */ //compute D*(D-1)/2 Differences size_t diffs = 0; for (size_t di = 0; di < D; di++ ) { int fullI = winI + di / cellsPerWindowX; int fullJ = winJ + di % cellsPerWindowX; //cout << "di: " << di << " full " << fullI << ", " << fullJ << endl; double* diHist = &fullHists[cellsN*histDim*fullI + histDim * fullJ]; for ( size_t d = di+1; d < D; d++) { int fulldI = winI + d / cellsPerWindowX; int fulldJ = winJ + d % cellsPerWindowX; //cout << "d: " << d << " full " << fulldI << ", " << fulldJ << endl; double* dHist = &fullHists[cellsN*histDim*fulldI + histDim * fulldJ]; // compute histogram difference feat[diffs] = histogramIntersection(diHist,dHist,maxHistValue); diffs++; } } //cout << "diffs " << diffs << endl; assert(diffs == D*(D-1)/2); //l2normalize(feat,flen); double fnorm = 0.0; for ( int k = 0; k < (int) flen; k++ ) { double val = feat[k]; fnorm += val*val; } //cout << "fnorm " << fnorm << endl; double normalizer = 1.0 / sqrt(fnorm); //cout << "normalizer " << normalizer << endl; for ( int k = 0; k < (int) flen; k++ ) { feat[k] *= normalizer; } bool checkNormOne = false; if ( checkNormOne ) { double normCheck = 0; for ( int k = 0; k < (int) flen; k++ ) { double val = feat[k]; normCheck += val*val; } normCheck = sqrt(normCheck); //cout << "normCheck " << normCheck<< endl; } return feat; }