Horus Doc || Corba Reference || Corba   Client Server   Stubs C++   Stubs Java   Servant Generator  

clientVxStructureDemo.c File Reference

#include <OB/CORBA.h>
#include "HxCorbaGlobalOps.h"
#include "HxCorbaConstructor.h"
#include "HxCorbaVxSegmentation.h"
#include "HxCorbaVxStructure.h"
#include <string>
#include <iostream>

Defines

#define STD_COUT   std::cout
#define STD_ENDL   std::endl
#define VXBLOCKS   HxCorba::VxStructure::BLOCKS
#define VXSCENES   HxCorba::VxStructure::SCENES

Functions

void waitForEnter ()
ostream & operator<< (ostream &os, const HxCorba::VxSegmentation_ptr &seg)
int clientVxStructureDemo (CORBA::ORB_ptr orb, int argc, char *argv[])

Define Documentation

#define STD_COUT   std::cout
 

#define STD_ENDL   std::endl
 

#define VXBLOCKS   HxCorba::VxStructure::BLOCKS
 

#define VXSCENES   HxCorba::VxStructure::SCENES
 


Function Documentation

void waitForEnter  
 

00029 {
00030     STD_COUT << "Press <ENTER> to continue with demo." << STD_ENDL;
00031     char c;
00032     scanf("%c",&c);
00033 }

ostream & operator<< ostream &    os,
const HxCorba::VxSegmentation_ptr   seg
 

00176 {
00177     HxCorba::StringSeq_var ids = seg->getIds();
00178     HxCorba::StringSeq_var types = seg->getTypes();
00179 
00180     // put header
00181     // #@ name
00182     os << "#@ \"start\" \"end\" ";
00183     for(int i=0; i<ids->length(); i++) os << "\"" << ids[i] << "\" ";
00184     os << STD_ENDL;
00185 
00186     // #= type
00187     os << "#= \"int\" \"int\" ";
00188     for(i=0; i<types->length(); i++) os << "\"" << types[i] << "\" ";
00189     os << STD_ENDL;
00190 
00191     // put body
00192     HxCorba::VxSegmentSeq_var segments = seg->getAll();
00193     for(i=0; i<segments->length(); i++) {
00194         os << segments[i]->start() << " " << segments[i]->end() << " ";
00195         for(int j=0; j<ids->length(); j++) {
00196             if(strcmp(types[j], "int") == 0)
00197                 os << segments[i]->getInt(ids[j]) << " ";
00198             else if(strcmp(types[j], "double") == 0)
00199                 os << segments[i]->getDouble(ids[j]) << " ";
00200             else if(strcmp(types[j], "string") == 0)
00201                 os << "\"" << segments[i]->getString(ids[j]) << "\" ";
00202         }
00203         os << STD_ENDL;
00204     }
00205 
00206     return os;
00207 }

int clientVxStructureDemo CORBA::ORB_ptr    orb,
int    argc,
char *    argv[]
 

