OSVR-Core
ImageSource.h
Go to the documentation of this file.
1 
11 // Copyright 2015 Sensics, Inc.
12 //
13 // Licensed under the Apache License, Version 2.0 (the "License");
14 // you may not use this file except in compliance with the License.
15 // You may obtain a copy of the License at
16 //
17 // http://www.apache.org/licenses/LICENSE-2.0
18 //
19 // Unless required by applicable law or agreed to in writing, software
20 // distributed under the License is distributed on an "AS IS" BASIS,
21 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 // See the License for the specific language governing permissions and
23 // limitations under the License.
24 
25 #ifndef INCLUDED_ImageSource_h_GUID_C1B68116_0322_4DBD_2360_EF4E6A81D5F4
26 #define INCLUDED_ImageSource_h_GUID_C1B68116_0322_4DBD_2360_EF4E6A81D5F4
27 
28 // Internal Includes
29 // - none
30 
31 // Library/third-party includes
32 #include <opencv2/core/core.hpp>
33 #include <osvr/Util/TimeValue.h>
34 
35 // Standard includes
36 #include <memory>
37 
38 namespace osvr {
39 namespace vbtracker {
42  class ImageSource {
43  public:
45  virtual ~ImageSource();
46 
48  virtual bool ok() const = 0;
49 
56  virtual bool grab() = 0;
57 
59  virtual void retrieve(cv::Mat &color, cv::Mat &gray,
60  osvr::util::time::TimeValue &timestamp);
61 
64  inline void retrieve(cv::Mat &color, cv::Mat &gray) {
66  retrieve(color, gray, ts);
67  }
68 
70  virtual cv::Size resolution() const = 0;
71 
75  virtual void retrieveColor(cv::Mat &color,
76  osvr::util::time::TimeValue &timestamp) = 0;
79  inline void retrieveColor(cv::Mat &color) {
81  retrieveColor(color, ts);
82  }
83 
84  protected:
85  ImageSource() = default;
86  };
87 
88  using ImageSourcePtr = std::unique_ptr<ImageSource>;
89 } // namespace vbtracker
90 } // namespace osvr
91 #endif // INCLUDED_ImageSource_h_GUID_C1B68116_0322_4DBD_2360_EF4E6A81D5F4
virtual bool ok() const =0
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
void retrieve(cv::Mat &color, cv::Mat &gray)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ImageSource.h:64
void retrieveColor(cv::Mat &color)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ImageSource.h:79
virtual bool grab()=0
Trigger camera capture.
Header providing a C++ wrapper around TimeValueC.h.
virtual ~ImageSource()
Destructor.
Definition: ImageSource.cpp:36
Uniform interface for the various normal to strange image sources for the tracking algorithm...
Definition: ImageSource.h:42
virtual void retrieve(cv::Mat &color, cv::Mat &gray, osvr::util::time::TimeValue &timestamp)
Call after grab() to get the actual image data.
Definition: ImageSource.cpp:37
virtual void retrieveColor(cv::Mat &color, osvr::util::time::TimeValue &timestamp)=0
For those devices that naturally read a non-corrupt color image, overriding just this method will let...
virtual cv::Size resolution() const =0
Get resolution of the images from this source.
Standardized, portable parallel to struct timeval for representing both absolute times and time inter...
Definition: TimeValueC.h:81