Panda3D
webcamVideoOpenCV.cxx
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file webcamVideoOpenCV.cxx
10  * @author drose
11  * @date 2010-10-20
12  */
13 
14 #include "webcamVideoOpenCV.h"
15 
16 #ifdef HAVE_OPENCV
17 
19 #include "configVariableInt.h"
20 
21 TypeHandle WebcamVideoOpenCV::_type_handle;
22 
23 /**
24  * Finds all OpenCV webcams and adds them to the global list _all_webcams.
25  */
26 void
27 find_all_webcams_opencv() {
28  // OpenCV doesn't really provide a way to enumerate cameras. We ask the
29  // user to do this via a config variable.
30  static ConfigVariableInt wemcam_opencv_camera_index
31  ("webcam-opencv-camera-index", "0",
32  PRC_DESC("Specify the space-separated list of integer camera index "
33  "numbers that are assumed to be available via OpenCV to the "
34  "WebcamVideo interface. The default camera index is 0. "
35  "Specify empty string if there are no available cameras."));
36  for (size_t i = 0; i < wemcam_opencv_camera_index.get_num_words(); ++i) {
37  PT(WebcamVideo) wc = new WebcamVideoOpenCV(wemcam_opencv_camera_index[i]);
38  WebcamVideoOpenCV::_all_webcams.push_back(wc);
39  }
40 }
41 
42 /**
43  *
44  */
45 WebcamVideoOpenCV::
46 WebcamVideoOpenCV(int camera_index) :
47  _camera_index(camera_index)
48 {
49  std::ostringstream strm;
50  strm << "OpenCV webcam " << _camera_index;
51  set_name(strm.str());
52 }
53 
54 /**
55  * Open this video, returning a MovieVideoCursor.
56  */
57 PT(MovieVideoCursor) WebcamVideoOpenCV::
58 open() {
59  return new WebcamVideoCursorOpenCV(this);
60 }
61 
62 #endif
Allows you to open a webcam or other video capture device as a video stream.
Definition: webcamVideo.h:23
A MovieVideo is actually any source that provides a sequence of video frames.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is a convenience class to specialize ConfigVariable as an integer type.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81