00039 {
00040     STD_COUT << "VxStructureDemo -base [fileroot] -feature [full filename]" << STD_ENDL;
00041 
00042     string base="n:\\demodata\\friends418.";
00043 //  base="n:\\videodatabase\\friends\\417\\friends417.";
00044 //  base="n:\\videodatabase\\witness\\cd1\\witness_cd1";
00045 
00046     string fCameraFeature="n:\\demodata\\friends418.cam";
00047 
00048     if (argc<2)
00049         STD_COUT << "No input parameters. Going for defaults." << STD_ENDL;
00050     else
00051         for (int i=1; i<argc; i++)
00052         {
00053             string arg = argv[i];
00054             if (arg.compare("-base")==0)
00055                 base=argv[i+1];
00056             if (arg.compare("-feature")==0)
00057                 fCameraFeature=argv[i+1];
00058         }
00059 
00060     CORBA::Object_var obj;
00061     obj = orb->resolve_initial_references("Constructor");
00062     HxCorba::Constructor_var cons = HxCorba::Constructor::_narrow(obj);
00063     obj = orb->resolve_initial_references("GlobalOps");
00064     HxCorba::GlobalOps_var ops = HxCorba::GlobalOps::_narrow(obj);
00065 
00066     // Demo1
00067 
00068     STD_COUT << "Demo 1: read blocks and scenes in VxStructure." << STD_ENDL;
00069     HxCorba::StringSeq_var extList = new HxCorba::StringSeq();
00070     extList->length(2);
00071     extList[0] = CORBA::string_dup(VXBLOCKS);
00072     extList[1] = CORBA::string_dup(VXSCENES);
00073 
00074     HxCorba::VxStructure_var vs = cons->makeVxStructure(base.c_str(), extList);
00075 
00076     for(int i=0; i<extList->length(); i++)
00077         STD_COUT << "  Read: " << extList[i].in() << STD_ENDL;
00078     STD_COUT << STD_ENDL;
00079     
00080     HxCorba::VxSegmentation_var res1 = vs->getShots();
00081     HxCorba::VxSegmentation_var res2 = vs->getEffects();
00082 
00083     STD_COUT << "  " << vs->size(VXBLOCKS) << " blocks contain " << res1->size() << " shots and " << res2->size() << " effects." << STD_ENDL;
00084     STD_COUT << "  " << vs->size(VXSCENES) << " scenes." << STD_ENDL;
00085 
00086     waitForEnter();
00087 
00088     STD_COUT << "Demo 2: process blocks and scenes in VxStructure." << STD_ENDL;
00089 
00090     STD_COUT << "  Continuity blocks level: " << (vs->isContinuous(VXBLOCKS)? "true":"false") << STD_ENDL;
00091     STD_COUT << "  Continuity scenes level: " << (vs->isContinuous(VXSCENES)? "true":"false") << STD_ENDL;
00092 
00093     STD_COUT << "  Sequentiality blocks level: " << (vs->isSequential(VXBLOCKS)? "true":"false") << STD_ENDL;
00094     STD_COUT << "  Sequentiality scenes level: " << (vs->isSequential(VXSCENES)? "true":"false") << STD_ENDL;
00095     
00096 
00097     STD_COUT << "  Blocks segment boundaries in first 2000 frames: ";
00098     HxCorba::VxTimeSpan timeSpan = {0, 2000};
00099     HxCorba::LongSeq_var l = vs->getSegmentBoundaries(VXBLOCKS,timeSpan);
00100     for(i=0; i<l->length(); i++)
00101         STD_COUT << l[i] << " ";
00102     STD_COUT << STD_ENDL;
00103 
00104     STD_COUT << "  Scenes segment boundaries in first 20000 frames: ";
00105     timeSpan.end = 20000;
00106     l = vs->getSegmentBoundaries(VXSCENES,timeSpan);
00107     for(i=0; i<l->length(); i++)
00108         STD_COUT << l[i] << " ";
00109     STD_COUT << STD_ENDL;
00110 
00111     STD_COUT << STD_ENDL;
00112 
00113     STD_COUT << "  Blocks parent of scenes: " << (vs->isParentOf(VXBLOCKS,VXSCENES)? "true":"false") << STD_ENDL;
00114     STD_COUT << "  Blocks parent of blocks: " << (vs->isParentOf(VXBLOCKS,VXBLOCKS)? "true":"false") << STD_ENDL;
00115     STD_COUT << "  Scenes parent of blocks: " << (vs->isParentOf(VXSCENES,VXBLOCKS)? "true":"false") << STD_ENDL;
00116     STD_COUT << "  Scenes parent of scenes: " << (vs->isParentOf(VXSCENES,VXSCENES)? "true":"false") << STD_ENDL;
00117 
00118     STD_COUT << STD_ENDL;
00119 
00120     STD_COUT << "  Blocks child of scenes: " << (vs->isChildOf(VXBLOCKS,VXSCENES)? "true":"false") << STD_ENDL;
00121     STD_COUT << "  Blocks child of blocks: " << (vs->isChildOf(VXBLOCKS,VXBLOCKS)? "true":"false") << STD_ENDL;
00122     STD_COUT << "  Scenes child of blocks: " << (vs->isChildOf(VXSCENES,VXBLOCKS)? "true":"false") << STD_ENDL;
00123     STD_COUT << "  Scenes child of scenes: " << (vs->isChildOf(VXSCENES,VXSCENES)? "true":"false") << STD_ENDL;
00124 
00125     STD_COUT << STD_ENDL;
00126 
00127     waitForEnter();
00128 
00129 
00130     HxCorba::VxTimeSpan elt1 = {140,290};
00131     HxCorba::VxTimeSpan elt2 = {100,189};
00132     
00133     STD_COUT << "Demo 3: temporal relations between 2 segments: " 
00134         << elt1.start << " " << elt1.end << " and " 
00135         << elt2.start << " " << elt1.end << ". " << STD_ENDL;
00136     
00137     STD_COUT << "  Relation: " << ops->VxRelAsString(elt1,elt2) << STD_ENDL;
00138 
00139     STD_COUT << "  Equals " << (ops->VxRelEquals(elt1,elt2) ? "true" : "false") << STD_ENDL;
00140     STD_COUT << "  Before " << (ops->VxRelBefore(elt1,elt2) ? "true" : "false") << STD_ENDL;
00141     STD_COUT << "  Meets " << (ops->VxRelMeets(elt1,elt2) ? "true" : "false") << STD_ENDL;
00142     STD_COUT << "  Overlaps " << (ops->VxRelOverlaps(elt1,elt2) ? "true" : "false") << STD_ENDL;
00143     STD_COUT << "  Dur " << (ops->VxRelDur(elt1,elt2) ? "true" : "false") << STD_ENDL;
00144     STD_COUT << "  Con " << (ops->VxRelCon(elt1,elt2) ? "true" : "false") << STD_ENDL;
00145     STD_COUT << "  BeforeA " << (ops->VxRelBeforeAfter(elt1,elt2) ? "true" : "false") << STD_ENDL;
00146     STD_COUT << "  MeetsA " << (ops->VxRelMeetsAnywhere(elt1,elt2) ? "true" : "false") << STD_ENDL;
00147     STD_COUT << "  OverlapsA " << (ops->VxRelOverlapsAnywhere(elt1,elt2) ? "true" : "false") << STD_ENDL << STD_ENDL;
00148 
00149     waitForEnter();
00150 
00151     HxCorba::VxSegmentation_var segmentation;
00152 
00153     string strChandler = "Chandler";
00154     STD_COUT << "Demo 4: show all blocks that have description=" << strChandler << STD_ENDL;
00155     segmentation = vs->getWhereString(VXBLOCKS,"description",strChandler.c_str());
00156     STD_COUT << segmentation << STD_ENDL;
00157 
00158     waitForEnter();
00159 
00160     STD_COUT << "Demo 5: read camera feature file (other structure than shots)" << STD_ENDL;
00161 
00162     segmentation = cons->makeVxSegmentation(fCameraFeature.c_str());
00163     vs->push("camera", segmentation);
00164 
00165     string strCamWork = "zoom";
00166     STD_COUT << "  Show all segments that have a " << strCamWork << " camera effect" << STD_ENDL;
00167     segmentation = vs->getWhereString("camera","type",strCamWork.c_str());
00168     STD_COUT << segmentation << STD_ENDL;
00169 
00170     STD_COUT << "VxStructureDemo ended" << STD_ENDL;
00171 
00172     return EXIT_SUCCESS;
00173 }


Generated on Tue Feb 3 14:20:12 2004 for CorbaReference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001