00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <l1394_session.h>
00023 #include <l1394_XShmImg.h>
00024
00025 using namespace L1394;
00026 using namespace L1394_MM;
00027
00028 int exit()
00029 {
00030 cout << "delete Session ok" << endl;
00031 return 0;
00032 }
00033
00034 int main(int argc, char* argv[])
00035 {
00036 int cam_id = 1;
00037
00038 if (argc == 2)
00039 cam_id = atoi(argv[1]);
00040
00041 Session* session = SSession::getInstance();
00042
00043 list<Camera*> camera_list = session->getAllCameras();
00044
00045 if (cam_id > camera_list.size() )
00046 {
00047 cout << "Only " << camera_list.size() << " Camera available" << endl;
00048 return exit();
00049 }
00050
00051 list<Camera*>::iterator it = camera_list.begin();
00052 Camera* camera = 0;
00053 for (int i = 0; i< cam_id; i++)
00054 {
00055 camera = *it;
00056 it++;
00057 }
00058
00059
00060 if (camera == 0)
00061 {
00062 cout << "No camera found " << endl;
00063 return exit();
00064 }
00065
00066 if (camera->setParameter(30, FREE_ISO_CHANNEL , DEVICE_ISO_RUN, DEVICE_320x240_YUV_422 ,DEVICE_FRAMES_30) != L1394_SUCCESS)
00067 {
00068 cout << "could not set Parameter" << endl;
00069 return exit();
00070 }
00071 if (camera->init() != L1394_SUCCESS)
00072 {
00073 cout << "could not init the camera" << endl;
00074 return exit();
00075 }
00076
00077
00078 XShmImg* window = new XShmImg("Camera 1", L1394_MM::Converter::UYVYtoBGRA32);
00079 window->connect(camera);
00080 if (camera->start() == L1394_FAILED)
00081 cout << "Could not start the camera " << endl;
00082 window->start();
00083
00084 char q = 'a';
00085 bool quit = false;
00086 while(!quit)
00087 {
00088 cout << "press (r) to start, (p) for pause, (q) for quit, (s) for 7.5fps, (f) for 30fps" << endl;
00089 cin >> q;
00090 switch (q)
00091 {
00092 case 'r' : camera->start(); window->start(); break;
00093 case 'p' : window->stop(); camera->stop(); break;
00094 case 'f' : window->stop(); camera->stop(); camera->setParameter(5, FREE_ISO_CHANNEL , DEVICE_ISO_RUN, DEVICE_320x240_YUV_422 ,DEVICE_FRAMES_30); camera->init(); camera->start(); window->start(); break;
00095 case 's' : window->stop(); camera->stop(); camera->setParameter(5, FREE_ISO_CHANNEL , DEVICE_ISO_RUN, DEVICE_320x240_YUV_422 ,DEVICE_FRAMES_7_5); camera->init(); camera->start(); window->start(); break;
00096 case 'q' : quit = true; break;
00097 default: break;
00098 }
00099 }
00100 window->stop();
00101 camera->stop();
00102
00103 return exit();
00104 }
00105