1.10
camera.h
1/*
2 * Copyright (C) 2018 Microchip Technology Inc. All rights reserved.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6#ifndef EGT_CAMERA_H
7#define EGT_CAMERA_H
8
14#include <egt/detail/meta.h>
15#include <egt/window.h>
16#include <memory>
17#include <string>
18
19namespace egt
20{
21inline namespace v1
22{
23
24namespace detail
25{
26class GstDecoderImpl;
27}
28
38class EGT_API CameraWindow : public Window
39{
40protected:
41
43 std::unique_ptr<detail::GstDecoderImpl> m_camera_impl;
44
45public:
46
55
60
82 explicit CameraWindow(const std::string& device = "/dev/video0",
83 PixelFormat format_hint = PixelFormat::yuyv,
84 WindowHint hint = WindowHint::overlay);
85
102 explicit CameraWindow(const Rect& rect,
103 const std::string& device = "/dev/video0",
104 PixelFormat format_hint = PixelFormat::yuyv,
105 WindowHint hint = WindowHint::overlay);
106
113 : CameraWindow(props, false)
114 {
115 }
116
117protected:
118
119 CameraWindow(Serializer::Properties& props, bool is_derived);
120
121public:
122
123 CameraWindow(const CameraWindow&) = delete;
127
128 void do_draw() override
129 {
130 // video windows don't draw
131 }
132
133 void draw(Painter& painter, const Rect& rect) override;
134
141 bool start();
142
147 bool play();
148
154 EGT_NODISCARD bool playing() const;
155
156 /*
157 * set camera device node.
158 *
159 * @param[in] device Camera device node.
160 */
161 void device(const std::string& device);
162
163 /*
164 * Get camera device node in use.
165 */
166 std::string device() const;
167
168 /*
169 * Get the list of camera devices
170 */
171 std::vector<std::string> list_devices();
172
176 void stop();
177
178 using Window::scale;
179
180 void scale(float hscale, float vscale) override;
181
182 void serialize(Serializer& serializer) const override;
183
184 ~CameraWindow() noexcept override;
185
186private:
187
188 void deserialize(Serializer::Properties& props);
189
190};
191
192}
193}
194
195#endif
A CameraWindow is a widget to capture image feed from the camera sensor and render it on screen using...
Definition camera.h:39
std::vector< std::string > list_devices()
EGT_NODISCARD bool playing() const
Check is the camera pipeline in play state.
CameraWindow(CameraWindow &&)=default
bool play()
Set the camera pipeline to the play state.
CameraWindow(const std::string &device="/dev/video0", PixelFormat format_hint=PixelFormat::yuyv, WindowHint hint=WindowHint::overlay)
Create a camera window.
CameraWindow & operator=(CameraWindow &&)=default
std::string device() const
void draw(Painter &painter, const Rect &rect) override
Draw the widget.
SignalW< const std::string & > on_error
Event signal.
Definition camera.h:54
CameraWindow & operator=(const CameraWindow &)=delete
CameraWindow(const Rect &rect, const std::string &device="/dev/video0", PixelFormat format_hint=PixelFormat::yuyv, WindowHint hint=WindowHint::overlay)
Create a camera window.
CameraWindow(const CameraWindow &)=delete
void stop()
Stop camera.
void serialize(Serializer &serializer) const override
Serialize the widget to the specified serializer.
void do_draw() override
Perform the actual drawing.
Definition camera.h:128
SignalW< const std::string & > on_disconnect
Generated when an USB camera disconnected.
Definition camera.h:64
bool start()
Initialize camera pipeline to capture image feed from the camera sensor and render to Window.
CameraWindow(Serializer::Properties &props)
Construct a camera window.
Definition camera.h:112
SignalW< const std::string & > on_connect
Generated when an USB camera connected.
Definition camera.h:59
void device(const std::string &device)
CameraWindow(Serializer::Properties &props, bool is_derived)
~CameraWindow() noexcept override
void scale(float hscale, float vscale) override
Set the scale of the widget.
Drawing interface for 2D graphics.
Definition painter.h:45
Abstract base serializer class.
Definition serialize.h:34
std::list< std::tuple< std::string, std::string, Serializer::Attributes > > Properties
Definition serialize.h:47
Definition signal.h:184
A Window is a Widget that handles drawing to a Screen.
Definition window.h:47
WindowHint
Hint used for configuring Window backends.
Definition widgetflags.h:683
PixelFormat
Supported pixel formats.
Definition types.h:94
EGT framework namespace.
Definition animation.h:24