capture.h

00001 /* -- 2007-05-07 -- 
00002  *  ardev - an augmented reality library for robot developers
00003  *  Copyright 2005-2007 - Toby Collett (ardev _at_ plan9.net.nz)
00004  *
00005  *  This library is free software; you can redistribute it and/or
00006  *  modify it under the terms of the GNU Lesser General Public
00007  *  License as published by the Free Software Foundation; either
00008  *  version 2.1 of the License, or (at your option) any later version.
00009  *
00010  *  This library is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00013  *  Lesser General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU Lesser General Public
00016  *  License along with this library; if not, write to the Free Software
00017  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
00018  *
00019  */
00020 #ifndef ARDEV_CAPTURE_H
00021 #define ARDEV_CAPTURE_H
00022 
00023 /***************************************************************************
00024  *            capture.h
00025  *
00026  *  Wed Apr 21 15:34:26 2004
00027  *  Copyright  2004  Toby Collett
00028  *  Email
00029  ****************************************************************************/
00030 
00031 #include <ardev/ardevconfig.h>
00032 #include <ardev/ardev.h>
00033 
00034 #include <sys/time.h>
00035 #include <linux/videodev.h>
00036 #include <libthjc/misc.h>
00037 
00038 #ifdef HAVE_DC1394
00039 #include <libraw1394/raw1394.h>
00040 #include <dc1394/control.h>
00041 #endif
00042 
00043 
00044 
00051 class CaptureFile : public CaptureObject
00052 {
00053         public:
00059                 CaptureFile(const char * FileName, int Delay=0);
00061                 const ARImage & GetFrame();
00063                 int GetMaxWidth();
00065                 int GetMaxHeight();
00066         private:
00067                 char * FileName; 
00068                 int Delay; 
00069                 ARImage  Frame; 
00070 };
00071 
00072 
00076 class CaptureV4L : public CaptureObject
00077 {
00078         public:
00080                 CaptureV4L(const char * _VideoDev ="/dev/video0", int _width=768, int _height=480, int _channel=1, int _format=1, int _tuner=-1);
00082                 virtual ~CaptureV4L() {free(VideoDev);};
00084                 const ARImage & GetFrame();
00086                 bool Fresh() {return !Blocking;};
00088                 int GetMaxWidth();
00090                 int GetMaxHeight();
00091         private:
00092                 char * VideoDev; 
00093                 int width; 
00094                 int height; 
00095                 int channel; 
00096                 int format; 
00097                 //int tuner; ///< The v4l tuner to use (-1 for none)
00098                 
00099                 int NumFrames;
00100                 int CurrentFrame;
00101         
00102                 bool Open; 
00103                 int vid_fd; 
00104                 unsigned char * uservmem; 
00105                 struct video_mmap m_vmem; 
00106                 bool Blocking;
00107                 
00108                 ARImage Frame; 
00109 };
00110 
00111 #ifdef HAVE_DC1394
00112 
00115 class CaptureDC1394 : public CaptureObject
00116 {
00117         public:
00119                 CaptureDC1394();
00121                 virtual ~CaptureDC1394();
00122 
00124                 virtual int Initialise(bool Active = true);
00126                 virtual void Terminate();
00127 
00128 
00130                 const ARImage & GetFrame();
00132                 bool Fresh() {return !Blocking;};
00134                 int GetMaxWidth();
00136                 int GetMaxHeight();
00137         private:
00138                 bool Open; 
00139                 bool Blocking;
00140                 
00142                 dc1394camera_t * camera;
00143                 dc1394featureset_t features;
00144                 dc1394format7modeset_t modeset;
00145                 //unsigned int channel;
00146                 dc1394speed_t speed;
00147                 
00148                 StopWatch Timer;
00149                 
00150                 ARImage Frame; 
00151 };
00152 #endif
00153 
00154 #endif

SourceForge.net Logo Generated on Sat May 12 15:25:43 2007 for ardev by doxygen 1.5.1