CELLP newcell() { CELLP cp; //printf("=%d= ", __LINE__); if((freecelltop + 1) >= fromcelltop + (CELLSIZ / 2)) { if(verbose) { fprintf(stderr, "====== Newcell call GBC. ======\n"); } //printf("=%d= ", __LINE__); gbc(OFF, ON); //printf("=%d= ", __LINE__); if((freecelltop + 1) >= fromcelltop + (CELLSIZ / 2)) { //printf("=%d= ", __LINE__); fprintf(stdout,"New Cell allocation failed!!!!!!\n"); //printf("=%d= ", __LINE__); exit(0); } //printf("=%d= ", __LINE__); } //printf("=%d= ", __LINE__); cp = freecelltop; //printf("=%d= ", __LINE__); freecelltop++; //printf("=%d= ", __LINE__); cp->cdr = (CELLP)nil; //printf("=%d= ", __LINE__); //printf("==fromcelltop=%p + CELLSIZ/2=%d = %p; cp=%p; freecelltop=%p== ", fromcelltop, CELLSIZ/2, fromcelltop + (CELLSIZ / 2), cp, freecelltop); allocated_cell++; return cp; }
ATOMP newatom() { ATOMP ap; //予約語のための領域確保の場合 //printf("=%d= ", __LINE__); if(save_in_sys_atom == 1) { fprintf(stdout, "Allocation System Atom\n"); // if((freesysatomtop + 1) >= freesysatomtop + SYSATOMS) if((freesysatomtop + 1) >= freesysatom + SYSATOMS) { // !!!N fprintf(stderr, "Error:: Can't generate systemAtom"); exit(0); } ap = freesysatomtop; freesysatomtop++; //printf("=%d= ", __LINE__); return ap; } //新しいATOMPを用意すると半分からはみ出る場合にはGC起動 if((freeatomtop + 1) >= fromatomtop + (ATOMSIZ / 2)) { if(verbose) { fprintf(stderr, "====== New atom call GBC. ======\n"); } gbc(OFF, ON); if((freeatomtop + 1) >= fromatomtop + (ATOMSIZ / 2)) { fprintf(stdout,"New atom allocation failed!!!!!!\n"); exit(0); } } ap = freeatomtop; freeatomtop++; //printf("=%d= ", __LINE__); //Increment allocated_atom allocated_atom++; return ap; }
ATOMP newatom() { ATOMP ap; if (freeatom == (ATOMP)nil) { gbc(OFF, ON); ec; } ap = freeatom; freeatom = (ATOMP)freeatom->plist; // プロパティ(属性)リスト return ap; }
NUMP newnum() { NUMP np; if (freenum == (NUMP)nil) { gbc(ON, OFF); ec; } np = freenum; freenum = freenum->value.ptr; return np; }
CELLP newcell() { CELLP cp; if (freecell == (CELLP)nil) { gbc(OFF, OFF); ec; } cp = freecell; freecell = freecell->cdr; cp->cdr = (CELLP)nil; return cp; }
NUMP newnum() { NUMP np; //新しいNUMを追加すると分からはみ出る場合にはGCを起動する。 //printf("=%d= ", __LINE__); if((freenumtop + 1) >= fromnumtop + (NUMSIZ / 2)){ if(verbose) { fprintf(stderr, "====== New num call GBC. ======\n"); } gbc(ON, OFF); ec; if((freenumtop + 1) >= fromnumtop + (NUMSIZ / 2)) { fprintf(stdout,"New num allocation failed!!!!!!\n"); exit(0); } } np = freenumtop; freenumtop++; //printf("=%d= ", __LINE__); allocated_num++; return np; }
//自由セルが一定数を下回った場合にはgbcを起動する。 void checkgbc(void){ if(fc < FREESIZE) gbc(); }
int f_gbc(int arglist){ gbc(); return(T); }
int main(const int argc, const char **argv) { // instantiate a model manager: ModelManager manager("Frame Grabber Tester"); // Instantiate our various ModelComponents: nub::soft_ref<FrameGrabberConfigurator> gbc(new FrameGrabberConfigurator(manager)); manager.addSubComponent(gbc); nub::soft_ref<CameraControl> camera(new CameraControl(manager, "Camera Controller", "CameraControl", 0, true, 0, 1, 1)); manager.addSubComponent(camera); // Parse command-line: if (manager.parseCommandLine(argc, argv, "", 0, 0) == false) return(1); // do post-command-line configs: nub::soft_ref<FrameIstream> gb = gbc->getFrameGrabber(); if (gb.isInvalid()) LFATAL("You need to select a frame grabber type via the " "--fg-type=XX command-line option for this program " "to be useful"); int width = gb->getWidth(), height = gb->getHeight(); float delay = 0; // let's get all our ModelComponent instances started: manager.start(); XWindow wini(Dims(width, height), 0, 0, "test-input window"); XWindow wino1(Dims(width/4, height/4), 0, 0, "test-output window 1"); XWindow wino2(Dims(width/4, height/4), 0, 0, "test-output window 2"); XWindow winAux1(Dims(100, 450), 0, 0, "HSV levels 1"); XWindow winAux2(Dims(100, 450), 0, 0, "HSV levels 2"); Timer tim; Image< PixRGB<byte> > ima; Image< PixRGB<float> > fima; Image< PixRGB<byte> > display; Timer camPause; // to pause the move command camPause.reset(); uint64 t[NAVG]; int frame = 0; segmentImageMerge segmenter(2); // set up tracking parameters //segmenter.setTrackColor(10,10,0.15,0.20,150,150,0,true,15); segmenter.setTrackColor(13,7,0.17,0.3,156,30,0,true,15); //segmenter.setTrackColor(10,10,0.15,0.20,150,150,1,false,15); segmenter.setTrackColor(270,10,0.18,0.25,60,60,1,true,15); segmenter.setAdaptBound(20,5,.30,.15,170,100,0); //segmenter.setAdaptBound(15,5,.30,.25,140,100,0); segmenter.setAdaptBound(285,265,.25,.15,80,40,1); segmenter.setFrame(0,0,width/4,height/4,width/4,height/4,0); segmenter.setFrame(0,0,width/4,height/4,width/4,height/4,1); segmenter.setCircleColor(0,255,0,0); segmenter.setCircleColor(0,0,255,1); segmenter.setBoxColor(255,255,0,0); segmenter.setBoxColor(255,0,255,1); segmenter.setAdapt(3,true,3,true,3,true,0); segmenter.setAdapt(3,true,3,true,3,true,1); while(1) { tim.reset(); ima = gb->readRGB(); uint64 t0 = tim.get(); // to measure display time Image<PixRGB<byte> > Aux1; Image<PixRGB<byte> > Aux2; Aux1.resize(100,450,true); Aux2.resize(100,450,true); Image<byte> outputI1; Image<byte> outputI2; display = ima; segmenter.trackImage(ima,&display,0,&Aux1); segmenter.trackImage(ima,&display,1,&Aux2); segmenter.mergeImages(&display); if(camPause.get() > delay) { int modi,modj; segmenter.getImageTrackXY(&modi,&modj,0); //segmenter.getImageTrackXYMerge(&modi,&modj); modi = modi*8; modj = 480-modj*8; if(modi > 0 && modi < 640 && modj > 0 && modj < 480) { if(segmenter.returnLOT(0) == false) { camPause.reset(); delay = camera->moveCamXYFrame(modi,modj); } } } Image<byte> temp1 = segmenter.returnCandidateImage(0); Image<byte> temp2 = segmenter.returnCandidateImage(1); wini.drawImage(display); //wino1.drawImage(outputI1); wino1.drawImage(temp1); wino2.drawImage(temp2); winAux1.drawImage(Aux1); winAux2.drawImage(Aux2); t[frame % NAVG] = tim.get(); t0 = t[frame % NAVG] - t0; if (t0 > 28) LINFO("Display took %llums", t0); // compute and show framerate over the last NAVG frames: if (frame % NAVG == 0 && frame > 0) { uint64 avg = 0; for (int i = 0; i < NAVG; i ++) avg += t[i]; float avg2 = 1000.0 / (float)avg * NAVG; printf("Framerate: %.1f fps\n", avg2); } frame ++; } manager.stop(); return 0; }
int f_gbc(int arglist){ gbc(); return(makeT()); }