WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
RawSource.hpp
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <string_view>
8
10#include "wpi/cs/VideoMode.hpp"
11#include "wpi/cs/cscore_raw.hpp"
12#include "wpi/util/RawFrame.hpp"
13
14namespace wpi::cs {
15
16/**
17 * A source for user code to provide video frames as raw bytes.
18 *
19 * This is a complex API, most cases should use CvSource.
20 */
21class RawSource : public ImageSource {
22 public:
23 RawSource() = default;
24
25 /**
26 * Create a raw frame source.
27 *
28 * @param name Source name (arbitrary unique identifier)
29 * @param mode Video mode being generated
30 */
31 RawSource(std::string_view name, const VideoMode& mode) {
32 m_handle = CreateRawSource(name, false, mode, &m_status);
33 }
34
35 /**
36 * Create a raw frame source.
37 *
38 * @param name Source name (arbitrary unique identifier)
39 * @param pixelFormat Pixel format
40 * @param width width
41 * @param height height
42 * @param fps fps
43 */
44 RawSource(std::string_view name, VideoMode::PixelFormat pixelFormat,
45 int width, int height, int fps) {
47 name, false, VideoMode{pixelFormat, width, height, fps}, &m_status);
48 }
49
50 protected:
51 /**
52 * Put a raw image and notify sinks.
53 *
54 * @param image raw frame image
55 */
57 m_status = 0;
59 }
60};
61
62} // namespace wpi::cs
@ name
Definition base.h:690
void PutFrame(wpi::util::RawFrame &image)
Put a raw image and notify sinks.
Definition RawSource.hpp:56
RawSource(std::string_view name, VideoMode::PixelFormat pixelFormat, int width, int height, int fps)
Create a raw frame source.
Definition RawSource.hpp:44
RawSource(std::string_view name, const VideoMode &mode)
Create a raw frame source.
Definition RawSource.hpp:31
CS_Status m_status
Definition VideoSource.hpp:372
CS_Source m_handle
Video source handle.
Definition VideoSource.hpp:375
void PutSourceFrame(CS_Source source, const WPI_RawFrame &image, CS_Status *status)
CS_Source CreateRawSource(std::string_view name, bool isCv, const VideoMode &mode, CS_Status *status)
CameraServer (cscore) namespace.
Definition CvSource.hpp:15
Video mode.
Definition VideoMode.hpp:15
Definition RawFrame.hpp:20