WPILibC++  unspecified
CvSinkImpl.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2016-2018 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 <memory>
13 #include <thread>
14 #include <vector>
15 
16 #include <wpi/NetworkAcceptor.h>
17 #include <wpi/NetworkStream.h>
18 #include <wpi/SmallVector.h>
19 #include <wpi/StringRef.h>
20 #include <wpi/raw_istream.h>
21 #include <wpi/raw_ostream.h>
22 #include <wpi/raw_socket_ostream.h>
23 
24 #include "SinkImpl.h"
25 
26 namespace cs {
27 
28 class SourceImpl;
29 
30 class CvSinkImpl : public SinkImpl {
31  public:
32  explicit CvSinkImpl(wpi::StringRef name);
34  std::function<void(uint64_t time)> processFrame);
35  ~CvSinkImpl() override;
36 
37  void Stop();
38 
39  uint64_t GrabFrame(cv::Mat& image);
40  uint64_t GrabFrame(cv::Mat& image, double timeout);
41 
42  private:
43  void ThreadMain();
44 
45  std::atomic_bool m_active; // set to false to terminate threads
46  std::thread m_thread;
47  std::function<void(uint64_t time)> m_processFrame;
48 };
49 
50 } // namespace cs
51 
52 #endif // CSCORE_CVSINKIMPL_H_
Definition: CvSourceImpl.h:19
Definition: SinkImpl.h:23
Definition: CvSinkImpl.h:30
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49