Panda3D
webcamVideo.cxx
1 // Filename: webcamVideo.cxx
2 // Created by: jyelon (01Nov2007)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "webcamVideo.h"
16 #include "pandabase.h"
17 #include "movieVideoCursor.h"
18 
19 pvector<PT(WebcamVideo)> WebcamVideo::_all_webcams;
20 TypeHandle WebcamVideo::_type_handle;
21 
22 
23 ////////////////////////////////////////////////////////////////////
24 // Function: WebcamVideo::Destructor
25 // Access: Published, Virtual
26 // Description:
27 ////////////////////////////////////////////////////////////////////
28 WebcamVideo::
29 ~WebcamVideo() {
30 }
31 
32 ////////////////////////////////////////////////////////////////////
33 // Function: WebcamVideo::find_all_webcams
34 // Access: Public
35 // Description: Scans the hardware for webcams, and pushes them
36 // onto the global list of all webcams.
37 //
38 // There are several implementations of WebcamVideo,
39 // including one based on DirectShow, one based on
40 // Video4Linux, and so forth. These implementations
41 // are contained in one C++ file each, and they export
42 // nothing at all except a single "find_all" function.
43 // Otherwise, they can only be accessed through the
44 // virtual methods of the WebcamVideo objects they
45 // create.
46 ////////////////////////////////////////////////////////////////////
47 void WebcamVideo::
49  static bool initialized = false;
50  if (initialized) return;
51  initialized = true;
52 
53 #ifdef HAVE_DIRECTCAM
54  extern void find_all_webcams_ds();
55  find_all_webcams_ds();
56 #endif
57 
58 #ifdef HAVE_VIDEO4LINUX
59  extern void find_all_webcams_v4l();
60  find_all_webcams_v4l();
61 #endif
62 
63 #if defined(HAVE_OPENCV) && !defined(HAVE_DIRECTCAM) && !defined(HAVE_VIDEO4LINUX)
64  extern void find_all_webcams_opencv();
65  find_all_webcams_opencv();
66 #endif
67 }
68 
69 ////////////////////////////////////////////////////////////////////
70 // Function: WebcamVideo::get_num_options
71 // Access: Public, Static
72 // Description: Returns the number of webcam options. An "option"
73 // consists of a device plus a set of configuration
74 // parameters. For example, "Creative Webcam Live at
75 // 640x480, 30 fps" is an option.
76 ////////////////////////////////////////////////////////////////////
77 int WebcamVideo::
80  return _all_webcams.size();
81 }
82 
83 ////////////////////////////////////////////////////////////////////
84 // Function: WebcamVideo::get_option
85 // Access: Public, Static
86 // Description: Returns the nth webcam option.
87 ////////////////////////////////////////////////////////////////////
88 PT(WebcamVideo) WebcamVideo::
89 get_option(int n) {
91  nassertr((n >= 0) && (n < (int)_all_webcams.size()), NULL);
92  return _all_webcams[n];
93 }
Allows you to open a webcam or other video capture device as a video stream.
Definition: webcamVideo.h:25
static int get_num_options()
Returns the number of webcam options.
Definition: webcamVideo.cxx:78
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
static void find_all_webcams()
Scans the hardware for webcams, and pushes them onto the global list of all webcams.
Definition: webcamVideo.cxx:48