00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #include "Component/ModelManager.H"
00041 #include "Image/Image.H"
00042 #include "Image/ImageSet.H"
00043 #include "Image/ShapeOps.H"
00044 #include "Image/DrawOps.H"
00045 #include "Image/FilterOps.H"
00046 #include "Image/ColorOps.H"
00047 #include "Image/Transforms.H"
00048 #include "Image/MathOps.H"
00049 #include "Neuro/StdBrain.H"
00050 #include "Neuro/VisualCortex.H"
00051 #include "Neuro/NeuroOpts.H"
00052 #include "Neuro/SaliencyMap.H"
00053 #include "Media/TestImages.H"
00054 #include "Media/SceneGenerator.H"
00055 #include "Channels/DescriptorVec.H"
00056 #include "Channels/ComplexChannel.H"
00057 #include "GUI/DebugWin.H"
00058
00059
00060
00061
00062 ModelManager *mgr;
00063
00064 int main(const int argc, const char **argv)
00065 {
00066
00067 MYLOGVERB = LOG_INFO;
00068 mgr = new ModelManager("Test LabelMeSaliency");
00069
00070
00071 nub::ref<StdBrain> brain2(new StdBrain(*mgr));
00072 mgr->addSubComponent(brain2);
00073
00074
00075 mgr->exportOptions(MC_RECURSE);
00076 mgr->setOptionValString(&OPT_RawVisualCortexChans, "IOC");
00077
00078
00079
00080
00081
00082 mgr->setOptionValString(&OPT_SaliencyMapType, "Fast");
00083 mgr->setOptionValString(&OPT_SMfastInputCoeff, "1");
00084
00085 mgr->setOptionValString(&OPT_WinnerTakeAllType, "Fast");
00086
00087 mgr->setModelParamVal("FOAradius", 100, MC_RECURSE);
00088 mgr->setModelParamVal("FoveaRadius", 100, MC_RECURSE);
00089
00090 mgr->setOptionValString(&OPT_IORtype, "Disc");
00091
00092 if (mgr->parseCommandLine(
00093 (const int)argc, (const char**)argv, "<path to images>", 1, 1) == false);
00094
00095 mgr->start();
00096 nub::ref<StdBrain> brain = dynCastWeak<StdBrain>(mgr->subComponent(0));
00097
00098
00099
00100 TestImages testImages(mgr->getExtraArg(0).c_str(), TestImages::MIT_LABELME);
00101
00102
00103 printf("## \"Filename\", \"Size\", \"Number of objects\", \"Obj ID\", \"Size\"\n");
00104
00105 for(uint scene=0; scene<testImages.getNumScenes(); scene++)
00106 {
00107
00108
00109 LINFO("Get scene %i", scene);
00110 Image<PixRGB<byte> > img = testImages.getScene(scene);
00111 std::string sceneFile = testImages.getSceneFilename(scene);
00112 LINFO("Size %ix%i", img.getWidth(), img.getHeight());
00113
00114 if (testImages.getNumObj() > 0)
00115 {
00116 for (uint obj=0; obj<testImages.getNumObj(); obj++)
00117 {
00118 Image<byte> objMask = testImages.getObjMask(obj);
00119 int objSize = -1;
00120 for(int y=0; y<objMask.getHeight(); y++)
00121 for(int x=0; x<objMask.getWidth(); x++)
00122 if (objMask.getVal(x,y) > 0)
00123 objSize++;
00124
00125
00126 std::vector<Point2D<int> > objPoly = testImages.getObjPolygon(obj);
00127 Point2D<int> p1 = objPoly[0];
00128 for(uint i=1; i<objPoly.size(); i++)
00129 {
00130 drawLine(img, p1, objPoly[i], PixRGB<byte>(255, 0, 0), 4);
00131 p1 = objPoly[i];
00132 }
00133 drawLine(img, p1, objPoly[0], PixRGB<byte>(255, 0, 0), 4);
00134
00135 printf("\"%s\",\"%ix%i\",\"%i\",\"%i\",\"%i\"\n",
00136 sceneFile.c_str(), img.getWidth(), img.getHeight(),
00137 testImages.getNumObj(), obj, objSize);
00138
00139 }
00140 SHOWIMG(img);
00141
00142 } else {
00143 printf("##%s has no objects \n", sceneFile.c_str());
00144 }
00145 }
00146
00147 }
00148