void main(int argc,String *argv) { ArgParser a=ArgParser(argc,argv); String dir=a.argor("directory","../../"); ordering=( a.argexists("-s") ? &orderbysize : a.argexists("-d") ? &orderbydate : &orderbysize ); a.done(); DirRec dr=DirRec(dir); Scene *s=new Scene(); Renderer *r=new WireframeRenderer(); Avatar *av=new Avatar(); adddirtoscene(s,&dr,V3d::origin,V3d::j); ImageType *m=new ImageType(scrwid,scrhei,0); while (!key[KEY_ESC]) { r->renderimage(m,s,&(av->v)); makepalette(&greypalette); m->writetoscreen(); av->move(); } // m->writefile("rendered.bmp"); }
void main(int argc,String *argv) { ArgParser a=ArgParser(argc,argv); int as=a.intafter("-as","angles examined",16); bool showpp=a.argexists("-spp","show winning projection profile"); bool showpps=a.argexists("-spps","show all projection profiles"); String bname=a.getarg("binary image"); a.done(); Map2d<bool> binimg=*Map2d<bool>::readfile(bname)->threshold(0.5); ProjectionProfiler pp=ProjectionProfiler(as,binimg); pp.showpps=showpps; pp.showpp=showpp; float ang=pp.getlineangle(); Pixel cen=Pixel(binimg.width/2,binimg.height/2); Pixel diff=Pixel(V2d::angle(ang)*binimg.width); binimg.line(cen-diff,cen+diff,true); #ifdef USINGJFONT jfont.writeString(Sformat("entropy=%.5f",lowestent),&binimg,0,10,8.0,true); #endif binimg.writefile("result.bmp"); }
void main(int argc,String *argv) { ArgParser a=ArgParser(argc,argv); String iname=a.getarg(); String fname=Sconc("home/joey/images/",iname,".bmp"); String ename=Sconc("home/joey/images/exp",iname,".bmp"); a.done(); randomise(); image=RGBmp::readfile(fname)->getv3ds(); greyscale=image->applyfn(&V3dtofloat); greyscale->edgedetection(Map2d<float>::sobel(),&edgemag,&edgeang); expected=Map2d<float>::readfile(ename)->scaleto(image->width,image->height)->threshold(0.5); printf("Starting segmentation...\n"); Seg seg=Seg(&measureglvariance); // Seg seg=Seg(&classifytrain); // Map2d<bool> *b=seg.classifytopdown(); Map2d<bool> *b=seg.classifyneighbours(); // Map2d<bool> *b=seg.classifywindows(); // b->scaleto(expected->width,expected->height)->writefile("textseg.bmp"); }
void BGSEEConsoleCmd_LoadForm_ExecuteHandler(BGSEECONSOLECMD_ARGS) { SME::StringHelpers::Tokenizer ArgParser(Args, " ,"); std::string CurrentArg; std::string EditorID; for (int i = 1; i <= ParamCount; i++) { ArgParser.NextToken(CurrentArg); switch (i) { case 1: EditorID = CurrentArg; break; } } TESForm* Form = TESForm::LookupByEditorID(EditorID.c_str()); if (Form) { TESDialog::ShowFormEditDialog(Form); } else BGSEECONSOLE_MESSAGE("Couldn't load form '%s' for editing. Recheck the editorID argument.", EditorID.c_str()); }
void main(int argc,String *argv) { ArgParser a=ArgParser(argc,argv); String fname=a.getarg(1); String search=a.getarg(1); String replace=a.getarg(1); a.done(); List<char> replacelist; for (int i=1;i<=Slen(replace);i++) replacelist.add(replace[i]); c=readbinaryfile(fname); int cnt=0; for (int i=1;i<=c->len-Slen(search)+1;i++) { if (match(search,i)) { c->removenumkeeporder(i,Slen(search)); c->insert(i,replacelist); i+=Slen(replace)-1; cnt++; } } writebinaryfile(Sconc(fname,".sr"),c); printf("sreplace %s : %i replacements made.\n",fname,cnt); }
int main(int argc, char** argv) { string configFile; bool result = ArgParser({ Option('f', "config", OptionFlags::RequiredArg, [&](string val) { configFile = val; }) }).Run(argc, argv); if (configFile.empty()) { fprintf(stderr, "CoeusFTP: Please specify a config file\n"); usage(); return 1; } FTPConfig config; if (!config.Load(configFile)) { fprintf(stderr, "CoeusFTP: Failed to load config file %s\n", configFile.c_str()); return 1; } std::thread ftpThread([&](){ FTPServer* pServer = new FTPServer(config); pServer->Run(); delete pServer; }); ftpThread.join(); return 0; }
void main(int argc,String *argv) { ArgParser a=ArgParser(argc,argv); int as=a.intafter("-as","angles examined",16); String bname=a.getarg("binary image"); a.done(); Map2d<bool> binimg=*Map2d<bool>::readfile(bname)->threshold(0.5); List<float> angs; for (float a=0;a<=pi;a+=pi/(float)as) angs.add(a); List<Map1d<int> > pps=getprojprofiles(binimg,angs); float lowestent=0.0; int lowestind=-1; for (int i=1;i<=pps.len;i++) { // Map2d<bool> d=pps.p2num(i)->draw(); float ent=pps.p2num(i)->entropy(); if (ent<lowestent) { lowestent=ent; lowestind=i; } // jfont.writeString(Sformat("%.5f",ent),&d,0,12,10.0,true); // d.writefile(getnextfilename("pp","bmp")); // d.freedom(); } float ang=lowestind*pi/(float)as; Pixel cen=Pixel(binimg.width/2,binimg.height/2); Pixel diff=Pixel(V2d::angle(ang)*binimg.width); binimg.line(cen-diff,cen+diff,true); jfont.writeString(Sformat("entropy=%.5f",lowestent),&binimg,0,10,8.0,true); binimg.writefile("result.bmp"); printf("Lowest was %i with %.5f\n",lowestind,lowestent); }
void BGSEEConsoleCmd_Crash_ExecuteHandler(BGSEECONSOLECMD_ARGS) { SME::StringHelpers::Tokenizer ArgParser(Args, " ,"); std::string CurrentArg; bool Assertion = false; for (int i = 1; i <= ParamCount; i++) { ArgParser.NextToken(CurrentArg); switch (i) { case 1: Assertion = CurrentArg != "0"; break; } } if (Assertion) { SME_ASSERT(1 == 0); } else { *((int*)0) = 0; } }
void main(int argc,String *argv) { ArgParser a=ArgParser(argc,argv); String fname=a.argafter("-i","Font file (.jf)"); float size=scrhei/2.0; // float size=scrhei/2.0*5; JBmp j=JBmp(scrwid,scrhei,0); j.setupfastsmooth(6); JFont font=JFont(fname); // String word="retro asymptotic cyberdruid"; String word=Salphabet(); int l=1; allegrosetup(scrwid,scrhei); makepalette(&greypalette); randomise(); while (!keypressed()) { // String c=Smid(word,intrnd(1,Slen(word)),1); String c=Smid(word,l,1); if (myrnd()<0.07) font.writeString(Smid(word,intrnd(1,Slen(word)),1),&j,myrnd()*scrwid,myrnd()*scrhei,0.5+0.5*myrnd()*size,255); if (myrnd()<0.07) font.centerString("retro",&j,myrnd()*scrwid,myrnd()*scrhei,0.5+0.5*myrnd()*size,255); if (myrnd()<0.07) font.centerString("asymptotic",&j,myrnd()*scrwid,myrnd()*scrhei,0.5+0.5*myrnd()*size,255); if (myrnd()<0.07) font.centerString("cyber druid",&j,myrnd()*scrwid,myrnd()*scrhei,0.5+0.5*myrnd()*size,255); j.fadeby(10); j.randomfastsmooth(); j.writetoscreen(); //l=(l%Slen(word))+1; } }
void main(int argc,String *argv) { ArgParser a=ArgParser(argc,argv); a.com=Sconc(a.com,"[source directories] "); String dest=a.argafter("-dest","destination file location",Sconc(safegetenv("JPATH"),"/background.jpg")); // Get possible files List<String> fs; if (a.argsleft()==0) { fs.add(getfilesrecursive(Sconc(safegetenv("JPATH"),"/wallpapers/"))); // Default if no args } while (a.argsleft()) { String d=a.getarg(); fs.add(getfilesrecursive(d)); } // printf("%s\n",fs.toString()); a.done(); // Exclude those of wrong type List<String> types; types.add("jpg"); types.add("jpeg"); types.add("bmp"); types.add("gif"); types.add("tgz"); types.add("gz"); for (int i=1;i<=fs.len;i++) { String fname=fs.num(i); String ext=Safterlastorall(fname,"."); // printf("%s has ext %s\n",fname,ext); if ( types.find(ext,&Sequiv)==0 || Sinstr(fname,"wallpapers/tiles/")>0 || Sinstr(fname,"wallpapers/small/")>0 || Sinstr(fname,"wallpapers/naff/")>0 || Sinstr(fname,"wallpapers/for/")>0 || Sinstr(fname,"/babes/")>0 || Sinstr(fname,"/fairies/")>0 || Sinstr(fname,"/mermaids/")>0 || Sinstr(fname,"/.xvpics/")>0 ) { // Case-insensitive search // printf("Didn't find extension %s\n",ext); fs.removenum(i); i--; } } // Choose a random file and symbolically link it randomise(); int n=intrnd(1,fs.len); #ifdef DOS String call=Sformat("copy \"%s\" \"%s\"",fs.num(n),dest); #else String call=Sformat("ln -s -f \"%s\" \"%s\"",fs.num(n),dest); #endif system(call); // setenv("RANDOMFILENAME",fs.num(n),true); }
void main(int argc,String *argv) { ArgParser a=ArgParser(argc,argv); bool writingframes=a.argexists("-wf","write frames"); int tol=a.intafter("-t","colour tolerance",8); int res=a.intafter("-r","resolution",5); a.done(); allegrosetup(scrwid,scrhei); makepalette(&greypalette); PPsetup(scrwid,scrhei,2.0); JBmp img=JBmp(scrwid,scrhei); randomise(); for (int i=1;i<=5;i++) { // int j=intrnd(1,2); if (odd(i)) es.add(new Radial()); else es.add(new Stripey()); // es.num(es.len)->amp=floatrnd(0,1); es.num(es.len)->amp=1; } for (int i=1;i<=es.len;i++) for (int j=1;j<=200;j++) es.num(i)->evolve(); int frame=0; while (!keypressed()) { frame++; // Make new image quadify(&img,&effectat,tol,res,20); // Show new image img.writetoscreen(); // Evolve drivers for (int i=1;i<=es.len;i++) for (int j=1;j<=5;j++) { Effect2d *e=es.num(i); e->evolve(); // e->pos=e->cen+V2d::rotate(e->off,e->rotvel*(float)frame); } if (writingframes) img.writeframe(); } }
void main(int argc,String *argv) { ArgParser a=ArgParser(argc,argv); String fname=a.arg("HTML file"); a.done(); HTMLer h=HTMLer(fname); int cnt=0; // Find next block Pos p=h.find("~open"); while (p.r>0 && p.c>0) { cnt++; Pos g=h.findback(">",p); //printf("Found > at r%ic%i\n",g.r,g.c); String w=h.ls.num(g.r); w=Sinsert(w,g.c+1,Sformat("<font color=\"008000\"><u><span id=\"click%i\" class=\"Outline\" style=\"cursor:hand;\">",cnt)); h.ls.replace(g.r,w); String s=h.ls.num(p.r); s=Sreplaceall(s,"~open",Sformat("</span></u> <b><span id=\"click%iclosed\">></span><span id=\"click%iopen\" style=\"display:None\"><</span></b></font> ",cnt,cnt)); h.ls.replace(p.r,s); // Find start and end of blockquote Pos q=h.find("<blockquote>",p); printf("Found <b> at r%ic%i\n",q.r,q.c); Pos r=q; int indent=1; do { //printf("Searching..."); Pos s=h.find("<blockquote>",r.nextrow()); Pos e=h.find("</blockquote>",r.nextrow()); //printf("s r%ic%i e r%ic%i\n",s.r,s.c,r.r,r.c); if (s.r==-1 && s.c==-1 && e.r==-1 && e.c==-1) error("Could not find <b> or </b> from row %i\n",r.nextrow()); if (s.r<e.r && s.r>-1) { indent++; r=s; } else { indent--; r=e; } } while (indent>0 || (Slen(h.ls.num(r.r+1))==0 && Seq(h.ls.num(r.r+2),"<blockquote>"))); printf("Found corresponding </b> at r%ic%i\n",r.r,r.c); String t=h.ls.num(q.r); t=Sformat("<span id=\"click%iblock\" style=\"display:None;\">%s",cnt,t); h.ls.replace(q.r,t); String u=h.ls.num(r.r); u=Sformat("%s</span>",u); h.ls.replace(r.r,u); p=h.find("~open",p.nextrow()); h.write("einaus.html"); } Pos v=h.find("/body"); h.ls.insert(v.r,readlinesfromfile("einausinsert.html")); h.write("einaus.html"); }
int main(int argc,String *argv) { ArgParser a=ArgParser(argc,argv); String infile=a.argafter("-i","Input file","histvar.bmp"); String outfile=a.argafter("-o","Output file","s1hv.bmp"); int r=a.intafter("-r","Smoothing radius",0); float t=a.floatafter("-t","Adaptive threshold",0.2); Map2d<float> *in=Map2d<float>::readfile(infile); Map2d<bool> *out=in->smoothed(r)->adaptivethreshold(t); out->writefile(outfile); }
void main(int argc,String *argv) { setupdates(); ArgParser a=ArgParser(argc,argv); String fname=a.getarg(1); a.done(); List<String> ls=mail2list(fname); printf("Done\n"); String destdir=Sformat("O%s",fname); system(Sformat("mkdir %s",destdir)); system(Sformat("rm %s/*",destdir)); int i=1; while (i>0 && i<=ls.len) { Email e=Email(); int j=e.parsefrom(&ls,i); // printf("Email %i\n",i); for (int k=1;k<=e.content.len;k++) { Date *d=finddate(e.content.num(k)); if (d!=NULL) { drs.add(DateRec(*d,i)); // printf("Line %s\ncontains date %s\n",e.content.num(k),d->toString()); } } i=j; } HTMLer h; h.start(Sconc("Mails regarding ",stdate.toString()," to ",enddate.toString())); h.addtitle(); /* List<String> ls=readlinesfromfile(fname); StringParser sp=StringParser(ls.num(1)); sp.expect("From "); String from=sp.getbefore(" "); int dl=ls.satisfy(&startsdate,2); if (dl==0) error("No Date: line found"); Date *date=finddate(ls.num(dl)); printf("\n%s written %s\n",fname,date->toString()); // Find end of header for (int i=ls.satisfy(&Sempty,3);i<=ls.len;i++) { Date *indate=finddate(ls.num(i)); if (indate!=NULL) { // printf("Pertains to %s\n",indate->toString()); printf("%s\n",ls.num(i)); } } */ }
TEST(Common, ArgParser) { vector<string> rawArgv = { "", "-f", "conf/main.cfg", "--port", "1234", "--flag" }; int argc = rawArgv.size(); char** argv = new char*[argc]; for (int i = 0; i < argc; ++i) { argv[i] = new char[rawArgv[i].size() + 1]; memcpy(argv[i], rawArgv[i].c_str(), rawArgv[i].size() + 1); } int callbacks = 0; string confVal, portVal, flagVal; bool res = ArgParser({ Option('f', "config", OptionFlags::RequiredArg, [&](string val) { confVal = val; ++callbacks; }), Option('p', "port", OptionFlags::OptionalArg, [&](string val) { portVal = val; ++callbacks; }), Option('\0', "flag", OptionFlags::NoArg, [&](string val) { flagVal = val; ++callbacks; }) }).Run(argc, (char**)argv); EXPECT_TRUE(res); EXPECT_EQ(confVal, string(argv[2])); EXPECT_EQ(portVal, string(argv[4])); EXPECT_EQ(flagVal, ""); EXPECT_EQ(callbacks, 3); for (int i = 0; i < argc; ++i) { delete[] argv[i]; } delete[] argv; }
void main(int argc,String *argv) { randomise(); ArgParser a=ArgParser(argc,argv); String imname=a.getarg(1); int quant=a.intafter("-q","Quantisation",16); // if (a.argsleft()) String oname=a.argor("edgehist.dat"); a.done(); //int quant=16; RGBmp *oi=RGBmp::readfile(imname); Map2d<float> *gs=oi->getgreyscale(); // Edge detection printf("Doing edge detection\n"); gs->edgedetection(Map2d<float>::sobel(),&mag,&angs); mag->writefile("tmp.bmp"); angs->writefile("tmp2.bmp"); // Map1d<float> hist=Map1d<float>(quant); float *hist=new float[quant]; for (int i=0;i<quant;i++) hist[i]=0; for (int x=0;x<gs->width;x++) for (int y=0;y<gs->height;y++) { float i=angs->pos[x][y]*(float)quant/2.0/pi; i=i+(float)quant/2.0; int j=i; // printf("%i",j); hist[j]+=mag->pos[x][y]; } List<String> data; for (int i=0;i<quant;i++) { data.add(Sformat("%.2f",hist[i])); } data.add(Sformat("Score: %.2f",scorefor())); data.add(Sformat("V/area: %.2f",keepoffness)); printf("Score: %.2f\n",scorefor()); printf("V/area: %.2f\n",keepoffness); writelinestofile(data,oname); }
void main(int argc,String *argv) { ArgParser a=ArgParser(argc,argv); String app=a.argor("append","tar cfz hwiport.tgz"); String dir=a.argor("directory","."); a.done(); DirRec d=DirRec(dir); d.portfilter(); printf("%s",app); d.portdisplay(""); printf("\n"); }
void main(int argc,String *argv) { ArgParser a=ArgParser(argc,argv); String fname=a.arg("HTML file"); a.done(); List<String> ls=readlinesfromfile(fname); int count=0; for (int i=1; i<=ls.len; i++) { String l=ls.num(i); int j; if ((j=Sinstr(l,"<blockquote>"))>0) { printf("Found blockquote line %i (%i): %s\n",i,j,l); int k=i-1; int m; String n; do { n=ls.num(k); m=max(Sinstrlast(ls.num(k),"<br>"),Sinstrlast(ls.num(k),"</p>")); printf("m=%i for line %s\n",m,n); if (m==0) k--; } while (m==0); printf("Found </P> or <BR> line %i (%i): %s\n",k,m,n); // Assume success, proceed with insertion count++; String click=Sformat("einaus%i",count); String block=Sformat("einaus%iblock",count); // Prepend <p>... with begin span String s1=Sconc("<span id=\"",click,"\" class=\"Outline\" style=\"cursor:hand;\">"); // n=Sinsert(n,m,s1); ls.replace(k,Sconc(s1,n,"</span>")); // Prepend blockquote String s2=Sconc("<span id=\"",block,"\" style=\"display:None\">"); ls.replace(i,Sinsert(l,j,s2)); int o=i; for (; Sinstr(ls.num(o),"</blockquote>")==0; o++) { } printf("Found end of blockquote line %i: %s\n",o,ls.num(o)); ls.replace(o,Sconc(ls.num(o),"</span>")); i=o; } } int i; for (i=1; Sinstr(ls.num(i),"</body>")==0; i++) { } ls.insert(i,readlinesfromfile("einausinsert.html")); writelinestofile("einaus.html",ls); printf("Found %i blocks\n",count); }
void main(int argc,String *argv) { ArgParser a=ArgParser(argc,argv); bool useold=a.argexists("-o","use a previous calculation of the map"); usexv=a.argexists("-xv","display progress using xv"); String iname=a.getarg("image"); String bname=a.getarg("binary image"); approx=false; int scalewid=a.intafter("-sw","scale to width",600); bool showscaled=a.argexists("-ss","show scaled images"); showprogress=a.argexists("-sp","show progress"); a.done(); origimage=RGBmp::readfile(iname); image=origimage->scaletowidth(scalewid); Map2d<bool> total=*Map2d<bool>::readbinfile(bname)->binscaleto(image->width,image->height); if (showscaled) { image->writefile("scaledimg.bmp"); total.writefile("scaledbin.bmp"); } if (!useold) { rm=total.getregionmap(true); rm.writefileandscale("regmap.bmp"); rm.hueify().writefile("regmapvis.bmp"); } else { rm=*Map2d<int>::readfileandscale("regmap.bmp"); distmap=*Map2d<float>::readfileandscale("distmap.bmp"); } List<Region> cs=rm.collectregions(); for (int i=1;i<=cs.len;i++) { bs.add(Blob(i,cs.p2num(i))); } printf("Calculating initial distances...\n"); for (int i=1;i<=bs.len;i++) { if (showprogress && ((i % 10)==1)) printf("%i/%i\n",i,bs.len); for (int j=1;j<=bs.len;j++) if (i!=j) float dummy=closestdist(i,j); } distmap.writefileandscale("distmap.bmp"); findlines(); }
void main(int argc,String *argv) { ArgParser a=ArgParser(argc,argv); String pat=a.argor("pattern","."); a.done(); List<String> ls=getfilesrecursive(pat); printf("getfilesrecursive: %i\n%s\n",ls.len,ls.toString()); ls=getfilesindir(pat); printf("getfilesindir: %i\n%s\n",ls.len,ls.toString()); ls=getfiles(pat); printf("getfiles: %i\n%s\n",ls.len,ls.toString()); }
void main(int argc,String *argv) { ArgParser a=ArgParser(argc,argv); int w=a.intafter("-w","width",275); int h=a.intafter("-h","height",116); int numpts=a.intafter("-n","number of points",100); a.done(); FILE *file=fopen("region.txt","wa"); fprintf(file,"[Normal]\n"); fprintf(file,"Numpoints=%i\n",numpts); V2d cen=V2d((float)w/2.0,(float)h/2.0); for (int i=0;i<numpts;i++) { V2d a=10.0*(w+h)*V2d::angle(-pi/4.0+2.0*pi*(float)i/(float)numpts); a=a+cen; if (a.x<0) a=Line2d(cen,a).intersect(Line2d(V2d(0,0),V2d(0,1))); if (a.y<0) a=Line2d(cen,a).intersect(Line2d(V2d(0,0),V2d(1,0))); if (a.x>w) a=Line2d(cen,a).intersect(Line2d(V2d(w,0),V2d(w,1))); if (a.y>h) a=Line2d(cen,a).intersect(Line2d(V2d(0,h),V2d(1,h))); a=a-cen; float rnd=myrnd(); a=a*rnd; a=a+cen; fprintf(file,"%i,%i",(int)a.x,(int)a.y); if (i<numpts-1) fprintf(file,", "); } fprintf(file,"\n"); fclose(file); }
inline int Main( int argc, char* const argv[], Config& config ) { ArgParser( argc, argv, config ); if( !config.getMessage().empty() ) { std::cerr << config.getMessage() << std::endl; Catch::Context::cleanUp(); return (std::numeric_limits<int>::max)(); } // Handle help if( config.showHelp() ) { showHelp( argv[0] ); Catch::Context::cleanUp(); return 0; } return Main( config ); }
int main(int argc, char **argv) { ArgParser a=ArgParser(argc,argv); String infile=a.argafter("-i","input filename","grey.bmp"); String outfile=a.argafter("-o","edges output filename","edgemag.bmp"); String aoutfile=a.argafter("-oa","edge angles output filename","edgeangs.bmp"); String oeutfile=a.argafter("-oe","edge angle distribution variance output filename","eadv.bmp"); int anghistq=a.intafter("-q","edge angle distribution quantisation",8); int angrad=a.intafter("-r","radius of distribution sample mask",6); String moutfile=a.argafter("-oe","text edges cancel out output filename","myeadv.bmp"); float myscale=a.floatafter("-ms","scale for my method",0.5); int myangrad=a.intafter("-mr","radius for my method",3); Map2d<float> *gs=Map2d<float>::readfile(infile); // Edge detection Map2d<float> *change,*angs; gs->edgedetection(Map2d<float>::sobel(),&change,&angs); // vs->vedgedetection(Map2d<float>::thinsobel(),&change,&angs); change->writefile(outfile); angs->writefile(aoutfile); Map2d<float> *d2change,*d2angs; change->edgedetection(Map2d<float>::sobel(),&d2change,&d2angs); d2change->writefile("d2edges.bmp"); // Edge angle distribution variance Map2d<float> *angdist=angs->getdistributionvariancewithweighting(change,anghistq,angrad); angdist->writefiletop(oeutfile,400); // Edge angle cancelling outness Map2d<float> *mine=angs->getmydistributionvariancewithweighting(change,myangrad,myscale); mine->writefiletop(moutfile,6); // Edge angle visualisation RGBmp *r=new RGBmp(angs->width,angs->height); for (int i=0;i<r->width;i++) { printf("."); for (int j=0;j<r->height;j++) r->bmp[i][j]=change->pos[i][j]*myRGB::hue(0.5+angs->pos[i][j]/2.0/pi); } r->inverted()->writefile("edgeangv.bmp"); }
void main(int argc,String *argv) { ArgParser a=ArgParser(argc,argv); bool useold=a.argexists("-o","use a previous calculation of the map"); String iname=a.getarg(); String bname=a.getarg(); a.done(); Map2d<float> *image=Map2d<float>::readfile(iname); Map2d<bool> total=*Map2d<bool>::readbinfile(bname)->binscaleto(image->width,image->height); Map2d<int> rm; if (!useold) { rm=total.getregionmap(true); rm.writefile("map.bmp"); writeinttofile("map.bmp.dat",rm.largest()); } else { int i=readintfromfile("map.bmp.dat"); if (i>255) error("Cannot re-read map: greyscale resolution too low!"); rm=*Map2d<int>::readfile("map.bmp",i); } List<Region> cs=rm.collectregions(); List<Blob> bs; for (int i=1;i<=cs.len;i++) { bs.add(Blob(cs.p2num(i))); // for (;i<=cs.len && myrnd()<0.9;i++) // bs.p2num(bs.len)->add(cs.p2num(i)); } /* RGBmp *out=new RGBmp(image->width,image->height); for (int i=1;i<=bs.len;i++) out->line(bs.p2num(i)->line(),myRGB::red); out->writefile("out.bmp");*/ findlines(bs,rm); }
void main(int argc,String *argv) { ArgParser a=ArgParser(argc,argv); String fname=a.getarg(1); a.done(); ls=readlinesfromfile(fname); int i=nextstart(0); while (i>0 && i<ls.len) { int j=nextstart(gi); if (j==0) j=ls.len+1; List<String> nls; for (int k=i;k<j;k++) nls.add(ls.num(k)); writelinestofile(nls,getnextfilename("txt")); i=j; } }
void main(int argc,String *argv) { ArgParser a=ArgParser(argc,argv); a.done(); randomise(); for (int i=0;i<20;i++) { Line3d la=Line3d(V3d::random(),V3d::random()); Line3d lb=Line3d(V3d::random(),V3d::random()); V3d *i=la.intersection(lb); if (i==NULL) printf("fail\n"); V3d nor=V3d::cross(la.b-la.a,lb.b-lb.a); printf("%f %f\n", V3d::normdot(la.b-la.a,nor), V3d::normdot(lb.b-lb.a,nor) ); } }
void main(int argc,String *argv) { ArgParser a=ArgParser(argc,argv); String imname=a.getarg("image file"); String bname=a.getarg("binary file"); String oname=a.getarg("output file"); myRGB shade=myRGB::hue(a.floatafter("-h","Shade hue",1.0/6.0)); a.done(); RGBmp *r=RGBmp::readfile(imname)->scaledby(0.5); Map2d<bool> *b=Map2d<float>::readfile(bname)->threshold(0.5); for (int i=0;i<r->width;i++) for (int j=0;j<r->height;j++) { Pixel p=Pixel(i*b->width/r->width,j*b->height/r->height); if (b->getpos(p) && r->inimage(i,j)) r->bmp[i][j]=shade; } r->writefile(oname); }
void main(int argc,String *argv) { ArgParser a=ArgParser(argc,argv); bool tmp=a.argexists("/s"); String pattern=a.arg(1); a.done(); List<FileInfo> fs; struct ffblk f; int ffops=FA_HIDDEN | FA_SYSTEM; if (tmp) ffops=ffops | FA_DIREC; bool done = findfirst(pattern, &f, ffops); while (!done) { FileInfo fi=FileInfo(f.ff_name,f.ff_fsize,contains(f.ff_attrib,FA_DIREC),contains(f.ff_attrib,FA_RDONLY),contains(f.ff_attrib,FA_ARCH),contains(f.ff_attrib,FA_SYSTEM),contains(f.ff_attrib,FA_HIDDEN), Date((f.ff_fdate >> 5) & 0x0f,(f.ff_fdate & 0x1f),((f.ff_fdate >> 9) & 0x7f) + 1980), Time((f.ff_ftime >> 11) & 0x1f,(f.ff_ftime >> 5) & 0x3f,(f.ff_ftime & 0x1f) * 2)); fs.add(fi); printf("%10u %2u:%02u:%02u %2u/%02u/%4u %20s Atrs: %i\n", f.ff_fsize, (f.ff_ftime >> 11) & 0x1f, (f.ff_ftime >> 5) & 0x3f, (f.ff_ftime & 0x1f) * 2, (f.ff_fdate >> 5) & 0x0f, (f.ff_fdate & 0x1f), ((f.ff_fdate >> 9) & 0x7f) + 1980, f.ff_name, (int)f.ff_attrib); done = findnext(&f); } for (int i=1;i<=fs.len;i++) printf("%s\n",fs.num(i).toString()); }
void BGSEEConsoleCmd_LoadPlugin_ExecuteHandler(BGSEECONSOLECMD_ARGS) { SME::StringHelpers::Tokenizer ArgParser(Args, " ,"); std::string CurrentArg; std::string PluginName; bool SetActive = false; for (int i = 1; i <= ParamCount; i++) { ArgParser.NextToken(CurrentArg); switch (i) { case 1: PluginName = CurrentArg; break; case 2: SetActive = (_stricmp(CurrentArg.c_str(), "1") == 0); break; } } // prolog hooks::_MemHdlr(AutoLoadActivePluginOnStartup).WriteJump(); TESFile* File = _DATAHANDLER->LookupPluginByName(PluginName.c_str()); if (File) { File->SetActive(SetActive); File->SetLoaded(true); SendMessage(BGSEEUI->GetMainWindow(), WM_COMMAND, TESCSMain::kToolbar_DataFiles, 0); } else BGSEECONSOLE_MESSAGE("Plugin '%s' doesn't exist!", PluginName.c_str()); // epilog hooks::_MemHdlr(AutoLoadActivePluginOnStartup).WriteBuffer(); }
void main(int argc,String *argv) { ArgParser a=ArgParser(argc,argv); int cirres=a.intafter("-res","resolution of infinity circle",30); int ppres=a.intafter("-ppres","resolution of each projection profile",200); String bname=a.getarg("binary image"); measure=&measuresquare; if (a.argexists("-deriv","use derivative measure")) measure=&measurederiv; if (a.argexists("-square","use square measure")) measure=&measuresquare; if (a.argexists("-entropy","use entropy measure")) measure=&measureentropy; if (a.argexists("-variance","use variance measure")) measure=&measurevariance; a.done(); Map2d<bool> binimg=*Map2d<bool>::readfile(bname)->threshold(0.5); ProjectionProfiler pp=ProjectionProfiler(cirres,ppres,binimg); pp.setup(); pp.calculate(); V2d vp=pp.getvp(); V2d cen=V2d(binimg.width/2,binimg.height/2); V2d diff=(cen-vp).perp().norm()*binimg.width/2; binimg.line(cen-diff,cen+diff,true); binimg.line(vp,V2d(cen+diff),true); binimg.line(vp,V2d(cen-diff),true); #ifdef USINGJFONT // jfont.writeString(Sformat("entropy=%.5f",lowestent),&binimg,0,10,8.0,true); #endif binimg.writefile("result.bmp"); pp.drawvps().writefile("pps.bmp"); if (outcount>0) printf("%i pixels fell outside their window\n"); }