WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
ImageSink.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>
8#include <string_view>
9
10#include "wpi/cs/VideoSink.hpp"
11#include "wpi/cs/cscore_cpp.hpp"
12
13namespace wpi::cs {
14
15/**
16 * A base class for single image reading sinks.
17 */
18class ImageSink : public VideoSink {
19 protected:
20 ImageSink() = default;
21
22 public:
23 /**
24 * Set sink description.
25 *
26 * @param description Description
27 */
28 void SetDescription(std::string_view description) {
29 m_status = 0;
30 SetSinkDescription(m_handle, description, &m_status);
31 }
32
33 /**
34 * Get error string. Call this if WaitForFrame() returns 0 to determine
35 * what the error is.
36 */
37 std::string GetError() const {
38 m_status = 0;
40 }
41
42 /**
43 * Enable or disable getting new frames.
44 *
45 * <p>Disabling will cause processFrame (for callback-based CvSinks) to not
46 * be called and WaitForFrame() to not return. This can be used to save
47 * processor resources when frames are not needed.
48 */
49 void SetEnabled(bool enabled) {
50 m_status = 0;
52 }
53};
54
55} // namespace wpi::cs
void SetEnabled(bool enabled)
Enable or disable getting new frames.
Definition ImageSink.hpp:49
void SetDescription(std::string_view description)
Set sink description.
Definition ImageSink.hpp:28
std::string GetError() const
Get error string.
Definition ImageSink.hpp:37
VideoSink() noexcept=default
CS_Sink m_handle
Definition VideoSink.hpp:229
CS_Status m_status
Definition VideoSink.hpp:228
std::string GetSinkError(CS_Sink sink, CS_Status *status)
void SetSinkDescription(CS_Sink sink, std::string_view description, CS_Status *status)
void SetSinkEnabled(CS_Sink sink, bool enabled, CS_Status *status)
CameraServer (cscore) namespace.
Definition CvSource.hpp:15