void init(){ grabber.init(pa("-i")); bool c_arg = pa("-c"); gui << Draw().handle("draw").label("input image") << Image().handle("cropped").label("cropped") << ( VBox().maxSize(c_arg ? 0 : 12,99).minSize(c_arg ? 0 : 12,1) << Button("save as ..").handle("saveAs") << Button("overwrite input").handle("overwrite") << Combo("0,90,180,270").handle("rot").label("rotation") << CheckBox("rectangular",!pa("-r")).handle("rect") << Button("Batch crop...").handle("batch") << ( HBox().label("rectification size") << Spinner(1,4096,640).handle("s1") << Label(":") << Spinner(1,4096,480).handle("s2") ) << (HBox() << Fps().handle("fps") << CamCfg() ) ) << Show(); if(!c_arg){ gui["batch"].registerCallback(batch_crop); } const ImgBase *image = grabber.grab(); if(!c_arg){ mouse_1 = new Mouse1(image->getSize()); gui["draw"].install(mouse_1); } mouse_2 = new Mouse2(image->getSize()); gui["draw"].install(mouse_2); DrawHandle draw = gui["draw"]; draw->setImageInfoIndicatorEnabled(false); if(!c_arg){ gui["rect"].registerCallback(rectangular_changed); rectangular_changed(); if(*pa("-i",0) != "file" || FileList(*pa("-i",1)).size() != 1){ gui["overwrite"].disable(); }else{ gui["overwrite"].registerCallback(overwrite); } gui["saveAs"].registerCallback(save_as); } }
void batch_mode(){ if(pa("-config")){ ConfigFile f(*pa("-config")); int masksize = f["config.masksize"]; int thresh = f["config.threshold"]; float gamma = f["config.gammaslope"]; if(!pa("-output")){ printf("please specify output file pattern\n"); return; } grabber.init(pa("-i")); FileList fl; int maxSteps = -1; if(grabber.getType() == "file"){ fl = FileList(*pa("-input",1)); maxSteps = fl.size(); } static FileWriter w(*pa("-output")); static LocalThresholdOp t; t.setMaskSize(masksize); t.setGlobalThreshold(thresh); t.setGammaSlope(gamma); int i=0; while(maxSteps < 0 || maxSteps--){ if(maxSteps > 0){ printf("processing image %30s ......",fl[i++].c_str()); } const ImgBase *image = grabber.grab(); if(image->getFormat() != formatGray){ printf("..."); static ImgBase *grayImage = 0; ensureCompatible(&grayImage,depth8u,image->getSize(),formatGray); cc(image,grayImage); printf("..."); image = grayImage; } static ImgBase *dst = 0; printf("..."); t.apply(image,&dst); printf("..."); w.write(dst); printf("done! \n"); printf("writing image to %30s ... done\n",w.getFilenameGenerator().showNext().c_str()); } }else{ ERROR_LOG("please run with -config config-filename!"); return; } }
void init(){ gui << Image().handle("image").minSize(16,12); gui << ( HBox().maxSize(100,2) << Fps(10).handle("fps").maxSize(100,2).minSize(5,2) << CamCfg("") ) << Show(); grabber.init(pa("-i")); if(pa("-size")){ grabber.useDesired<Size>(pa("-size")); } }
void init(){ gui << Image().handle("image").minSize(32,24) << Image().handle("imageOut").minSize(32,24) << Slider(1,22,5).out("filterSize").label("filterSize").maxSize(100,2).handle("filterSize-handle") << Slider(1,22,10).out("difference").label("difference").maxSize(100,2).handle("difference-handle") << CheckBox("useCL", true).out("disableCL").maxSize(100,2).handle("disableCL-handle") << Show(); int maxFilterSize=pa("-maxFilterSize"); int nullValue=pa("-nullValue"); smoothing = new MotionSensitiveTemporalSmoothing(nullValue, maxFilterSize); grabber.init(pa("-i")); update(); }
void init(){ int masksize = 10; int thresh = 2; float gamma = 0; if(pa("-config")){ ConfigFile f(*pa("-config")); masksize = f["config.masksize"]; thresh = f["config.threshold"]; gamma = f["config.gammaslope"]; } gui << Draw().minSize(16,12).handle("orig").label("original image") << Image().minSize(16,12).handle("prev").label("preview image") << ( VBox().label("controls") << Slider(2,200,masksize).label("mask size").out("masksize").minSize(15,2).handle("a") << FSlider(-30,40,thresh).label("threshold").out("threshold").minSize(15,2).handle("b") << FSlider(0,15,gamma).label("gamma slope").out("gamma").minSize(15,2).handle("c") << Button("next image").handle("next") << Button("stopped","running").out("loop").handle("d") << Button("no clip","clip to roi").out("clipToROI").handle("e") << Button("save params").handle("save") << Combo("region mean,tiledNN,tiledLIN").handle("algorithm").label("algorithm") << ( HBox() << Label("..ms").handle("time").label("apply time").minSize(2,3) << Fps(10).handle("fps").minSize(4,3).label("fps") ) ) << Show(); grabber.init(pa("-i")); if(grabber.getType() != "file"){ grabber.useDesired<Size>(pa("-s")); if(!pa("-color")){ grabber.useDesired(formatGray); }else{ grabber.useDesired(formatRGB); } grabber.useDesired(depth8u); } gui.registerCallback(step,"a,b,c,d,e,next,algorithm"); gui["orig"].install(new MouseHandler(mouse)); step(); }
void init() { grabber.init(pa("-i")); if (pa("-s")) { utils::Size size = pa("-s"); grabber.setDesiredSizeInternal(size); } // create the GUI gui << ( VBox() << ( HBox() << Draw().label("Original").handle("view1").minSize(16, 12) << Draw().label("Median").handle("view2").minSize(16, 12) << Draw().label("Bilateral Filtered").handle("view3").minSize(16, 12) ) << ( HBox() << Draw().label("Original").handle("viewedge1").minSize(16, 12) << Draw().label("Median").handle("viewedge2").minSize(16, 12) << Draw().label("Bilateral Filtered").handle("viewedge3").minSize(16, 12) ) << CheckBox("Use LAB",true).handle("use_lab") << CheckBox("Use gray image",false).handle("to_gray") << Slider(1,24,4).label("Bilateral Kernel Radius").handle("bi_radius") << Slider(1,24,4).label("Median Kernel Radius").handle("median_radius") << FSlider(0.1,200,5).label("sigma_r (bilateral) ").handle("sigma_r") << FSlider(0.1,200,5).label("sigma_s (bilateral) ").handle("sigma_s") << Slider(0,255,200).label("Canny low th").handle("canny_low_th") << Slider(0,255,255).label("Canny high th").handle("canny_high_th") << Slider(10,100,100).label("ROI of Img (Percent)").handle("roi_size") << Fps().handle("fps") ); gui << Show(); bi_filter = new BilateralFilterOp(); }
void init(){ grabber.init(pa("-i")); gui << Draw().handle("image") << Show(); gui["image"].install(mouse); }