Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

tutorial_3.cpp

Go to the documentation of this file.
00001 /****************************************************************
00002 **
00003 ** L1394 tutorial 3
00004 **
00005 ** This program searches all DccCameras and sets all parameters
00006 ** to the minimum value of a camera.
00007 **
00008 **  begin                : Thu Nov 30 2000
00009 **  copyright            : (C) 2000-2004 by Michael Repplinger
00010 **  email                : repplinger@cs.uni-sb.de
00011 *******************************************************************/
00012 
00013 /***************************************************************************
00014  *                                                                         *
00015  *   This program is free software; you can redistribute it and/or modify  *
00016  *   it under the terms of the GNU General Public License as published by  *
00017  *   the Free Software Foundation; either version 2 of the License, or     *
00018  *   (at your option) any later version.                                   *
00019  *                                                                         *
00020  ***************************************************************************/
00021 
00022 
00023 
00024 #include <iostream>
00025 #include <l1394_session.h>
00026 
00027 using namespace L1394;
00028 
00029 /*
00030     Function setParameter() shows how to control a device.
00031     If you access a feature of a Camera, a pointer to the register object is returned.
00032     Now you can specify how to use the feature.
00033     For example you can test, if the feature is supported by a camera.
00034 */
00035 void setParameter(Camera* camera)
00036 {
00037   if (camera->whiteBalance()->hasFeature()) //If the feature is supported
00038     camera->whiteBalance()->onePush();      //Call onePush
00039 
00040 
00041 /*
00042     The following example tests, if a feature is supported
00043     and sets the actual value to the minimum value of a Camera.
00044     Then it tests, if the new value is set correct.
00045 */
00046   if (camera->zoom()->hasFeature())
00047   {
00048    camera->zoom()->setValue(camera->zoom()->getMinValue());
00049    if (camera->zoom()->getValue() == camera->zoom()->getMinValue())
00050     cout << "Zoom value is set correct" << endl;
00051    else
00052     cout << "Zoom value is not set correct" << endl;
00053   }
00054   else
00055    cout << "Zoom feature not present" << endl;
00056 
00057 
00058   if (camera->gamma()->hasFeature())
00059   {
00060    camera->gamma()->setValue(camera->gamma()->getMinValue());
00061    if (camera->gamma()->getValue() == camera->gamma()->getMinValue())
00062     cout << "Gamma value is set correct" << endl;
00063    else
00064     cout << "Gamma value is not set correct" << endl;
00065   }
00066   else
00067    cout << "Gamma feature not present" << endl;
00068 
00069 
00070 
00071   if (camera->hue()->hasFeature())
00072   {
00073    camera->hue()->setValue(camera->hue()->getMinValue());
00074    if (camera->hue()->getValue() == camera->hue()->getMinValue())
00075     cout << "Hue value is set correct" << endl;
00076    else
00077     cout << "Hue value is not set correct" << endl;
00078   }
00079   else
00080    cout << "Hue feature not present" << endl;
00081 
00082 
00083 
00084   if (camera->saturation()->hasFeature())
00085   {
00086    camera->saturation()->setValue(camera->saturation()->getMinValue());
00087    if (camera->saturation()->getValue() == camera->saturation()->getMinValue())
00088     cout << "Saturation value is set correct" << endl;
00089    else
00090     cout << "Saturation value is not set correct" << endl;
00091   }
00092   else
00093    cout << "Saturation feature not present" << endl;
00094 
00095   //and so on......
00096 }
00097 
00098 int main()
00099 {
00100   Session* session = SSession::getInstance();
00101   if (!session) {
00102     cerr << "Could not get Session object" << endl;
00103     return 0;
00104   }
00105 
00106   //request all DccCameras
00107   list<DccCamera*> camera_list = session->getAllDccCameras();
00108 
00109   if (camera_list.size() == 0) {
00110     cout << "No camera found. " <<endl;
00111     exit(0);
00112   }
00113 
00114   DccCamera* camera = 0;
00115   for(list<DccCamera*>::iterator it = camera_list.begin(); it != camera_list.end(); it++)
00116   {
00117    //setParameter(*it);
00118    camera = *it;
00119   if (camera->setParameter(30, FREE_ISO_CHANNEL , DEVICE_ISO_RUN, DEVICE_320x240_YUV_422 ,DEVICE_FRAMES_30) != L1394_SUCCESS)
00120   {
00121     cout << "could not set Parameter" << endl;
00122     return 0;
00123   }
00124   if (camera->init() != L1394_SUCCESS)
00125   {
00126     cout << "could not init the camera" << endl;
00127     return 0;
00128   }
00129   camera->start();
00130   }
00131   while(1) {
00132   cout << ".";
00133   cout.flush();
00134     camera->getFrame();
00135 
00136   }
00137   return 0;
00138 }

Generated on Wed Aug 24 00:36:41 2005 for L1394 by doxygen 1.4.2
L1394 library (NMM) grahics.cs.uni-sb.de/~repplix/l1394_home/