libcvd-members
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libcvd-members] libcvd cvd/videosource.h cvd/OSX/qtbuffer.h cvd...


From: Gerhard Reitmayr
Subject: [libcvd-members] libcvd cvd/videosource.h cvd/OSX/qtbuffer.h cvd...
Date: Thu, 12 Nov 2009 16:26:52 +0000

CVSROOT:        /cvsroot/libcvd
Module name:    libcvd
Changes by:     Gerhard Reitmayr <gerhard>      09/11/12 16:26:52

Modified files:
        cvd            : videosource.h 
        cvd/OSX        : qtbuffer.h 
        cvd_src        : videosource.cpp 
        cvd_src/OSX    : qtbuffer.cpp videosource_noqtbuffer.cc 
                         videosource_qtbuffer.cc 
        progs          : calibrate.cxx 

Log message:
        

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/videosource.h?cvsroot=libcvd&r1=1.24&r2=1.25
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/OSX/qtbuffer.h?cvsroot=libcvd&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/videosource.cpp?cvsroot=libcvd&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/OSX/qtbuffer.cpp?cvsroot=libcvd&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/OSX/videosource_noqtbuffer.cc?cvsroot=libcvd&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/OSX/videosource_qtbuffer.cc?cvsroot=libcvd&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/libcvd/progs/calibrate.cxx?cvsroot=libcvd&r1=1.18&r2=1.19

Patches:
Index: cvd/videosource.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/videosource.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- cvd/videosource.h   2 Nov 2009 16:50:25 -0000       1.24
+++ cvd/videosource.h   12 Nov 2009 16:26:52 -0000      1.25
@@ -239,14 +239,15 @@
        // QuickTime buffer
        //
 
-       template <class T> VideoBuffer<T> * makeQTBuffer( const ImageRef & , 
int , bool )
+       template <class T> VideoBuffer<T> * makeQTBuffer( const ImageRef & , 
int , bool, bool )
        {
-               throw VideoSourceException("QTBuffer cannot handle types other 
than vuy422");
+               throw VideoSourceException("QTBuffer cannot handle " + 
PNM::type_name<T>::name());
        }
-       template <> VideoBuffer<vuy422> * makeQTBuffer( const ImageRef & size, 
int input, bool showsettings);
-       template <> VideoBuffer<yuv422> * makeQTBuffer( const ImageRef & size, 
int input, bool showsettings);
+       template <> VideoBuffer<vuy422> * makeQTBuffer( const ImageRef & size, 
int input, bool showsettings, bool verbose);
+       template <> VideoBuffer<yuv422> * makeQTBuffer( const ImageRef & size, 
int input, bool showsettings, bool verbose);
+       template <> VideoBuffer<Rgb<byte> > * makeQTBuffer( const ImageRef & 
size, int input, bool showsettings, bool verbose);
        
-       void get_qt_options(const VideoSource & vs, ImageRef & size, bool & 
showsettings);
+       void get_qt_options(const VideoSource & vs, ImageRef & size, bool & 
showsettings, bool & verbose);
 
 
        
////////////////////////////////////////////////////////////////////////////////
@@ -318,10 +319,10 @@
                } 
        else if (vs.protocol == "qt") {
                ImageRef size;
-               bool showsettings;
+               bool showsettings, verbose;
                int input = atoi(vs.identifier.c_str());
-               get_qt_options(vs, size, showsettings);
-               return makeQTBuffer<T>(size, input, showsettings);
+               get_qt_options(vs, size, showsettings, verbose);
+               return makeQTBuffer<T>(size, input, showsettings, verbose);
        }
                else
                        throw VideoSourceException("undefined video source 
protocol: '" + vs.protocol + "'\n\t valid protocols: "
@@ -458,7 +459,8 @@
 
 'qt' protocol (QTBuffer): identifier is camera number
          size = vga | qvga | <width>x<height>  (default vga)
-         showsettings = 0 | 1 (default 0)
+         showsettings [ = <bool> ] (default 0)
+         verbose [ = <bool> ] (default 0)
 
 'jpegstream' protocol (ServerPushJpegBuffer): identifier is path to file
          read_ahead  [= <number>] (default is 50 if specified without value)

Index: cvd/OSX/qtbuffer.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/OSX/qtbuffer.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- cvd/OSX/qtbuffer.h  3 Dec 2008 23:32:33 -0000       1.4
+++ cvd/OSX/qtbuffer.h  12 Nov 2009 16:26:52 -0000      1.5
@@ -93,9 +93,9 @@
         /** constructor
                * @param dev file name of the device to open
                * @param mode color palette to use (not supported yet)
-               * @param which camera to open (not supported yet)
+               * @param num which camera to open
                */
-      RawQT(const ImageRef & size, unsigned int mode, unsigned int num = 0, 
bool showSettingsDialog=false);
+               RawQT(const ImageRef & size, unsigned int mode, unsigned int 
num = 0, bool showSettingsDialog=false, bool verbose = false);
         virtual ~RawQT();
         
                /** Get the width in pixels of the captured frames. */
@@ -135,7 +135,7 @@
 public:
     /// Construct a video buffer
     /// @param dev file name of the device to use
-    QTBuffer(const ImageRef & size, unsigned int number = 0, bool 
showSettingsDialog=false ) : VideoBuffer<T>(VideoBufferType::Live), RawQT( 
size, 0, number, showSettingsDialog ) {}
+    QTBuffer(const ImageRef & size, unsigned int number = 0, bool 
showSettingsDialog=false, bool verbose = false ) : 
VideoBuffer<T>(VideoBufferType::Live), RawQT( size, 0, number, 
showSettingsDialog, verbose ) {}
        
     virtual ImageRef size()
     {

Index: cvd_src/videosource.cpp
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd_src/videosource.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- cvd_src/videosource.cpp     26 Oct 2009 15:44:58 -0000      1.14
+++ cvd_src/videosource.cpp     12 Nov 2009 16:26:52 -0000      1.15
@@ -382,15 +382,18 @@
                }
    }
        
