WPILibC++  2018.4.1-20180728210220-1136-g75a6720
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
CameraServer.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2014-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 #pragma once
9 
10 #include <stdint.h>
11 
12 #include <memory>
13 #include <string>
14 
15 #include <wpi/ArrayRef.h>
16 #include <wpi/StringRef.h>
17 
18 #include "cscore.h"
19 
20 namespace frc {
21 
27 class CameraServer {
28  public:
29  static constexpr uint16_t kBasePort = 1181;
30  static constexpr int kSize640x480 = 0;
31  static constexpr int kSize320x240 = 1;
32  static constexpr int kSize160x120 = 2;
33 
37  static CameraServer* GetInstance();
38 
39 #ifdef __linux__
40  // USBCamera does not work on anything except Linux.
53 
63 
71 
79 #endif
80 
87  void StartAutomaticCapture(const cs::VideoSource& camera);
88 
97 
105  cs::AxisCamera AddAxisCamera(const char* host);
106 
114  cs::AxisCamera AddAxisCamera(const std::string& host);
115 
124 
132  template <typename T>
133  cs::AxisCamera AddAxisCamera(std::initializer_list<T> hosts);
134 
142 
149  cs::AxisCamera AddAxisCamera(wpi::StringRef name, const char* host);
150 
157  cs::AxisCamera AddAxisCamera(wpi::StringRef name, const std::string& host);
158 
167 
174  template <typename T>
176  std::initializer_list<T> hosts);
177 
186 
193  cs::CvSink GetVideo(const cs::VideoSource& camera);
194 
202 
211  cs::CvSource PutVideo(wpi::StringRef name, int width, int height);
212 
219 
225  cs::MjpegServer AddServer(wpi::StringRef name, int port);
226 
232  void AddServer(const cs::VideoSink& server);
233 
239  void RemoveServer(wpi::StringRef name);
240 
248 
255 
261  void AddCamera(const cs::VideoSource& camera);
262 
268  void RemoveCamera(wpi::StringRef name);
269 
279  void SetSize(int size);
280 
281  private:
282  CameraServer();
283  ~CameraServer();
284 
285  struct Impl;
286  std::unique_ptr<Impl> m_impl;
287 };
288 
289 } // namespace frc
290 
291 #include "cameraserver/CameraServer.inc"
void RemoveCamera(wpi::StringRef name)
Removes a camera by name.
Definition: SPIAccelerometerSim.h:18
void StartAutomaticCapture(const cs::VideoSource &camera)
Start automatically capturing images to send to the dashboard from an existing camera.
cs::AxisCamera AddAxisCamera(wpi::StringRef host)
Adds an Axis IP camera.
void AddCamera(const cs::VideoSource &camera)
Adds an already created camera.
A source for video that provides a sequence of frames.
Definition: cscore_oo.h:97
A sink for video that accepts a sequence of frames.
Definition: cscore_oo.h:648
void RemoveServer(wpi::StringRef name)
Removes a server by name.
cs::VideoSink GetServer()
Get server for the primary camera feed.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: ArrayRef.h:41
void SetSize(int size)
Sets the size of the image to use.
A source that represents a USB camera.
Definition: cscore_oo.h:330
A source for user code to provide OpenCV images as video frames.
Definition: cscore_oo.h:518
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
static CameraServer * GetInstance()
Get the CameraServer instance.
cs::CvSink GetVideo()
Get OpenCV access to the primary camera feed.
Singleton class for creating and keeping camera servers.
Definition: CameraServer.h:27
cs::MjpegServer AddServer(wpi::StringRef name)
Adds a MJPEG server at the next available port.
cs::CvSource PutVideo(wpi::StringRef name, int width, int height)
Create a MJPEG stream with OpenCV input.
A sink that acts as a MJPEG-over-HTTP network server.
Definition: cscore_oo.h:755
A source that represents an Axis IP camera.
Definition: cscore_oo.h:461
A sink for user code to accept video frames as OpenCV images.
Definition: cscore_oo.h:835