00001 /* --------------------------------------------------------------------------- 00002 Phission : 00003 Realtime Vision Processing System 00004 00005 Copyright (C) 2003 Philip D.S. Thoren (pthoren@cs.uml.edu) 00006 University of Massachusetts at Lowell, 00007 Laboratory for Artificial Intelligence and Robotics 00008 00009 This file is part of Phission. 00010 00011 ---------------------------------------------------------------------------*/ 00012 #include <FLLiveSourceTest.h> 00013 #include <phission.h> 00014 00015 /* ------------------------------------------------------------------------ */ 00016 void usage() 00017 { 00018 printf("\n\nUsage:\n",argv[0]); 00019 printf("\t--help\t\t\tdisplay usage\n"); 00020 printf("\t--test <value>\tsleep 'value' seconds and then close test\n"); 00021 printf("\n\n"); 00022 exit(1); 00023 } 00024 00025 /* ------------------------------------------------------------------------ */ 00026 int main(int argc, char *argv[] ) 00027 { 00028 phFUNCTION("main") 00029 00030 int displaysOpen= 1; 00031 FLDisplay *display = new FLDisplay(320,240,"FLLiveSourceTest"); 00032 00033 char *capture_path = NULL; 00034 int channel = 0; 00035 00036 #ifdef WIN32 00037 VFWSource *capture = new VFWSource(); 00038 #else 00039 V4LCapture *capture = new V4LCapture(); 00040 #endif 00041 00042 /* Utility class to ease the starting and stopping of displays, captures and 00043 * pipelines */ 00044 phSystem system; 00045 00046 /* Remove the code below when using this code as an example. 00047 * 00048 * This just checks whether "--test" has been specified with 00049 * a time value argument. It's for testing all the examples 00050 * without the need for human intervention. */ 00051 int test = 0; 00052 00053 phArgTable *arg_parser = new phArgTable(); 00054 00055 /* Setup and parse all the arguments */ 00056 rc = arg_parser->add("--test",&test,phARG_INT); 00057 phCHECK_RC(rc,NULL,"arg_parser->add"); 00058 rc = arg_parser->add("--help",(void *)&usage,phARG_FUNC); 00059 phCHECK_RC(rc,NULL,"arg_parser->add"); 00060 00061 rc = arg_parser->add("--path",&capture_path,phARG_CHAR); 00062 phCHECK_RC(rc,NULL,"arg_parser->add"); 00063 00064 rc = arg_parser->add("--channel",&channel,phARG_INT); 00065 phCHECK_RC(rc,NULL,"arg_parser->add"); 00066 00067 rc = arg_parser->parse(argc,argv); 00068 phCHECK_RC(rc,NULL,"arg_parser->parse"); 00069 00070 capture->set(320,240,capture_path); 00071 capture->setChannel(channel); 00072 display->setLiveSourceInput(capture->getLiveSourceOutput()); 00073 00074 rc = system.addCapture(capture); 00075 phPRINT_RC(rc,NULL,"system.addCapture(capture)"); 00076 00077 rc = system.addDisplay(display); 00078 phPRINT_RC(rc,NULL,"system.addDisplay(display)"); 00079 00080 00081 /* startup */ 00082 rc = system.startup(); 00083 phPRINT_RC(rc,NULL,"system.startup()"); 00084 00085 /* start the live source */ 00086 00087 while (displaysOpen) 00088 { 00089 /* Sleep a while, don't loop tightly */ 00090 00091 phMSleep(100); 00092 00093 /* Yielding is optional. This gives up the thread's timeslice 00094 * to prevent slow response in other threads. It consumes more 00095 * CPU cycles than sleeping. Use it instead of sleeping if 00096 * this loop is processing anything */ 00097 00098 /* phYield(); */ 00099 00100 displaysOpen = 0; 00101 if (display->isOpen()) 00102 { 00103 displaysOpen = 1; 00104 } 00105 00106 /* Remove this if block when using this code as an example */ 00107 /* Set the loop control value to end the loop when testing */ 00108 if (test > 0) 00109 { 00110 displaysOpen = 0; 00111 phSleep(test); /* test's value should be a time (in secs) value > 0*/ 00112 } 00113 } 00114 00115 rc = system.shutdown(); 00116 phPRINT_RC(rc,NULL,"system.shutdown()"); 00117 00118 error: 00119 phDelete(display); 00120 phDelete(capture); 00121 00122 phFree(capture_path); 00123 phDelete(arg_parser); 00124 00125 return phSUCCESS; 00126 }
Copyright (C) 2002 - 2007 |
Philip D.S. Thoren ( pthoren@users.sourceforge.net ) University Of Massachusetts at Lowell Robotics Lab |