OSVR-Core
ImageProcessingThread.h
Go to the documentation of this file.
1 
11 // Copyright 2016 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_ImageProcessingThread_h_GUID_307E6652_D346_43B4_291A_5BAAEF4BA909
26 #define INCLUDED_ImageProcessingThread_h_GUID_307E6652_D346_43B4_291A_5BAAEF4BA909
27 
28 // Internal Includes
29 #include <CameraParameters.h>
30 
31 // Library/third-party includes
32 #include <opencv2/core/core.hpp>
33 
34 // Standard includes
35 #include <condition_variable>
36 #include <cstdint>
37 #include <fstream>
38 #include <iosfwd>
39 #include <mutex>
40 
41 namespace osvr {
42 namespace vbtracker {
43  class TrackerThread;
44  class TrackingSystem;
45  class ImageSource;
46 
48  public:
49  explicit ImageProcessingThread(TrackingSystem &trackingSystem,
50  ImageSource &cam,
51  TrackerThread &trackerThread,
52  CameraParameters const &camParams,
53  std::int32_t cameraUsecOffset);
54 
57 
59  void signalDoFrame();
61  void signalExit();
62 
64  void threadAction();
65 
67  bool exiting() const { return exiting_; }
68 
69  private:
71  std::ostream &msg() const;
73  std::ostream &warn() const;
75  void doFrame();
76 
77  TrackingSystem &trackingSystem_;
78  ImageSource &cam_;
79  TrackerThread &trackerThreadObj_;
80  const CameraParameters camParams_;
81  const std::int32_t cameraUsecOffset_;
82 
84  bool logBlobs_ = false;
85  std::ofstream blobFile_;
86 
87  enum class NextOp { Waiting, DoFrame, Exit };
88 
89  std::mutex stateMutex_;
90  std::condition_variable stateCondVar_;
91  NextOp next_ = NextOp::Waiting;
92 
93  cv::Mat frame_;
94  cv::Mat gray_;
95 
96  bool exiting_ = false;
97  };
98 
99 } // namespace vbtracker
100 } // namespace osvr
101 
102 #endif // INCLUDED_ImageProcessingThread_h_GUID_307E6652_D346_43B4_291A_5BAAEF4BA909
Definition: ImageProcessingThread.h:47
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
void threadAction()
Entry point for the thread dedicated to this object.
Definition: ImageProcessingThread.cpp:75
Definition: TrackerThread.h:77
void signalExit()
called by TrackerThread
Definition: ImageProcessingThread.cpp:67
Definition: CameraParameters.h:41
Definition: TrackingSystem.h:54
ImageProcessingThread & operator=(ImageProcessingThread &)=delete
non-assignable.
void signalDoFrame()
called by TrackerThread
Definition: ImageProcessingThread.cpp:59
Uniform interface for the various normal to strange image sources for the tracking algorithm...
Definition: ImageSource.h:42
bool exiting() const
Did we get the exit message?
Definition: ImageProcessingThread.h:67