WPILibC++  unspecified
CvSinkImpl.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #ifndef CSCORE_CVSINKIMPL_H_
9 #define CSCORE_CVSINKIMPL_H_
10 
11 #include <atomic>
12 #include <condition_variable>
13 #include <memory>
14 #include <mutex>
15 #include <thread>
16 #include <vector>
17 
18 #include <llvm/SmallVector.h>
19 #include <llvm/StringRef.h>
20 #include <llvm/raw_ostream.h>
21 #include <support/raw_istream.h>
22 #include <support/raw_socket_ostream.h>
23 #include <tcpsockets/NetworkAcceptor.h>
24 #include <tcpsockets/NetworkStream.h>
25 
26 #include "SinkImpl.h"
27 
28 namespace cs {
29 
30 class SourceImpl;
31 
32 class CvSinkImpl : public SinkImpl {
33  public:
34  explicit CvSinkImpl(llvm::StringRef name);
36  std::function<void(uint64_t time)> processFrame);
37  ~CvSinkImpl() override;
38 
39  void Stop();
40 
41  uint64_t GrabFrame(cv::Mat& image);
42  uint64_t GrabFrame(cv::Mat& image, double timeout);
43 
44  private:
45  void ThreadMain();
46 
47  std::atomic_bool m_active; // set to false to terminate threads
48  std::thread m_thread;
49  std::function<void(uint64_t time)> m_processFrame;
50 };
51 
52 } // namespace cs
53 
54 #endif // CSCORE_CVSINKIMPL_H_
Definition: SinkImpl.h:19
Definition: SinkImpl.h:23
Definition: CvSinkImpl.h:32
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:42