Mat take_pic ( const camera& cam, const float& global_t ) { int frame_idx = global_t; float center_x = int (cam.center_x) + 0.5; float center_y = int (cam.center_y) + 0.5; int L = (center_x + 0.5) - cam.width * cam.zoom / 2; int U = (center_y + 0.5) - cam.height * cam.zoom / 2; Mat frame = imread ( destination + num2string ( frame_idx ) + ".jpg", CV_LOAD_IMAGE_COLOR); Mat sub_img_temp1 = frame( Rect (L, U, cam.width * cam.zoom, cam.height * cam.zoom)).clone(); IplImage* sub_img_temp2 = new IplImage(sub_img_temp1); Image* sub_img = new Image(sub_img_temp2); float v = log(cam.zoom) / 1.33886; GaussianFilter gss(9, 9, v); ImageWarpper wp; Image *down = wp.downSamplePSF( sub_img, 1/cam.zoom, &gss, 0, 0); //down->SaveImage ("zoom_2_diff4.jpg"); Mat down_mat( down->getIplImg(), 1); return down_mat; }
void TDistribution::_calculateNewV(const Mat& m, const vector<double>& EH, const vector<double>& ELogH) { // Use Line Search to search for the best v. CostT ct(this, m, EH, ELogH); GoldenSectionSearch gss(0.1); _v = gss.argmin(ct, 0, 10000); }
void ScorerManager::parseGlobalReflectionSymm() { ////////////////// emit( message("Parse global symmetry starts: ") ); if ( this->actualInputGraphs_.size() < 2) { emit( ("Two graphs needed!") ); return; } double symmScore[2]; for (int i = 0; i < this->actualInputGraphs_.size(); ++i) { Structure::Graph * g = Structure::Graph::actualGraph( this->actualInputGraphs_[i] ); GlobalReflectionSymmScorer gss(g, i, this->normalizeCoef_, this->bUsePart_, this->logLevel_); symmScore[i] = gss.evaluate(); if ( i == 0) { this->refCenter_ = gss.center_; this->refNormal_ = gss.normal_; } } this->maxGlobalSymmScore_ = std::max(symmScore[0], symmScore[1]); //this->maxGlobalSymmScore_ = symmScore[0]; emit( message("Parse global symmetry end. ") ); }
ScorerManager::PathScore ScorerManager::pathScore( QVector<Structure::Graph*> graphs ) { ScorerManager::PathScore score; int N = graphs.size(); int logLevel = 0; QVector<double> connectivity, localSymmetry, globalSymmetry; // Compute all scores at once for (int i = 0; i < N; ++i) { Structure::Graph * g = Structure::Graph::actualGraph(graphs[i] ); // Connectivity ConnectivityScorer cs(g, i, this->normalizeCoef_, this->isUseLink_, logLevel); connectivity.push_back( cs.evaluate(this->connectPairs_, this->gcorr_->correspondences) ); // Local symmetry GroupRelationScorer grs(g, i, this->normalizeCoef_, logLevel); localSymmetry.push_back( grs.evaluate(groupRelations_, this->gcorr_->correspondences) ); // Global symmetry GlobalReflectionSymmScorer gss(g, i, this->normalizeCoef_, logLevel); if (isUseSourceCenter_) globalSymmetry.push_back( gss.evaluate( this->refCenter_, this->refNormal_, this->maxGlobalSymmScore_) ); else globalSymmetry.push_back( gss.evaluate( gss.center_, this->refNormal_, this->maxGlobalSymmScore_) ); // Clean up delete g; } // Fill scores into vectors score.connectivity = VectorXd::Zero(N); score.localSymmetry = VectorXd::Zero(N); score.globalSymmetry = VectorXd::Zero(N); for(int i = 0; i < N; i++) { score.connectivity[i] = connectivity[i]; score.localSymmetry[i] = localSymmetry[i]; score.globalSymmetry[i] = globalSymmetry[i]; graphs[i]->property["scoreConnectivity"] = 1 - connectivity[i]; graphs[i]->property["scoreSymLocal"] = 1 - localSymmetry[i]; graphs[i]->property["scoreSymGlobal"] = 1 - globalSymmetry[i]; double error = qMax(qMax(connectivity[i], localSymmetry[i]), globalSymmetry[i]); graphs[i]->property["score"] = -error; } return score; }
/*+************************************************************************* ** ** Do_gssapi_test ** ** Does the actual call to GSS-client ** ***************************************************************************/ void do_gssapi_test (void) { int n; // Return value HCURSOR hcursor; // For the hourglass cursor hcursor = SetCursor(LoadCursor(NULL, IDC_WAIT)); n = gss (szHost, szService, szMech, szMessage[0] ? szMessage : "Test Gssapi Message", port, verbose, delegate, mutual, replay, sequence, gssv1, !noauth, !nowrap, !nocrypt, !nomic, ccount, mcount, szCCache); SetCursor(hcursor); if (n) MessageBox (NULL, "gss failed", "", IDOK | MB_ICONINFORMATION); }
QVector<double> ScorerManager::evaluateGlobalReflectionSymm( QVector<Structure::Graph*> const &graphs ) { QVector<double> symmScore; int logLevel = 0; double score; for (int i = 0; i < graphs.size(); ++i) { Structure::Graph * g = Structure::Graph::actualGraph(graphs[i] ); GlobalReflectionSymmScorer gss(g, i, this->normalizeCoef_, this->bUsePart_, logLevel); if (isUseSourceCenter_) score = gss.evaluate( this->refCenter_, this->refNormal_, this->maxGlobalSymmScore_); else score = gss.evaluate( gss.center_, this->refNormal_, this->maxGlobalSymmScore_); symmScore.push_back(score); } return symmScore; }
void ScorerManager::evaluateGlobalReflectionSymm() { ///////////////// emit( message("Evaluate global symmetry starts: ") ); if ( !isGlobalReflectionSymmParsed() ) { emit( message("Parse global symmetry first! ") ); return; } int idx(0); Structure::Graph* g = getCurrentGraph(idx); GlobalReflectionSymmScorer gss(g, idx, this->normalizeCoef_, this->bUsePart_, this->logLevel_); double symmScore; if (isUseSourceCenter_) symmScore = gss.evaluate( this->refCenter_, this->refNormal_, this->maxGlobalSymmScore_); else symmScore = gss.evaluate( gss.center_, this->refNormal_, this->maxGlobalSymmScore_); emit( message("Evaluate global symmetry end. ") ); }
int main(int argc, char *argv[]) { int tcount, count, lastsize, size; if ((argc > 4) || (argc < 3)) { FPRINTF(STDOUTFILE "\n\n Usage: %s <# species> <# processors> [<min chunk size>]\n\n", argv[0]); exit(1); } chunksize = 1; switch(argc) { case 4: chunksize = atoi(argv[3]); case 3: n = numquarts(atoi(argv[1])); p = atoi(argv[2]); } FPRINTF(STDOUTFILE "proc=%6d\n", p); FPRINTF(STDOUTFILE "task=%6d\n", n); initsched(&testsched, n, p, chunksize); printsched(testsched); count=1; tcount = 0; FPRINTF(STDOUTFILE "\n\n---------------------------\n"); FPRINTF(STDOUTFILE "SC(sched) - Static Chunking\n"); FPRINTF(STDOUTFILE "---------------------------\n\n"); do { size = sc(&testsched); if (size > 0) {FPRINTF(STDOUTFILE "%6d. chunk = %6d %c\n", count++, size , (size%chunksize) ? '!' : ' '); tcount+=size;} else FPRINTF(STDOUTFILE "%d tasks in %d chunks\n", tcount, (count-1)); } while (size > 0); initsched(&testsched, n, p, chunksize); printsched(testsched); count=1; tcount = 0; FPRINTF(STDOUTFILE "\n\n---------------------------\n"); FPRINTF(STDOUTFILE "SS(sched) - Self Scheduling\n"); FPRINTF(STDOUTFILE "---------------------------\n\n"); do { size = ss(&testsched); if (size > 0) {if (count==1) FPRINTF(STDOUTFILE "%6d. chunk = %6d %c\n", count++, size , (size%chunksize) ? '!' : ' '); count++; tcount+=size; lastsize = size;} else {FPRINTF(STDOUTFILE " ...\n"); FPRINTF(STDOUTFILE "%6d. chunk = %6d %c\n", count++, lastsize , (lastsize%chunksize) ? '!' : ' '); FPRINTF(STDOUTFILE "%d tasks in %d chunks\n", tcount, (count-1));} } while (size > 0); /**/ count=1; tcount = 0; FPRINTF(STDOUTFILE "\n\n---------------------------\n"); FPRINTF(STDOUTFILE "FSC() - Fixed-Size Chunking\n"); FPRINTF(STDOUTFILE "---------------------------\n\n"); do { size = fsc(); if (size > 0) {FPRINTF(STDOUTFILE "%6d. chunk = %6d %c\n", count++, size , (size%chunksize) ? '!' : ' '); tcount+=size;} else FPRINTF(STDOUTFILE "%d tasks in %d chunks\n", tcount, (count-1)); } while (size > 0); /**/ initsched(&testsched, n, p, chunksize); printsched(testsched); count=1; tcount = 0; FPRINTF(STDOUTFILE "\n\n-----------------------------------\n"); FPRINTF(STDOUTFILE "GSS(sched) - Guided Self Scheduling\n"); FPRINTF(STDOUTFILE "-----------------------------------\n\n"); do { size = gss(&testsched); if (size > 0) {FPRINTF(STDOUTFILE "%6d. chunk = %6d %c\n", count++, size , (size%chunksize) ? '!' : ' '); tcount+=size;} else FPRINTF(STDOUTFILE "%d tasks in %d chunks\n", tcount, (count-1)); } while (size > 0); initsched(&testsched, n, p, chunksize); printsched(testsched); count=1; tcount = 0; FPRINTF(STDOUTFILE "\n\n--------------------------------------\n"); FPRINTF(STDOUTFILE "TSS(sched) - Trapezoid Self Scheduling\n"); FPRINTF(STDOUTFILE "--------------------------------------\n\n"); do { size = tss(&testsched); if (size > 0) {FPRINTF(STDOUTFILE "%6d. chunk = %6d %c\n", count++, size , (size%chunksize) ? '!' : ' '); tcount+=size;} else FPRINTF(STDOUTFILE "%d tasks in %d chunks\n", tcount, (count-1)); } while (size > 0); return (0); }
SVVector ngss(int n) { SVVector r=newSVV(n); int i; for(i=0;i<n;i++)r->value[i]=gss(); return r; }
IVector gis(void) { SVector v=gss();IVector r=newIV(v->size);int i;for(i=0;i<v->size;i++)r->value[i]=ti(v->value[i]);return r;}