void CLuaGaia::CobCallback(int retCode, void* p1, void* p2) { if (luaGaia) { CobCallbackData cbd(retCode, *((int*)&p1), *((float*)&p2)); luaGaia->cobCallbackEntries.push_back(cbd); } }
int main(int argc, char **argv) { // instantiate a model manager: ModelManager manager("test VRD Boundary Detection"); // Instantiate our various ModelComponents: nub::soft_ref<InputFrameSeries> ifs(new InputFrameSeries(manager)); manager.addSubComponent(ifs); nub::soft_ref<OutputFrameSeries> ofs(new OutputFrameSeries(manager)); manager.addSubComponent(ofs); rutz::shared_ptr<ContourBoundaryDetector> cbd(new ContourBoundaryDetector()); manager.exportOptions(MC_RECURSE); // Parse command-line: if (manager.parseCommandLine(argc, argv, "[window_size] ", 0, 1) == false) return(1); // get the operation mode int r = 8; if(manager.numExtraArgs() > 0) r = manager.getExtraArgAs<uint>(0); // let's do it! manager.start(); ifs->updateNext(); Image<PixRGB<byte> > ima = ifs->readRGB(); // ima = Image<PixRGB<byte> >(ima.getDims(),ZEROS); // drawFilledRect(ima, // Rectangle(Point2D<int>(180, 100), Dims(100, 100)), // PixRGB<byte>(255,0,0)); Image<float> fIma(luminance(ima)); Image<float> tempFIma = fIma; inplaceNormalize(tempFIma, 0.0f,255.0f); Image<byte> bIma(tempFIma); Timer timer(1000000); timer.reset(); cbd->computeContourBoundary(ima,r); Image<float> boundaryMap = cbd->getVarianceRidgeBoundaryMap(); LINFO("time: %f ms", timer.get()/1000.0); // get non-max suppressed boundary map image float mVal = 32; float bVal = 255 - mVal; inplaceNormalize(boundaryMap, 0.0f,bVal); Image<byte> dBmapc(boundaryMap); Image<byte> dImaR, dImaG, dImaB; getComponents(ima, dImaR, dImaG, dImaB); inplaceNormalize(dImaR, byte(0), byte(mVal)); inplaceNormalize(dImaG, byte(0), byte(mVal)); inplaceNormalize(dImaB, byte(0), byte(mVal)); Image<PixRGB<byte> > dBmap = toRGB(dBmapc); Image<PixRGB<byte> > dIma = makeRGB(dImaR,dImaG,dImaB); // the non-max suppressed boundary map image Image<float> dBmapNMStemp = cbd->getNmsBoundaryMap(); inplaceNormalize(dBmapNMStemp, 0.0F, 255.0F); Image<PixRGB<byte> > dBmapNMS = toRGB(Image<byte>(dBmapNMStemp)); // the contour boundary map image Image<float> dCBmapTemp = cbd->getEdgelBoundaryMap(); inplaceNormalize(dCBmapTemp, 0.0F, bVal); Image<PixRGB<byte> > dCBmap = toRGB(Image<byte>(dCBmapTemp)); // setup the display map uint w = ima.getWidth(); uint h = ima.getHeight(); Image<PixRGB<byte> > dispIma(4*w,2*h,ZEROS); inplacePaste(dispIma, ima, Point2D<int>(0,0)); inplacePaste(dispIma, Image<PixRGB<byte> >(dBmap), Point2D<int>(w,0)); //inplacePaste(dispIma, Image<PixRGB<byte> >(dIma+dBmap), Point2D<int>(w,0)); inplacePaste(dispIma, dBmapNMS, Point2D<int>(0,h)); inplacePaste(dispIma, Image<PixRGB<byte> >(dIma+dCBmap), Point2D<int>(w,h)); inplacePaste(dispIma, cbd->getContourBoundaryMap(), Point2D<int>(2*w,0)); // angle at 4th param: 0 degrees //Image<float> gaborImg = getGabor(fIma, 0.0, 2.50, 1.0, 5); // Image<float> gaborImg = getGabor(fIma,0,7,1,9); // -------------- // Image<float> gaborImg = getCanny(fIma); // inplaceNormalize(gaborImg, 0.0F, 255.0F); // Image<PixRGB<byte> > dGaborImg = toRGB(Image<byte>(gaborImg)); // inplacePaste(dispIma, Image<PixRGB<byte> >(dGaborImg), // Point2D<int>(w*2,h)); // Image<float> rDir0 = itsRDirMax[0]; // inplaceNormalize(rDir0, 0.0F, 255.0F); // Image<PixRGB<byte> > dRDir0 = toRGB(Image<byte>(rDir0)); // inplacePaste(dispIma, dRDir0, Point2D<int>(2*w,0)); // Image<float> rDir1 = itsRDirMax[1]; // inplaceNormalize(rDir1, 0.0F, 255.0F); // Image<PixRGB<byte> > dRDir1 = toRGB(Image<byte>(rDir1)); // inplacePaste(dispIma, dRDir1, Point2D<int>(3*w,0)); // Image<float> rDir2 = itsRDirMax[2]; // inplaceNormalize(rDir2, 0.0F, 255.0F); // Image<PixRGB<byte> > dRDir2 = toRGB(Image<byte>(rDir2)); // inplacePaste(dispIma, dRDir2, Point2D<int>(2*w,h)); // Image<float> rDir3 = itsRDirMax[3]; // inplaceNormalize(rDir3, 0.0F, 255.0F); // Image<PixRGB<byte> > dRDir3 = toRGB(Image<byte>(rDir3)); // inplacePaste(dispIma, dRDir3, Point2D<int>(3*w,h)); // 300, 140 /* drawRect(dispIma, Rectangle(Point2D<int>(w+156, 68), Dims(8, 8)), PixRGB<byte>(255,0,0)); drawRect(dispIma, Rectangle(Point2D<int>(w+152, 64), Dims(16, 16)), PixRGB<byte>(255,255,0)); drawRect(dispIma, Rectangle(Point2D<int>(156, h+68), Dims(8, 8)), PixRGB<byte>(255,0,0)); drawRect(dispIma, Rectangle(Point2D<int>(152, h+64), Dims(16, 16)), PixRGB<byte>(255,255,0)); */ //ofs->writeRGB(boundaryMap, "VRD Boundary Detection"); ofs->writeRGB(dispIma, "VRD Boundary Detection"); ofs->updateNext(); Raster::waitForKey(); return 0; }