Home || Visual Search || Applications || Architecture || Important Messages || OGL || Src

mainSrc.cpp

Go to the documentation of this file.
00001 #include "Core/Geometry/PointZList.h"
00002 #include "Core/Stream/RgbDataSrcFactory.h"
00003 #include "Core/Stream/RgbDataSrcWindow.h"
00004 #include "Core/Stream/SeqConvKernel.h"
00005 #include "Core/Array/ColorSegmentation.h"
00006 #include "Core/Array/Percentile.h"
00007 #include "Core/Array/GreaterThanVal.h"
00008 #include "Core/Array/Abs.h"
00009 #include "Core/Array/WritePgm.h"
00010 #include "Core/Array/WritePng.h"
00011 #include "Core/Array/WriteJpg.h"
00012 #include "Core/Array/Rotate.h"
00013 #include "Core/Array/MakeFromData.h"
00014 #include "Core/Array/RGB2Intensity.h"
00015 #include "Core/Array/GetRgbPixels.h"
00016 #include "Core/Array/Set.h"
00017 #include "Core/Array/WriteRaw.h"
00018 #include "Core/Array/ReadRaw.h"
00019 #include "Core/Array/Erosion.h"
00020 #include "Core/Array/Dilation.h"
00021 #include "Core/Array/Threshold.h"
00022 #include "Core/Array/Label.h"
00023 #include "Core/Array/Watershed.h"
00024 #include "Core/Array/GeodesicDistanceTransform.h"
00025 #include "Core/Array/SKIZ.h"
00026 #include "Core/Array/ProjectRange.h"
00027 #include "Core/Array/GaussDerivative.h"
00028 #include "Core/Array/RecGauss.h"
00029 #include "Core/Array/Trait/BpoEqual.h"
00030 #include "Core/Array/Harris.h"
00031 #include "Core/Array/InvCompDer.h"
00032 //#include "Core/Array/KeypointsLowe.h"
00033 
00034 #include "Visualization/Window.h"
00035 #include "Visualization/AppControlSrc.h"
00036 #include "Visualization/ViewListenerWithCircles.h"
00037 #include "Visualization/ViewListenerWithArrows.h"
00038 
00039 // since we are not using libraries:
00040 #include "OglGui/OglLib.cpp"
00041 #include "Link/ImpalaLib.cpp"
00042 
00043 namespace Impala
00044 {
00045 namespace Application
00046 {
00047 namespace Src
00048 {
00049 
00050 
00051 using namespace Impala::Visualization;
00052 using namespace Impala::Core::Array;
00053 using namespace Impala::Core::Stream;
00054 using namespace Impala::Core::Geometry;
00055 
00056 // command line parameters
00057 String gCmd;
00058 int    gVerbose = 0;
00059 Real64 gSigma = 1.0;
00060 Real64 gPrecision = 3.0;
00061 Real64 gLogScale = 32.0;
00062 String gDispMode("LogMagnitude");
00063 Real64 gSigmaA = 3.0;
00064 Real64 gK = 0.00; // 0.04 ?
00065 bool   gUseRecGauss = false;
00066 int    gBorderSize = 19;
00067 
00068 class BpoSwiss
00069 {
00070 public:
00072     typedef Pattern::TagTransInVar TransVarianceCategory;
00073 
00075     typedef Pattern::TagCallValue CallCategory;
00076 
00077     BpoSwiss(Real64 theMax, int dimension)
00078     {
00079         mTheMax = theMax;
00080         mDimension = dimension;
00081     }
00082 
00083     Element::Vec3Real64
00084     DoIt(const Element::Vec3Real64& v, const Real64& s)
00085     {
00086         Real64 f = (s > 0) ? (s / mTheMax) * 255 : 0;
00087         if (f < 32)
00088             return v;
00089         /* blend
00090         if (mDimension == 1)
00091             return Element::Vec3Real64(f, v.y(), v.z());
00092         else if (mDimension == 2)
00093             return Element::Vec3Real64(v.x(), f, v.z());
00094         return Element::Vec3Real64(v.x(), v.y(), f);
00095         */
00096 
00097         // saturate
00098         if (mDimension == 1)
00099             return Element::Vec3Real64(255, v.Y(), v.Z());
00100         else if (mDimension == 2)
00101             return Element::Vec3Real64(v.X(), 255, v.Z());
00102         return Element::Vec3Real64(v.X(), v.Y(), 255);
00103 
00104         /* force
00105         if (mDimension == 1)
00106             return Element::Vec3Real64(f, 0, 0);
00107         else if (mDimension == 2)
00108             return Element::Vec3Real64(0, f, 0);
00109         return Element::Vec3Real64(0, 0, f);
00110         */
00111     }
00112 
00113 private:
00114     Real64 mTheMax;
00115     int    mDimension;
00116 };
00117 
00118 class ExportPoints
00119 {
00120 public:
00121     typedef Pattern::TagPixOpOut       DirectionCategory;
00122     typedef Pattern::TagTransVar       TransVarianceCategory;
00123     typedef Pattern::Tag1Phase         PhaseCategory;
00124 
00125     ExportPoints(Real64 theMax, PointZListBI pListBI) :
00126         mPListBI(pListBI), mTheMax(theMax)
00127     {
00128     }
00129 
00130     void
00131     DoIt(const Real64& s, int x, int y)
00132     {
00133         Real64 f = (s > 0) ? (s / mTheMax) * 255 : 0;
00134         if (f < 32)
00135             return;
00136         *mPListBI++ = PointZ(x, y);
00137     }
00138 
00139 private:
00140 
00141     Real64 mTheMax;
00142     PointZListBI mPListBI;
00143 };
00144 
00145 // finds max points and stores result in dst as well as pList
00146 void
00147 DoMaxPoints(Array2dVec3Real64* dst, Array2dScalarReal64* src, int dimension,
00148             PointZListBI pListBI)
00149 {
00150     int cw = 2*gSigmaA + 1;
00151     int ch = 2*gSigmaA + 1;
00152     Array2dScalarReal64* ker = ArrayCreate<Array2dScalarReal64>(cw, ch);
00153     Core::Matrix::MatSet(ker, 0);
00154 
00155     Array2dScalarReal64* tmp1 = 0;
00156     Dilation(tmp1, src, ker);
00157     Trait::BpoEqual<Array2dScalarReal64, Array2dScalarReal64,
00158                     Array2dScalarReal64> bpo(0.0000000000000001);
00159     Pattern::PatBinaryPixOp(tmp1, tmp1, src, bpo); // src == dilated implies local max
00160     Mul(tmp1, tmp1, src); // obtain orignal values for local max from src
00161     Real64 theMax = PixMax(tmp1);
00162     //std::cout << "theMax : " << theMax << std::endl;
00163 
00164     ExportPoints expPoints(theMax, pListBI); // obtain coordinates
00165     Pattern::PatInOutOp(tmp1, expPoints);
00166 
00167     Array2dScalarReal64* tmp2 = 0;
00168     Dilation(tmp2, tmp1, ker); // "blow up" points for visibility
00169     delete ker;
00170 
00171     BpoSwiss bpoSwiss(theMax, dimension); // insert colored points in original
00172     Pattern::PatBinaryPixOp(dst, dst, tmp2, bpoSwiss);
00173     delete tmp1;
00174     delete tmp2;
00175 }
00176 
00177 
00178 
00179 class WindowSrc : public Window, public AppControlSrc
00180 {
00181 public:
00182 
00183     WindowSrc(RgbDataSrc* src) :
00184         Window(0, 0, SuggestWndWidth(3, src->FrameWidth()),
00185                SuggestWndHeight(2, src->FrameHeight()) + 25, true),
00186         AppControlSrc(1)
00187     {
00188         CmdOptions& options = CmdOptions::GetInstance();
00189         SetSrc(src); // tell AppControlSrc about src
00190         AppController::Instance().AddControl((AppControlSrc*) this, true);
00191         mViewScale = options.GetDouble("viewScale");
00192         mCircleView1 = 0;
00193         mCircleView2 = 0;
00194         mCircleView4 = 0;
00195         mCircleView5 = 0;
00196         mArrowView = 0;
00197         if (gCmd == "tgauss")
00198         {
00199             mTGauss = MakeGaussian1d(gSigma, 1, gPrecision, 100);
00200             //WindowPrepCopyToVec3Real64* tmp = new WindowPrepCopyToVec3Real64();
00201             //mSrcWindow = new RgbDataSrcWindow<WindowPrepCopyToVec3Real64>
00202             WindowPrepGaussDerivative* tmp = new WindowPrepGaussDerivative
00203                 (3.0, 1, 0, 3.0);
00204             mSrcWindow = new RgbDataSrcWindow<WindowPrepGaussDerivative>
00205                 (GetSrc(), mTGauss->CW(), tmp);
00206         }
00207 
00208 #ifdef OGL_USING_GLUT
00209 //        SetAlwaysDraw(); // UpdateScene() doesn't work.
00210 #endif
00211         AppController::Instance().MainLoop();
00212     }
00213 
00214     // specialization of base classes
00215 
00216     void
00217     HandleCycleSrc()
00218     {
00219 //        mOglWnd->updateScene = 1;
00220         SetStatusStr((char*) GetFpsString().c_str());
00221     }
00222 
00223     void
00224     HandleNewFrame()
00225     {
00226         UpdateView(0, GetSrc()->DataPtr(), GetSrc()->FrameWidth(),
00227                    GetSrc()->FrameHeight(), mViewScale);
00228 
00229         Util::Database* db = &Util::Database::GetInstance();
00230         ArraySystem& aSys = ArraySystem::Instance();
00231         aSys.MarkMemoryUsage(gVerbose > 0);
00232 
00233         Array2dVec3UInt8* srcWrap = ArrayCreate<Array2dVec3UInt8>
00234             (GetSrc()->FrameWidth(), GetSrc()->FrameHeight(), 0, 0,
00235              GetSrc()->DataPtr(), true);
00236         Array2dVec3Real64* srcV3R64 = ArrayCreate<Array2dVec3Real64>
00237             (GetSrc()->FrameWidth(), GetSrc()->FrameHeight(), gBorderSize,
00238              gBorderSize);
00239         MakeFromData2<Array2dVec3Real64,Array2dVec3UInt8>(srcV3R64,
00240                                                           GetSrc()->DataPtr());
00241         Array2dScalarReal64* srcSR64 = 0;
00242         RGB2Intensity(srcSR64, srcV3R64);
00243 
00244 
00245         /*
00246         if (gCmd == "keypoints")
00247         {
00248             if (gVerbose > 0)
00249                 std::cout << "doing keypoints" << std::endl;
00250             mAList.clear();
00251             Array2dScalarReal64* points = 0;
00252             Array2dScalarUInt8* featVecs = 0;
00253             KeypointsLowe(points, featVecs, srcWrap, false);
00254             for (int r=0 ; r<points->CH() ; r++)
00255             {
00256                 Real64* pointPtr = points->CPB(0, r);
00257                 ArrowR a;
00258                 a.mPX = *pointPtr++;
00259                 a.mPY = *pointPtr++;
00260                 //a.mLen = 6 * *pointPtr++; // produces proper length?
00261                 a.mLen = *pointPtr++;
00262                 a.mDir = *pointPtr++;
00263                 mAList.push_back(a);
00264             }
00265             delete points;
00266             delete featVecs;
00267             if (mArrowView == 0)
00268                 mArrowView = new ViewListenerWithArrows(&mAList, oglRED);
00269             UpdateView(1, srcSR64, "Stretch", mViewScale, mArrowView);
00270         }
00271         */
00272 
00273         if (gCmd == "tgauss")
00274         {
00275             if (gVerbose > 0)
00276                 std::cout << "doing tgauss" << std::endl;
00277             mSrcWindow->FollowSrc();
00278             Array2dVec3Real64* res = 0;
00279             SeqConvKernel(res, mSrcWindow, mTGauss);
00280             int v = 1;
00281             UpdateView(v++, res, "Stretch", mViewScale);
00282             for (int d=1 ; d<=3 ; d++)
00283             {
00284                 Array2dScalarReal64* p = 0;
00285                 ProjectRange(p, res, d);
00286                 UpdateView(v++, p, "Stretch", mViewScale);
00287                 delete p;
00288             }
00289             delete res;
00290             for (int i=0 ; i<mSrcWindow->WindowSize() ; i++)
00291                 UpdateView(v++, mSrcWindow->DataArrayWindow(i), "Direct",
00292                            mViewScale);
00293         }
00294 
00295         if (gCmd == "segment")
00296         {
00297             if (gVerbose > 0)
00298                 std::cout << "doing segment" << std::endl;
00299             ColorSegmentationAlgorithm segAlg = TextureAddZero;
00300             ColorSegmentationInvariant invariantType = C;
00301             //ColorSegmentationAlgorithm segAlg = Texture;
00302             //ColorSegmentationInvariant invariantType = E;
00303             //double minRegionFraction = 0.05;
00304             double minRegionFraction = 0.01;
00305             //double threshold = 7.5;
00306             double threshold = 6.0;
00307             bool gUseGauss = false;
00308             std::cout << "segAlg = " << MakeString(segAlg) << ", invariantType = "
00309                     << MakeString(invariantType) << std::endl;
00310             std::cout << "minRegionFraction = " << minRegionFraction
00311                     << ", threshold = " << threshold << std::endl;
00312             Array2dVec3UInt8* dst = 0;
00313             std::vector<Array2dVec3UInt8*> dispList;
00314             ColorSegmentation(dst, srcV3R64, segAlg, invariantType,
00315                               minRegionFraction, threshold, gUseGauss,
00316                               &dispList);
00317             UpdateView(1, dst, "Direct", mViewScale);
00318             for (int i=0 ; i<dispList.size() ; i++)
00319                 UpdateView(2+i, dispList[i], "Direct", mViewScale);
00320             delete dst;
00321             ArrayListDelete(&dispList);
00322         }
00323 
00324         if (gCmd == "inv")
00325         {
00326             if (gVerbose > 0)
00327                 std::cout << "doing inv" << std::endl;
00328             Array2dVec3Real64* srcCopy = 0;
00329             Set(srcCopy, srcV3R64);
00330 
00331             std::vector<Array2dScalarReal64*> rgbList;
00332             rgbList = InvCompDer(srcV3R64, gSigma, gPrecision, gUseRecGauss);
00333             Array2dScalarReal64* im = 0;
00334 
00335             HarrisObj<Array2dScalarReal64>(im, rgbList, gSigmaA, gK,
00336                                                gUseRecGauss);
00337             mPList1.clear();
00338             DoMaxPoints(srcV3R64, im, 1, std::back_inserter(mPList1));
00339             if (mCircleView1 == 0)
00340                 mCircleView1 = new ViewListenerWithCircles(&mPList1, 5,
00341                                                                oglRED);
00342             UpdateView(1, im, gDispMode, mViewScale, mCircleView1);
00343 
00344             HarrisSperical<Array2dScalarReal64>(im, rgbList, gSigmaA, gK,
00345                                                     gUseRecGauss);
00346             mPList2.clear();
00347             DoMaxPoints(srcV3R64, im, 2, std::back_inserter(mPList2));
00348             if (mCircleView2 == 0)
00349                 mCircleView2 = new ViewListenerWithCircles(&mPList2, 5,
00350                                                                oglGREEN);
00351             UpdateView(2, im, gDispMode, mViewScale, mCircleView2);
00352 
00353             UpdateView(0, srcV3R64, "Direct", mViewScale);
00354             UpdateView(3, srcCopy, "Direct", mViewScale); // dummy to init viewer
00355 
00356             HarrisRGB<Array2dScalarReal64>(im, rgbList, gSigmaA, gK,
00357                                                gUseRecGauss);
00358             mPList4.clear();
00359             DoMaxPoints(srcCopy, im, 2, std::back_inserter(mPList4));
00360             if (mCircleView4 == 0)
00361                 mCircleView4 = new ViewListenerWithCircles(&mPList4, 5,
00362                                                                oglGREEN);
00363             UpdateView(4, im, gDispMode, mViewScale, mCircleView4);
00364 
00365             HarrisOpponent<Array2dScalarReal64>(im, rgbList, gSigmaA, gK,
00366                                                     gUseRecGauss);
00367             mPList5.clear();
00368             DoMaxPoints(srcCopy, im, 1, std::back_inserter(mPList5));
00369             if (mCircleView5 == 0)
00370                 mCircleView5 = new ViewListenerWithCircles(&mPList5, 5,
00371                                                                oglRED);
00372             UpdateView(5, im, gDispMode, mViewScale, mCircleView5);
00373 
00374             UpdateView(3, srcCopy, "Direct", mViewScale);
00375 
00376             delete srcCopy;
00377             delete im;
00378             ArrayListDelete(&rgbList);
00379         }
00380 
00381         if (gCmd == "write")
00382         {
00383             if (gVerbose > 0)
00384                 std::cout << "doing write" << std::endl;
00385             WriteRaw(srcV3R64, "v3r64.raw", db, 1);
00386             WriteRaw(srcSR64, "sr64.raw", db, 1);
00387             UpdateView(1, srcSR64, "Stretch", mViewScale);
00388         }
00389 
00390         if (gCmd == "erosion")
00391         {
00392             if (gVerbose > 0)
00393                 std::cout << "doing erosion" << std::endl;
00394             int cw = 5;
00395             int ch = 9;
00396             Array2dScalarReal64* ker = ArrayCreate<Array2dScalarReal64>(cw, ch);
00397             Core::Matrix::MatSet(ker, 0);
00398             Array2dScalarReal64* res = 0;
00399             Erosion(res, srcSR64, ker);
00400             //Percentile(res, srcSR64, 5, 0.95);
00401             UpdateView(1, res, "Stretch", mViewScale);
00402             delete ker;
00403             delete res;
00404         }
00405 
00406         if (gCmd == "dilation")
00407         {
00408             if (gVerbose > 0)
00409                 std::cout << "doing dilation" << std::endl;
00410             int cw = 5;
00411             int ch = 9;
00412             Array2dScalarReal64* ker = ArrayCreate<Array2dScalarReal64>(cw, ch);
00413             Core::Matrix::MatSet(ker, 0);
00414             Array2dScalarReal64* res = 0;
00415             Dilation(res, srcSR64, ker);
00416             UpdateView(1, res, "Stretch", mViewScale);
00417             delete ker;
00418             delete res;
00419         }
00420 
00421         if (gCmd == "threshold")
00422         {
00423             if (gVerbose > 0)
00424                 std::cout << "doing threshold" << std::endl;
00425             Array2dScalarUInt8* binIm = 0;
00426             Threshold(binIm, srcSR64, 128);
00427             UpdateView(1, binIm, "Binary", mViewScale);
00428             delete binIm;
00429         }
00430 
00431         if (gCmd == "label")
00432         {
00433             if (gVerbose > 0)
00434                 std::cout << "doing label" << std::endl;
00435             Array2dScalarUInt8* binIm = 0;
00436             Threshold(binIm, srcSR64, 128);
00437             UpdateView(1, binIm, "Binary", mViewScale);
00438             Array2dScalarInt32* labIm = ArrayClone<Array2dScalarInt32>(binIm);
00439 Timer tim(1);
00440         Label(labIm, binIm, 8);
00441 std::cout << "time: " << tim.SplitTime() << std::endl;
00442             UpdateView(2, labIm, "Label", mViewScale);
00443             delete binIm;
00444             delete labIm;
00445         }
00446 
00447         if (gCmd == "watershed")
00448         {
00449             if (gVerbose > 0)
00450                 std::cout << "doing watershed" << std::endl;
00451             Array2dScalarInt32* srcIm = 0;
00452             Set(srcIm, srcSR64);
00453             Array2dScalarInt32* dstIm = 0;
00454             Watershed(dstIm, srcIm, 8);
00455             UpdateView(1, dstIm, "Stretch", mViewScale);
00456             delete srcIm;
00457             delete dstIm;
00458         }
00459 
00460         if (gCmd == "geodesic")
00461         {
00462             if (gVerbose > 0)
00463                 std::cout << "doing geodesic" << std::endl;
00464             Array2dScalarInt32* srcIm = 0;
00465             Set(srcIm, srcSR64);
00466             Array2dScalarInt32* dstIm = 0;
00467             GeodesicDistanceTransform(dstIm, srcIm, 8);
00468             UpdateView(1, dstIm, "Stretch", mViewScale);
00469             delete srcIm;
00470             delete dstIm;
00471         }
00472 
00473         if (gCmd == "skiz")
00474         {
00475             if (gVerbose > 0)
00476                 std::cout << "doing skiz" << std::endl;
00477             Array2dScalarInt32* srcIm = 0;
00478             Set(srcIm, srcSR64);
00479             Array2dScalarInt32* dstIm = 0;
00480             SKIZ(dstIm, srcIm, 8);
00481             UpdateView(1, dstIm, "Stretch", mViewScale);
00482             delete srcIm;
00483             delete dstIm;
00484         }
00485 
00486         if (gCmd == "rotate")
00487         {
00488             if (gVerbose > 0)
00489                 std::cout << "doing rotate" << std::endl;
00490             Array2dScalarReal64* res = 0;
00491             Rotate(res, srcSR64, 45.0, NEAREST, false, 0);
00492             UpdateView(1, res, "Stretch", mViewScale);
00493             delete res;
00494         }
00495 
00496         if (gCmd == "jpg")
00497         {
00498             if (gVerbose > 0)
00499                 std::cout << "doing jpg" << std::endl;
00500             Array2dVec3UInt8* buf = ArrayCreate<Array2dVec3UInt8>
00501                 (GetSrc()->FrameWidth(), GetSrc()->FrameHeight());
00502             GetRgbPixels(srcV3R64, buf->CPB(), "Direct");
00503             char fileName[50];
00504             sprintf(fileName, "frame_%06d.jpg", GetSrc()->FrameNr());
00505             WriteJpg(buf, String(fileName), db);
00506             delete buf;
00507         }
00508 
00509         if (gCmd == "png")
00510         {
00511             if (gVerbose > 0)
00512                 std::cout << "doing png" << std::endl;
00513             Array2dVec3UInt8* buf = ArrayCreate<Array2dVec3UInt8>
00514                 (GetSrc()->FrameWidth(), GetSrc()->FrameHeight());
00515             GetRgbPixels(srcV3R64, buf->CPB(), "Direct");
00516             char fileName[50];
00517             sprintf(fileName, "frame_%06d.png", GetSrc()->FrameNr());
00518             WritePng(buf, String(fileName), db);
00519             delete buf;
00520         }
00521 
00522         if (gCmd == "pgm")
00523         {
00524             if (gVerbose > 0)
00525                 std::cout << "doing pgm" << std::endl;
00526             Array2dVec3UInt8* buf = ArrayCreate<Array2dVec3UInt8>
00527                 (GetSrc()->FrameWidth(), GetSrc()->FrameHeight());
00528             GetRgbPixels(srcSR64, buf->CPB(), "Direct");
00529             char fileName[50];
00530             sprintf(fileName, "frame_%06d.pgm", GetSrc()->FrameNr());
00531             WritePgm(buf, String(fileName));
00532             delete buf;
00533         }
00534 
00535         if (gCmd == "stretch")
00536         {
00537             if (gVerbose > 0)
00538                 std::cout << "doing stretch" << std::endl;
00539             UpdateView(1, srcSR64, "Stretch", mViewScale);
00540         }
00541 
00542         delete srcV3R64;
00543         delete srcSR64;
00544         delete srcWrap;
00545         aSys.CheckMemoryUsageSinceMark(gVerbose > 0);
00546     }
00547 
00548     virtual void
00549     MouseFunc(INT msg, INT but, INT state, INT x, INT y)
00550     {
00551         Window::MouseFunc(msg, but, state, x, y);
00552 
00553         if ((msg == oglMouseDown) && (but == oglRightButton))
00554         {
00555             OGLMENU menu = oglSys.MenuCreate();
00556             oglSys.MenuAdd(menu, "fps reset", 0, 2);
00557 
00558             int choice = oglSys.MenuPopUp(mOglWnd, menu);
00559 
00560             switch (choice)
00561             {
00562             case 2:
00563                 FpsReset();
00564                 break;
00565             }
00566 
00567             oglSys.MenuDestroy(menu);
00568             oglSys.UpdateSceneFlag(mOglWnd, 1);
00569         }
00570     }
00571 
00572 #ifdef APP_CONTROLLER_ALT
00573     // RvB: Test PP-Def APP_CONTROLLER_ALT
00574     virtual void DisplayFunc()
00575     {
00576         SetAlwaysDraw(GetDoContinuous());
00577         AppControlSrc::ComputeCycle(0.04);
00578         // RvB: Next does not work as getAllDone is private
00579         //if (AppController::Instance().GetAllDone())
00580         //  exit(0);
00581         if (AppControlSrc::Done())
00582             exit(0);
00583         Window::DisplayFunc();
00584     }
00585 #endif
00586 
00587 private:
00588 
00589     double        mViewScale;
00590 
00591     PointZList mPList1;
00592     PointZList mPList2;
00593     PointZList mPList4;
00594     PointZList mPList5;
00595 
00596     ViewListenerWithCircles* mCircleView1;
00597     ViewListenerWithCircles* mCircleView2;
00598     ViewListenerWithCircles* mCircleView4;
00599     ViewListenerWithCircles* mCircleView5;
00600     ArrowRList                 mAList;
00601     ViewListenerWithArrows*  mArrowView;
00602 
00603     // for tgauss
00604     //RgbDataSrcWindow<WindowPrepCopyToVec3Real64>* mSrcWindow;
00605     RgbDataSrcWindow<WindowPrepGaussDerivative>* mSrcWindow;
00606     Array2dScalarReal64*                         mTGauss;
00607 
00608 };
00609 
00610 int
00611 mainSrc(int argc, char* argv[])
00612 {
00613     OglInit(&argc, &argv[0]);
00614     CmdOptions& options = CmdOptions::GetInstance();
00615     options.Initialise(true, true);
00616     String usageStr = "cmd camera|filename\n\n";
00617     usageStr += "  cmd = stretch|pgm|png|jpg|rotate|skiz|geodesic|watershed|\n";
00618     usageStr += "        label|threshold|dilation|erosion|write|inv|segment|\n";
00619     usageStr += "        tgauss|keypoints\n";
00620     if (! options.ParseArgs(argc, argv, usageStr, 2))
00621         return 1;
00622 
00623     gCmd = options.GetArg(0);
00624     String srcName = options.GetArg(1);
00625 
00626     gVerbose = options.GetInt("verb");
00627     gSigma = options.GetDouble("sigma");
00628     gPrecision = options.GetDouble("precision");
00629     gUseRecGauss = options.GetBool("recGauss");
00630     gDispMode = options.GetString("disp");
00631     gLogScale = options.GetDouble("logScale");
00632 
00633     Array2dScalarReal64* g = 0;
00634     if (gUseRecGauss)
00635         g = MakeGaussIIR1d(Max(gSigma,gSigmaA), 1, gPrecision);
00636     else
00637         g = MakeGaussian1d(Max(gSigma,gSigmaA), 1, gPrecision, 100);
00638     int gw = g->CW();
00639     if (gw > gBorderSize)
00640     {
00641         std::cout << "Adjusting bordersize to " << gw << std::endl;
00642         gBorderSize = gw;
00643     }
00644     delete g;
00645 
00646     RgbDataSrcFactory& factory = RgbDataSrcFactory::Instance();
00647     RgbDataSrc* src = factory.Construct(srcName, options.GetString("src"));
00648     if (! src->Valid())
00649     {
00650         std::cout << "RgbDataSrc failed" << std::endl;
00651         return 0;
00652     }
00653     std::cout << src->LastFrame()+1 << " frames of " << src->FrameWidth() 
00654             << " x " << src->FrameHeight() << std::endl;
00655 
00656     WindowSrc* oglWnd = new WindowSrc(src);
00657     if (! oglWnd->Valid())
00658     {
00659         std::cout << "WindowSrc failed" << std::endl;
00660         return 0;
00661     }
00662 
00663     return 1;
00664 }
00665 
00666 } // namespace Src
00667 } // namespace Application
00668 } // namespace Impala
00669 
00670 int
00671 main(int argc, char* argv[])
00672 {
00673     return Impala::Application::Src::mainSrc(argc, argv);
00674 }

Generated on Thu Jan 13 09:03:44 2011 for ImpalaSrc by  doxygen 1.5.1