WPILibC++  2019.1.1-beta-1-21-gfb557f4
 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 
39 #ifdef __linux__
40  // USBCamera does not work on anything except Linux.
53 
63 
70  cs::UsbCamera StartAutomaticCapture(const wpi::Twine& name, int dev);
71 
79  const wpi::Twine& path);
80 #endif
81 
88  void StartAutomaticCapture(const cs::VideoSource& camera);
89 
98 
106  cs::AxisCamera AddAxisCamera(const char* host);
107 
115  cs::AxisCamera AddAxisCamera(const std::string& host);
116 
125 
133  template <typename T>
134  cs::AxisCamera AddAxisCamera(std::initializer_list<T> hosts);
135 
142  cs::AxisCamera AddAxisCamera(const wpi::Twine& name, const wpi::Twine& host);
143 
150  cs::AxisCamera AddAxisCamera(const wpi::Twine& name, const char* host);
151 
158  cs::AxisCamera AddAxisCamera(const wpi::Twine& name, const std::string& host);
159 
168 
175  template <typename T>
177  std::initializer_list<T> hosts);
178 
187 
194  cs::CvSink GetVideo(const cs::VideoSource& camera);
195 
202  cs::CvSink GetVideo(const wpi::Twine& name);
203 
212  cs::CvSource PutVideo(const wpi::Twine& name, int width, int height);
213 
219  cs::MjpegServer AddServer(const wpi::Twine& name);
220 
226  cs::MjpegServer AddServer(const wpi::Twine& name, int port);
227 
233  void AddServer(const cs::VideoSink& server);
234 
240  void RemoveServer(const wpi::Twine& name);
241 
249 
255  cs::VideoSink GetServer(const wpi::Twine& name);
256 
262  void AddCamera(const cs::VideoSource& camera);
263 
269  void RemoveCamera(const wpi::Twine& name);
270 
280  void SetSize(int size);
281 
282  private:
283  CameraServer();
284  ~CameraServer();
285 
286  struct Impl;
287  std::unique_ptr<Impl> m_impl;
288 };
289 
290 } // namespace frc
291 
292 #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 StartAutomaticCapture(const cs::VideoSource &camera)
Start automatically capturing images to send to the dashboard from an existing 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:689
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:370
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:558
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:796
A source that represents an Axis IP camera.
Definition: cscore_oo.h:501
A sink for user code to accept video frames as OpenCV images.
Definition: cscore_oo.h:877