EchoImageClientIce.C

00001 #include "Component/ModelManager.H"
00002 #include "Component/ModelComponent.H"
00003 #include "Component/ModelParam.H"
00004 #include "Media/FrameSeries.H"
00005 #include <Image/Image.H>
00006 #include <Image/Pixels.H>
00007 #include "Raster/GenericFrame.H"
00008 #include "GUI/XWindow.H"
00009 #include "Raster/Raster.H"
00010 
00011 #include "Ice/IceImageCompressor.H"
00012 #include "Ice/IceImageDecompressor.H"
00013 
00014 #include "Ice/IceImageUtils.H"
00015 #include <Ice/Ice.h>
00016 #include "Ice/ImageIce.ice.H"
00017 #include <fstream>
00018 
00019 using namespace std;
00020 using namespace ImageIceMod;
00021 
00022 int main(const int argc, const char **argv) {
00023 
00024   IceImageCompressor   comp;
00025   IceImageDecompressor decomp;
00026 
00027   ModelManager *mgr = new ModelManager("EchoImageClientManager");
00028   mgr->debugMode();
00029   nub::ref<InputFrameSeries> ifs(new InputFrameSeries(*mgr));
00030   mgr->addSubComponent(ifs);
00031   nub::ref<OutputFrameSeries> ofs(new OutputFrameSeries(*mgr));
00032   mgr->addSubComponent(ofs);
00033 
00034   mgr->parseCommandLine(argc, argv, "", 0, 0);
00035   mgr->start();
00036   Image< PixRGB<byte> > inputImg;
00037   ifs->updateNext();
00038   GenericFrame input = ifs->readFrame();
00039   inputImg = input.asRgb();
00040 
00041   int status = 0;
00042 //  Ice::CommunicatorPtr ic;
00043 //  try {
00044 //    int dummy=0;
00045 //    ic = Ice::initialize(dummy,0);
00046 //    Ice::ObjectPrx base = ic->stringToProxy(
00047 //        "SimpleImageShuttle:default -p 10000");
00048 //    ImageShuttlePrx imageshuttle = ImageShuttlePrx::checkedCast(base);
00049 //    if(!imageshuttle)
00050 //      throw "Invalid proxy";
00051 
00052 
00053     while(true)
00054     {
00055 
00056       //inputImg = Image<PixRGB<byte> >(2,2,ZEROS);
00057       std::vector<unsigned char> compressedImage = comp.CompressImage(inputImg);
00058       std::cout << "Finished Compression! Final Array is " << compressedImage.size() << " bytes" << std::endl;
00059 //      imageshuttle->transferImage(Image2Ice(inputImg));
00060 
00061       ofstream outfile ("COMPRESSEDOUTPUT.jpg", ios::out | ios::binary);
00062       //outfile.write(&compressedImage[0], compressedImage.size());
00063       copy(compressedImage.begin(), compressedImage.end(), ostreambuf_iterator<char>(outfile));
00064       outfile.close();
00065 
00066 
00067       Image<PixRGB<byte> > uncompressedImage = decomp.DecompressImage(compressedImage);
00068       ofs->writeRGB(uncompressedImage, "FRAME");
00069 
00070       Raster::waitForKey();
00071 
00072 
00073       ifs->updateNext();
00074       GenericFrame input = ifs->readFrame();
00075       inputImg = input.asRgb();
00076 
00077       if(!inputImg.initialized()) break;
00078     }
00079 
00080 
00081   //}
00082   //catch (const Ice::Exception& ex) {
00083   //  cerr << ex << endl;
00084   //  status = 1;
00085   //}
00086   //catch(const char* msg) {
00087   //  cerr << msg << endl;
00088   //  status = 1;
00089   //}
00090   //if (ic)
00091   //  ic->destroy();
00092   return status;
00093 }
00094 
Generated on Sun May 8 08:04:51 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3