My Project
Capture.h
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 #ifndef CAPTURE_H
25 #define CAPTURE_H
26 
33 #include "Alvar.h"
34 #include "CaptureDevice.h"
35 #include "Util.h"
36 
37 namespace alvar {
38 
46 class ALVAR_EXPORT Capture
47 {
48 public:
54  Capture(const CaptureDevice captureDevice)
55  : mCaptureDevice(captureDevice), mXResolution(0), mYResolution(0), mIsCapturing(false)
56  {
57  }
58 
62  virtual ~Capture()
63  {
64  }
65 
71  {
72  return mCaptureDevice;
73  }
74 
78  unsigned long
80  {
81  return mXResolution;
82  }
83 
87  unsigned long
89  {
90  return mYResolution;
91  }
92 
96  bool
98  {
99  return mIsCapturing;
100  }
101 
108  virtual void
109  setResolution(const unsigned long xResolution, const unsigned long yResolution)
110  {
111  }
112 
118  virtual bool start() = 0;
119 
123  virtual void stop() = 0;
124 
132  virtual cv::Mat captureImage() = 0;
133 
140  virtual bool
141  saveSettings(std::string filename)
142  {
143  if (!isCapturing()) {
144  return false;
145  }
146 
147  Serialization serialization(filename);
148  try {
149  serialization << (*this);
150  } catch (...) {
151  return false;
152  }
153  return true;
154  }
155 
162  virtual bool
163  loadSettings(std::string filename)
164  {
165  if (!isCapturing()) {
166  return false;
167  }
168 
169  Serialization serialization(filename);
170  try {
171  serialization >> (*this);
172  } catch (...) {
173  return false;
174  }
175  return true;
176  }
177 
182  virtual bool showSettingsDialog() = 0;
183 
187  virtual std::string SerializeId() = 0;
188 
195  virtual bool Serialize(Serialization *serialization) = 0;
196 
197 protected:
198  CaptureDevice mCaptureDevice;
199  unsigned long mXResolution;
200  unsigned long mYResolution;
201  bool mIsCapturing;
202 };
203 
204 } // namespace alvar
205 
206 #endif
This file defines library export definitions, version numbers and build information.
This file implements a capture device to hold camera information.
This file implements generic utility functions and a serialization interface.
CaptureDevice holder for camera information.
Definition: CaptureDevice.h:45
Capture interface that plugins must implement.
Definition: Capture.h:47
virtual void stop()=0
Stops the camera capture.
virtual ~Capture()
Destructor.
Definition: Capture.h:62
Capture(const CaptureDevice captureDevice)
Constructor.
Definition: Capture.h:54
virtual bool loadSettings(std::string filename)
Load camera settings from a file.
Definition: Capture.h:163
virtual std::string SerializeId()=0
The identification of the class for serialization.
virtual void setResolution(const unsigned long xResolution, const unsigned long yResolution)
Set the resolution.
Definition: Capture.h:109
virtual bool showSettingsDialog()=0
Show the settings dialog of the camera.
virtual bool Serialize(Serialization *serialization)=0
Performs serialization of the class members and configuration.
unsigned long xResolution()
The resolution along the x axis (horizontal).
Definition: Capture.h:79
CaptureDevice captureDevice()
The camera information associated to this capture object.
Definition: Capture.h:70
virtual bool start()=0
Starts the camera capture.
bool isCapturing()
Test if the camera was properly initialized.
Definition: Capture.h:97
virtual cv::Mat captureImage()=0
Capture one image from the camera.
unsigned long yResolution()
The resolution along the y axis (vertical).
Definition: Capture.h:88
virtual bool saveSettings(std::string filename)
Save camera settings to a file.
Definition: Capture.h:141
Class for serializing class content to/from file or std::iostream.
Definition: Util.h:371
Main ALVAR namespace.
Definition: Alvar.h:174