test-ImageGrab.C

00001 /*test-ImageGrab.C   */
00002 
00003 #include "Component/ModelManager.H"
00004 
00005 #include "Media/FrameSeries.H"
00006 #include "Transport/FrameIstream.H"
00007 #include "Media/MediaOpts.H"
00008 
00009 #include "Image/Image.H"
00010 #include "Image/Pixels.H"
00011 #include "Raster/Raster.H"
00012 #include "Image/CutPaste.H"
00013 
00014 #include "BeoSub/IsolateColor.H"
00015 #include "Image/DrawOps.H"
00016 #include "Image/ColorOps.H"
00017 
00018 #include "GUI/XWinManaged.H"
00019 //#include "Image/OpenCVUtil.H"
00020 
00021 //#include "SeaBee/PipeRecognizer.H"
00022 
00023 
00024 int main(int argc, char* argv[])
00025 {
00026 
00027   MYLOGVERB = LOG_INFO;
00028 
00029   ModelManager manager("PipeRecognizer Tester");
00030 
00031   nub::soft_ref<InputFrameSeries> ifs(new InputFrameSeries(manager));
00032   manager.addSubComponent(ifs);
00033 
00034   manager.exportOptions(MC_RECURSE);
00035 
00036   // Parse command-line:
00037   if (manager.parseCommandLine(argc, argv,
00038                                "[image {*.ppm}]",
00039                                0, 1)
00040       == false) return(1);
00041 
00042   int w = ifs->getWidth(),  h = ifs->getHeight();
00043   std::string dims = convertToString(Dims(w, h));
00044   LINFO("image size: [%dx%d]", w, h);
00045   manager.setOptionValString(&OPT_InputFrameDims, dims);
00046 
00047   manager.setModelParamVal("InputFrameDims", Dims(w, h),
00048                            MC_RECURSE | MC_IGNORE_MISSING);
00049 
00050   manager.start();
00051 
00052   bool goforever = true;
00053 
00054   rutz::shared_ptr<XWinManaged> dispWin;
00055   dispWin.reset(new XWinManaged(Dims(w*2,h*2), 0, 0, "Pipe Recognizer Display"));
00056 
00057   // input and output image
00058 
00059   Image< PixRGB<byte> > img(w,h, ZEROS);
00060   Image< PixRGB<byte> > canny(w,h, ZEROS);
00061 
00062   //uint fNum = 0;
00063   while(goforever)
00064     {
00065       Image< PixRGB<byte> > dispImg(w*2,h*2, ZEROS);
00066       rutz::shared_ptr<Image< PixRGB<byte> > > outputImg(new Image<PixRGB<byte> >(w,h, ZEROS));
00067 
00068       //rutz::shared_ptr<Image<byte> > orangeIsoImage;
00069       //orangeIsoImage.reset(new Image<byte>(w,h, ZEROS));
00070 
00071       ifs->updateNext(); img = ifs->readRGB();
00072       if(!img.initialized()) {Raster::waitForKey(); break; }
00073 
00074           //find edges of segmented image using canny
00075           //IplImage *edge = cvCreateImage( cvGetSize(img2ipl(img)), 8, 1 );
00076           //cvCanny( img2ipl(luminance(img)), edge, 100, 150, 3 );//150,200,3
00077          // canny = ipl2rgb(edge);
00078 
00079       //inplacePaste(dispImg, canny, Point2D<int>(w,0));
00080       inplacePaste(dispImg, img, Point2D<int>(0,0));
00081 
00082       //orangeIsoImage->resize(w,h);
00083       //isolateOrange(img, *orangeIsoImage);
00084 
00085       //inplacePaste(dispImg, toRGB(*orangeIsoImage), Point2D<int>(w,0));
00086 
00087       /*pipeRecognizer->getPipeLocation(orangeIsoImage,
00088                                       outputImg,
00089                                       PipeRecognizer::HOUGH,
00090                                       pipeCenter,
00091                                       pipeAngle);
00092 
00093       projPoint.i = (int)(pipeCenter->i+30*cos(*pipeAngle));
00094       projPoint.j = (int)(pipeCenter->j+30*sin(*pipeAngle));
00095 
00096       drawLine(*outputImg, *pipeCenter, projPoint, PixRGB <byte> (255, 255,0), 3);
00097 
00098       inplacePaste(dispImg, *outputImg, Point2D<int>(0,h));
00099  */
00100 
00101       //wait a little
00102 
00103       dispWin->drawImage(dispImg, 0, 0);
00104       Raster::waitForKey();
00105     }
00106 
00107   // get ready to terminate:
00108   manager.stop();
00109   return 0;
00110 }
00111 
00112 // ######################################################################
00113 /* So things look consistent in everyone's emacs... */
00114 /* Local Variables: */
00115 /* indent-tabs-mode: nil */
00116 /* End: */
Generated on Sun May 8 08:42:15 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3