CapturePluginFile.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ALVAR, A Library for Virtual and Augmented Reality.
3  *
4  * Copyright 2007-2012 VTT Technical Research Centre of Finland
5  *
6  * Contact: VTT Augmented Reality Team <alvar.info@vtt.fi>
7  * <http://www.vtt.fi/multimedia/alvar.html>
8  *
9  * ALVAR is free software; you can redistribute it and/or modify it under the
10  * terms of the GNU Lesser General Public License as published by the Free
11  * Software Foundation; either version 2.1 of the License, or (at your option)
12  * any later version.
13  *
14  * This library is distributed in the hope that it will be useful, but WITHOUT
15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
17  * for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with ALVAR; if not, see
21  * <http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html>.
22  */
23 
24 #include "CapturePluginFile.h"
25 
26 namespace alvar {
27 namespace plugins {
28 
30  : Capture(captureDevice)
31  , mVideoCapture()
32  , mMatrix()
33  , mImage()
34 {
35 }
36 
38 {
39  stop();
40 }
41 
43 {
44  if (isCapturing()) {
45  return isCapturing();
46  }
47 
48  mVideoCapture.open(captureDevice().id().c_str());
49  if (mVideoCapture.isOpened()) {
50  mXResolution = (int)mVideoCapture.get(CV_CAP_PROP_FRAME_WIDTH);
51  mYResolution = (int)mVideoCapture.get(CV_CAP_PROP_FRAME_HEIGHT);
52  mIsCapturing = true;
53  }
54 
55  return isCapturing();
56 }
57 
59 {
60  if (isCapturing()) {
61  mVideoCapture.release();
62  mIsCapturing = false;
63  }
64 }
65 
67 {
68  if (!isCapturing()) {
69  return NULL;
70  }
71 
72  if (!mVideoCapture.grab()) {
73  // try to restart the capturing when end of file is reached
74  mVideoCapture.release();
75  mVideoCapture.open(captureDevice().id().c_str());
76  if (!mVideoCapture.isOpened()) {
77  mIsCapturing = false;
78  return NULL;
79  }
80  if (!mVideoCapture.grab()) {
81  return NULL;
82  }
83  }
84  mVideoCapture.retrieve(mMatrix);
85  mImage = mMatrix;
86  return &mImage;
87 }
88 
90 {
91  // TODO: implement this method
92  return false;
93 }
94 
96 {
97  return "CaptureFile";
98 }
99 
101 {
102  return false;
103 }
104 
105 CapturePluginFile::CapturePluginFile(const std::string &captureType)
106  : CapturePlugin(captureType)
107 {
108 }
109 
111 {
112 }
113 
115 {
116  CaptureDeviceVector devices;
117  return devices;
118 }
119 
121 {
122  return new CaptureFile(captureDevice);
123 }
124 
125 void registerPlugin(const std::string &captureType, alvar::CapturePlugin *&capturePlugin)
126 {
127  capturePlugin = new CapturePluginFile(captureType);
128 }
129 
130 } // namespace plugins
131 } // namespace alvar
Main ALVAR namespace.
Definition: Alvar.h:174
std::string SerializeId()
The identification of the class for serialization.
CapturePluginFile(const std::string &captureType)
Constructor.
CaptureDevice captureDevice()
The camera information associated to this capture object.
Definition: Capture.h:70
unsigned long mXResolution
Definition: Capture.h:181
bool Serialize(Serialization *serialization)
Performs serialization of the class members and configuration.
This file implements a capture plugin based on File.
CaptureDevice holder for camera information.
Definition: CaptureDevice.h:44
void registerPlugin(const std::string &captureType, alvar::CapturePlugin *&capturePlugin)
CapturePlugin interface that plugins must implement.
Definition: CapturePlugin.h:44
bool start()
Starts the camera capture.
Capture * createCapture(const CaptureDevice captureDevice)
Create Capture class. Transfers onwership to the caller.
void stop()
Stops the camera capture.
bool isCapturing()
Test if the camera was properly initialized.
Definition: Capture.h:85
CaptureDeviceVector enumerateDevices()
Enumerate capture devices currently available.
Capture interface that plugins must implement.
Definition: Capture.h:46
IplImage * captureImage()
Capture one image from the camera.
Class for serializing class content to/from file or std::iostream.
Definition: Util.h:352
Implementation of Capture interface for File plugin.
bool mIsCapturing
Definition: Capture.h:183
std::vector< CaptureDevice > CaptureDeviceVector
Vector of CaptureDevices.
Definition: CapturePlugin.h:60
bool showSettingsDialog()
Show the settings dialog of the camera.
unsigned long mYResolution
Definition: Capture.h:182
CaptureFile(const CaptureDevice captureDevice)
Constructor.


ar_track_alvar
Author(s): Scott Niekum
autogenerated on Mon Jun 10 2019 12:47:04