WPILibC++  2019.1.1-beta-4-28-g80f87ff
 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/Twine.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 
51 
61 
68  cs::UsbCamera StartAutomaticCapture(const wpi::Twine& name, int dev);
69 
77  const wpi::Twine& path);
78 
85  void StartAutomaticCapture(const cs::VideoSource& camera);
86 
95 
103  cs::AxisCamera AddAxisCamera(const char* host);
104 
112  cs::AxisCamera AddAxisCamera(const std::string& host);
113 
122 
130  template <typename T>
131  cs::AxisCamera AddAxisCamera(std::initializer_list<T> hosts);
132 
139  cs::AxisCamera AddAxisCamera(const wpi::Twine& name, const wpi::Twine& host);
140 
147  cs::AxisCamera AddAxisCamera(const wpi::Twine& name, const char* host);
148 
155  cs::AxisCamera AddAxisCamera(const wpi::Twine& name, const std::string& host);
156 
165 
172  template <typename T>
174  std::initializer_list<T> hosts);
175 
184 
191  cs::CvSink GetVideo(const cs::VideoSource& camera);
192 
199  cs::CvSink GetVideo(const wpi::Twine& name);
200 
209  cs::CvSource PutVideo(const wpi::Twine& name, int width, int height);
210 
216  cs::MjpegServer AddServer(const wpi::Twine& name);
217 
223  cs::MjpegServer AddServer(const wpi::Twine& name, int port);
224 
230  void AddServer(const cs::VideoSink& server);
231 
237  void RemoveServer(const wpi::Twine& name);
238 
246 
252  cs::VideoSink GetServer(const wpi::Twine& name);
253 
259  void AddCamera(const cs::VideoSource& camera);
260 
266  void RemoveCamera(const wpi::Twine& name);
267 
277  void SetSize(int size);
278 
279  private:
280  CameraServer();
281  ~CameraServer();
282 
283  struct Impl;
284  std::unique_ptr<Impl> m_impl;
285 };
286 
287 } // namespace frc
288 
289 #include "cameraserver/CameraServer.inc"
WPILib FRC namespace.
Definition: SPIAccelerometerSim.h:18
cs::MjpegServer AddServer(const wpi::Twine &name)
Adds a MJPEG server at the next available port.
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:748
cs::UsbCamera StartAutomaticCapture()
Start automatically capturing images to send to the dashboard.
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.
cs::CvSource PutVideo(const wpi::Twine &name, int width, int height)
Create a MJPEG stream with OpenCV input.
A source that represents a USB camera.
Definition: cscore_oo.h:420
void RemoveServer(const wpi::Twine &name)
Removes a server by name.
cs::AxisCamera AddAxisCamera(const wpi::Twine &host)
Adds an Axis IP camera.
A source for user code to provide OpenCV images as video frames.
Definition: cscore_oo.h:617
static CameraServer * GetInstance()
Get the CameraServer instance.
void RemoveCamera(const wpi::Twine &name)
Removes a camera by name.
cs::CvSink GetVideo()
Get OpenCV access to the primary camera feed.
Singleton class for creating and keeping camera servers.
Definition: CameraServer.h:27
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:79
A sink that acts as a MJPEG-over-HTTP network server.
Definition: cscore_oo.h:855
A source that represents an Axis IP camera.
Definition: cscore_oo.h:551
A sink for user code to accept video frames as OpenCV images.
Definition: cscore_oo.h:936