Panda3D
 All Classes Functions Variables Enumerations
webcamVideoOpenCV.cxx
00001 // Filename: webcamVideoOpenCV.cxx
00002 // Created by:  drose (20Oct10)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #include "webcamVideoOpenCV.h"
00016 
00017 #ifdef HAVE_OPENCV
00018 
00019 #include "webcamVideoCursorOpenCV.h"
00020 #include "configVariableInt.h"
00021 
00022 TypeHandle WebcamVideoOpenCV::_type_handle;
00023 
00024 ////////////////////////////////////////////////////////////////////
00025 //     Function: find_all_webcams_opencv
00026 //       Access: Public, Static
00027 //  Description: Finds all OpenCV webcams and adds them to the global
00028 //               list _all_webcams.
00029 ////////////////////////////////////////////////////////////////////
00030 void
00031 find_all_webcams_opencv() {
00032   // OpenCV doesn't really provide a way to enumerate cameras.  We ask
00033   // the user to do this via a config variable.
00034   static ConfigVariableInt wemcam_opencv_camera_index
00035     ("webcam-opencv-camera-index", "0",
00036      PRC_DESC("Specify the space-separated list of integer camera index "
00037               "numbers that are assumed to be available via OpenCV to the "
00038               "WebcamVideo interface.  The default camera index is 0.  "
00039               "Specify empty string if there are no available cameras."));
00040   for (int i = 0; i < wemcam_opencv_camera_index.get_num_words(); ++i) {
00041     PT(WebcamVideo) wc = new WebcamVideoOpenCV(wemcam_opencv_camera_index[i]);
00042     WebcamVideoOpenCV::_all_webcams.push_back(wc);
00043   }
00044 }
00045 
00046 ////////////////////////////////////////////////////////////////////
00047 //     Function: WebcamVideoOpenCV::Constructor
00048 //       Access: Published, Virtual
00049 //  Description: 
00050 ////////////////////////////////////////////////////////////////////
00051 WebcamVideoOpenCV::
00052 WebcamVideoOpenCV(int camera_index) : 
00053   _camera_index(camera_index) 
00054 {
00055   ostringstream strm;
00056   strm << "OpenCV webcam " << _camera_index;
00057   set_name(strm.str());
00058 }
00059 
00060 ////////////////////////////////////////////////////////////////////
00061 //     Function: WebcamVideoOpenCV::open
00062 //       Access: Published, Virtual
00063 //  Description: Open this video, returning a MovieVideoCursor.
00064 ////////////////////////////////////////////////////////////////////
00065 PT(MovieVideoCursor) WebcamVideoOpenCV::
00066 open() {
00067   return new WebcamVideoCursorOpenCV(this);
00068 }
00069 
00070 #endif
 All Classes Functions Variables Enumerations