API Documentation
Loading...
Searching...
No Matches
LocalPhysicalCameraView.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Widgets
28File: PhysicalCameraView
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#define NDEVR_SUPPORTS_LOCAL_CAMERA 1
35#if NDEVR_SUPPORTS_LOCAL_CAMERA
39#include "Base/Headers/File.h"
40#include <qglobal.h>
41class QAudioInput;
42class QImageCapture;
43class QCamera;
44class QCameraDevice;
45class QVideoWidget;
46class QMediaDevices;
47class QMediaRecorder;
48class QMediaCaptureSession;
49class QCameraInfo;
50class QCameraImageCapture;
51class QVideoEncoderSettings;
52class QAudioEncoderSettings;
53class QImage;
54namespace NDEVR
55{
56#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
57 class QCustomComboBox;
58 class Button;
59 /**--------------------------------------------------------------------------------------------------
60 \brief Provides access to a local camera on the system, such as a webcam or camera for a phone.
61 **/
62 class LOCAL_CAMERA_STREAM_API LocalPhysicalCameraView : public PhysicalCameraView
63 {
64 Q_OBJECT
65 public:
67 LocalPhysicalCameraView(const DynamicPointer<Camera>& camera, QWidget* parent = nullptr);
68 virtual bool setCameraSource(const String& connection_id) override;
69 virtual bool setCameraSource(const QCameraDevice& connection_id);
70 virtual void refreshInstance() override;
73 protected slots:
74 void processCapturedImage(int index, const QImage& img);
75 void handleCameraError(int camera_error);
76 void handleScreenshotError(int id, int error, const QString& errorString);
78 void updateCameraState(bool state);
79 void updateRecorderState(int state);
81 protected:
82 void init();
84 bool startRecord(const File& file) override;
85 bool finishRecord(File file) override;
86 virtual bool pauseRecord(bool paused, const File& file) override;
87 virtual bool takeImage(const File& file) override;
88 virtual void invertScreenColors(bool invert) override;
89 protected:
91 QMediaDevices* m_devices = nullptr;
92 QMediaCaptureSession* m_capture_session = nullptr;
93 QCamera* m_camera = nullptr;
94 QAudioInput* m_audio_input = nullptr;
95 QImageCapture* m_image_capture = nullptr;
96 QVideoWidget* m_video_widget = nullptr;
97 QMediaRecorder* m_media_recorder = nullptr;
100 };
101 /**--------------------------------------------------------------------------------------------------
102 \brief Provides an interface to PhysicalCameraViewFactory for creating a LocalPhysicalCameraView
103 **/
104 class LocalPhysicalCameraViewFactory : public PhysicalCameraViewFactory
105 {
106 public:
107 virtual PhysicalCameraView* createView(const DynamicPointer<Camera>& camera, DesignObjectLookup* model_manager, bool auto_add_models, QWidget* parent) override;
108 virtual bool canCreateView(const DynamicPointer<Camera>& camera, DesignObjectLookup* model_manager) override;
110 };
111#else
112 class NDEVR_WIDGETS_API LocalPhysicalCameraView : public PhysicalCameraView
113 {
114 Q_OBJECT
115 public:
117 LocalPhysicalCameraView(DynamicPointer<Camera>& camera, QWidget* parent = nullptr);
118 virtual bool setCameraSource(const String& connection_id) override;
119 virtual bool setCameraSource(const QCameraInfo& connection_id);
120 virtual void refreshInstance() override;
121 void setToDefaultCamera();
122 QAudioEncoderSettings audioSettings() const;
123 QVideoEncoderSettings videoSettings() const;
124 virtual ~LocalPhysicalCameraView();
125 protected slots:
126 void processCapturedImage(int index, const QImage& img);
127 void handleCameraError(int camera_error);
128 protected:
129 bool startRecord(const File& file) override;
130 bool finishRecord(const File& file) override;
131 virtual bool takeImage(const File& file) override;
132 virtual void invertScreenColors(bool invert) override;
133 void updateCameraState(int state);
134 protected:
135 File m_screenshot_location;
136 QCamera* m_camera;
137 QCameraImageCapture* imageCapture;
138 QMediaRecorder* mediaRecorder;
139 QVideoWidget* m_video_widget;
140 };
141#endif
142}
143#endif
#define LOCAL_CAMERA_STREAM_API
Definition DLLInfo.h:55
#define NDEVR_WIDGETS_API
Definition DLLInfo.h:59
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:56
A core widget that allows the user to click one of many button types.
Definition Button.h:66
A core class where all Design Objects including models, materials, and geometries are stored....
Definition DesignObjectLookup.h:65
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Definition Pointer.hpp:320
Logic for reading or writing to a file as well as navigating filesystems.
Definition File.h:48
Provides an interface to PhysicalCameraViewFactory for creating a LocalPhysicalCameraView.
Definition LocalPhysicalCameraView.h:105
virtual PhysicalCameraView * createView(const DynamicPointer< Camera > &camera, DesignObjectLookup *model_manager, bool auto_add_models, QWidget *parent) override
virtual Buffer< DynamicPointer< Camera > > availableCameraStreams() const override
virtual bool canCreateView(const DynamicPointer< Camera > &camera, DesignObjectLookup *model_manager) override
Provides access to a local camera on the system, such as a webcam or camera for a phone.
Definition LocalPhysicalCameraView.h:63
virtual bool takeImage(const File &file) override
virtual void refreshInstance() override
bool finishRecord(File file) override
LocalPhysicalCameraView(const DynamicPointer< Camera > &camera, QWidget *parent=nullptr)
Button * m_camera_flash_button
Definition LocalPhysicalCameraView.h:99
void handleScreenshotError(int id, int error, const QString &errorString)
virtual bool pauseRecord(bool paused, const File &file) override
virtual void invertScreenColors(bool invert) override
QCustomComboBox * m_selection_combo
Definition LocalPhysicalCameraView.h:98
void updateRecorderState(int state)
void updateCameraState(bool state)
File m_screenshot_location
Definition LocalPhysicalCameraView.h:90
virtual bool setCameraSource(const QCameraDevice &connection_id)
void processCapturedImage(int index, const QImage &img)
bool startRecord(const File &file) override
virtual bool setCameraSource(const String &connection_id) override
void handleCameraError(int camera_error)
A compact way to present a list of options to the user.
Definition QCustomCombobox.h:53
The core String class for the NDEVR API.
Definition String.h:69
Definition ACIColor.h:37