-       void get_qt_options(const VideoSource & vs, ImageRef & size, bool & 
showsettings){
+       void get_qt_options(const VideoSource & vs, ImageRef & size, bool & 
showsettings, bool & verbose){
                size = ImageRef(640, 480);
                showsettings = false;
+               verbose = false;
                for (VideoSource::option_list::const_iterator 
it=vs.options.begin(); it != vs.options.end(); ++it) {
                                if (it->first == "size")
                                        size = parseImageRef(it->second, true);
-                               else if(it->first == "showsettings") {
-                                       showsettings = atoi(it->second.c_str());
-                       } else
+                       else if(it->first == "showsettings")
+                               showsettings = parseBoolFlag(it->second);
+                       else if(it->first == "verbose")
+                               verbose = parseBoolFlag(it->second);
+                       else
                                throw VideoSourceException("invalid option for 
'qt' protocol: "+it->first+"\n\t valid options: size, showsettings");
                }
        }

Index: cvd_src/OSX/qtbuffer.cpp
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd_src/OSX/qtbuffer.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- cvd_src/OSX/qtbuffer.cpp    3 Apr 2009 16:16:37 -0000       1.5
+++ cvd_src/OSX/qtbuffer.cpp    12 Nov 2009 16:26:52 -0000      1.6
@@ -23,7 +23,6 @@
  *  libcvd
  *
  *  FIXME:
- *  - check if carbon events and WaitForNextEvent are necessary, or if we can 
just drive SGIdle directly
  *  - check how to set video input properties such as brightness, saturation, 
etc
  *  - support other video formats (potentially from other hardware) as well
  */
@@ -86,7 +85,7 @@
        return err;
 }
 
-RawQT::RawQT(const ImageRef & size, unsigned int /* mode */, unsigned int /* 
num */, bool showSettingsDialog) : pimpl(NULL) 
+RawQT::RawQT(const ImageRef & size, unsigned int /* mode */, unsigned int num, 
bool showSettingsDialog, bool verbose) : pimpl(NULL) 
 {
        if( !RawQTPimpl::isInitialized ){
                EnterMovies();
@@ -139,21 +138,42 @@
          }
 
     try {
+               SGDeviceList devices;
+               err = SGGetChannelDeviceList(pimpl->chanVideo, 0, &devices);
+               if(err != noErr)
+                       throw 
Exceptions::QTBUFFER::DeviceOpen("SGGetChannelDeviceList returned an error");
+        
+               if(verbose)
+                       cout << "QTBuffer available devices:\n";
+               vector<int> allowedDevices;
+               for(int i = 0; i < (*devices)->count; ++i){
+                       if((*devices)->entry[i].flags == 0){
+                               allowedDevices.push_back(i);
+                               if(verbose)
+                                       cout << "\t" << 
(*devices)->entry[i].name << endl;
+                       }
+               }
+               if(num >= allowedDevices.size())
+                       throw Exceptions::QTBUFFER::DeviceOpen("Given device 
number is not available");
+    
+               err = SGSetChannelDevice(pimpl->chanVideo, 
(*devices)->entry[allowedDevices[num]].name);
+               if(err != noErr)
+                       throw 
Exceptions::QTBUFFER::DeviceOpen("SGSetChannelDevice returned an error");
+               SGDisposeDeviceList(pimpl->chanVideo, devices);
+
            err = SGSetChannelBounds(pimpl->chanVideo, &pimpl->bounds);
-           if (err != noErr) {
+               if (err != noErr)
                        throw 
Exceptions::QTBUFFER::DeviceOpen("SGSetChannelBounds returned error");
-               }
+
                // set usage for new video channel to avoid playthrough
                // note we don't set seqGrabPlayDuringRecord
                err = SGSetChannelUsage(pimpl->chanVideo, seqGrabRecord);
-               if( err != noErr) {
+               if( err != noErr)
                        throw 
CVD::Exceptions::QTBUFFER::DeviceOpen("SGSetChannelUsage returned error");
-               }
 
                err = SGSetDataProc(pimpl->seqGrab, 
NewSGDataUPP(RawQTPimpl::GrabDataProc), (long)pimpl);
-               if(err != noErr){
+               if(err != noErr)
                        throw Exceptions::QTBUFFER::DeviceOpen("SGSetDataProc 
returned error");
-               }
                
                // lights...camera...
                err = SGPrepare(pimpl->seqGrab, false, true);   
@@ -163,15 +183,14 @@
                // What format are the images?
                ImageDescriptionHandle imageDesc = 
(ImageDescriptionHandle)NewHandle(0);
                err = SGGetChannelSampleDescription(pimpl->chanVideo, 
(Handle)imageDesc);
-               if(err != noErr){
+               if(err != noErr)
                  throw 
Exceptions::QTBUFFER::DeviceOpen("SGGetChannelSampleDescription returned 
error");
-               }
+
                // Convert pascal string to stl string..
                for(char i=1; i<=(**imageDesc).name[0]; i++)
                        frame_format_string = frame_format_string + (char) 
(**imageDesc).name[i];
-
-
-               
+               if(verbose)
+                       cout << "QTBuffer video format is " << 
frame_format_string << "\t" << (**imageDesc).width << "," << 
(**imageDesc).height << "," << (**imageDesc).depth << endl;
        }
        catch(Exceptions::QTBUFFER::DeviceOpen){
                // clean up on failure

Index: cvd_src/OSX/videosource_noqtbuffer.cc
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd_src/OSX/videosource_noqtbuffer.cc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- cvd_src/OSX/videosource_noqtbuffer.cc       26 Oct 2009 15:44:58 -0000      
1.1
+++ cvd_src/OSX/videosource_noqtbuffer.cc       12 Nov 2009 16:26:52 -0000      
1.2
@@ -11,4 +11,9 @@
        {
                throw VideoSourceException("QTBuffer is not compiled in to 
libcvd.");
        }
+       
+       template <> VideoBuffer<Rgb<byte> > * makeQTBuffer( const ImageRef & 
size, int input, bool showsettings, bool verbose)
+       {
+               throw VideoSourceException("QTBuffer is not compiled in to 
libcvd.");
+       }
 }

Index: cvd_src/OSX/videosource_qtbuffer.cc
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd_src/OSX/videosource_qtbuffer.cc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- cvd_src/OSX/videosource_qtbuffer.cc 26 Oct 2009 15:44:58 -0000      1.1
+++ cvd_src/OSX/videosource_qtbuffer.cc 12 Nov 2009 16:26:52 -0000      1.2
@@ -2,13 +2,19 @@
 #include <cvd/OSX/qtbuffer.h>
 namespace CVD{
 
-       template <> VideoBuffer<vuy422> * makeQTBuffer( const ImageRef & size, 
int input, bool showsettings)
+       template <> VideoBuffer<vuy422> * makeQTBuffer( const ImageRef & size, 
int input, bool showsettings, bool verbose)
        {
-               return new CVD::QTBuffer<vuy422>(size, input, showsettings);
+               return new CVD::QTBuffer<vuy422>(size, input, showsettings, 
verbose);
        }
 
-       template <> VideoBuffer<yuv422> * makeQTBuffer( const ImageRef & size, 
int input, bool showsettings)
+       template <> VideoBuffer<yuv422> * makeQTBuffer( const ImageRef & size, 
int input, bool showsettings, bool verbose)
        {
-               return new CVD::QTBuffer<yuv422>(size, input, showsettings);
+               return new CVD::QTBuffer<yuv422>(size, input, showsettings, 
verbose);
        }
+
+       template <> VideoBuffer<Rgb<byte> > * makeQTBuffer( const ImageRef & 
size, int input, bool showsettings, bool verbose)
+       {
+               return new CVD::QTBuffer<Rgb<byte> >(size, input, showsettings, 
verbose);
+       }
+
 }

Index: progs/calibrate.cxx
===================================================================
RCS file: /cvsroot/libcvd/libcvd/progs/calibrate.cxx,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- progs/calibrate.cxx 23 Jul 2009 15:39:21 -0000      1.18
+++ progs/calibrate.cxx 12 Nov 2009 16:26:52 -0000      1.19
@@ -19,6 +19,8 @@
 #include <cvd/timer.h>
 #include <cvd/colourspaces.h>
 #include <cvd/colourspace_convert.h>
+#include <cvd/colourspacebuffer.h>
+#include <cvd/videosource.h>
 
 using namespace std;
 using namespace TooN;
@@ -27,17 +29,12 @@
 #include <X11/keysym.h>
 #include <X11/Xlib.h>
 
-#ifdef CVD_HAVE_QTBUFFER
-typedef vuy422 CAMERA_PIXEL;
-#else
 typedef byte CAMERA_PIXEL;
-#endif
-
 VideoBuffer<CAMERA_PIXEL>* videoBuffer=0;
 
 // global configuration variables, can be set via command line options
 #ifdef CVD_HAVE_QTBUFFER
-string videoDevice = "qt://0";
+string videoDevice = "colourspace:[from=yuv422]//qt://0";
 #else
 string videoDevice = "v4l2:///dev/video0";
 #endif




reply via email to

[Prev in Thread] Current Thread [Next in Thread]