34#define NDEVR_SUPPORTS_LOCAL_CAMERA 1
35#if NDEVR_SUPPORTS_LOCAL_CAMERA
36#include "DesignWidgets/Headers/PhysicalCameraView.h"
37#include "Design/Headers/Camera.h"
38#include "Base/Headers/Pointer.hpp"
39#include "Base/Headers/File.h"
41#include <QCameraDevice>
51class QMediaCaptureSession;
52class QGraphicsLineItem;
54class QCameraImageCapture;
55class QVideoEncoderSettings;
56class QAudioEncoderSettings;
60#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
211 class QMediaDeviceManager :
public QObject
218 QMediaDeviceManager(QObject* parent =
nullptr);
279 virtual bool setCameraSource(
const String& connection_id)
override;
284 virtual bool setCameraSource(
const QCameraInfo& connection_id);
286 virtual void refreshInstance()
override;
288 void setToDefaultCamera();
292 QAudioEncoderSettings audioSettings()
const;
296 QVideoEncoderSettings videoSettings()
const;
304 void processCapturedImage(
int index,
const QImage& img);
308 void handleCameraError(
int camera_error);
314 bool startRecord(
const File& file)
override;
319 bool finishRecord(
const File& file)
override;
324 virtual bool takeImage(
const File& file)
override;
328 virtual void invertScreenColors(
bool invert)
override;
332 void updateCameraState(
int state);
334 File m_screenshot_location;
336 QCameraImageCapture* imageCapture;
337 QMediaRecorder* mediaRecorder;
338 QVideoWidget* m_video_widget;
The equivelent of std::vector but with a bit more control.
A core class where all Design Objects including models, materials, and geometries are stored.
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Logic for reading or writing to a file as well as navigating filesystems or other common file operati...
Provides an interface to PhysicalCameraViewFactory for creating a LocalPhysicalCameraView.
virtual Buffer< DynamicPointer< Camera > > availableCameraStreams() const override
Gets the list of available local camera streams.
virtual PhysicalCameraView * createView(const DynamicPointer< Camera > &camera, DesignObjectLookup *model_manager, QWidget *parent) override
Creates a local camera view for the given camera.
virtual bool canCreateView(const DynamicPointer< Camera > &camera, DesignObjectLookup *model_manager, bool ignore_active) override
Checks whether this factory can create a view for the given camera.
Provides access to a local camera on the system, such as a webcam or camera for a phone.
bool event(QEvent *event) override
Handles general events for the camera view.
QCamera * m_q_camera
The Qt camera device.
Button * m_camera_flash_button
Button for toggling camera flash.
virtual ~LocalPhysicalCameraView()
Destructor.
void handleCameraError(int camera_error)
Handles a camera error.
void updateCameraSourceCombo()
Updates the camera source combo box with available devices.
QCustomComboBox * m_selection_combo
Combo box for selecting camera sources.
QMediaPlayer * m_media_player
The media player for remote sources.
virtual bool setCameraSource(const StringView &connection_id) override
Sets the camera source by connection identifier string.
QGraphicsLineItem * m_cross_hair_x
Horizontal cross-hair overlay line.
LocalPhysicalCameraView()
Default constructor.
QAudioInput * m_audio_input
The audio input for recording.
void processCapturedImage(int index, const QImage &img)
Processes a captured image frame.
void handleVideoError()
Handles a video recording error.
void setToDefaultCamera()
Sets the camera source to the system default camera.
QGraphicsView * m_graphics_view
The graphics view for video display.
bool finishRecord(File file) override
Finishes recording and saves the video file.
virtual void refreshInstance() override
Refreshes the camera instance and reconnects if needed.
virtual bool setCameraSource(const QCameraDevice &connection_id)
Sets the camera source from a QCameraDevice.
void updateCameraState(bool state)
Updates the UI based on the camera active state.
QMediaRecorder * m_media_recorder
The media recorder for video recording.
fltp08 defaultScale() const
Gets the default scale factor for the camera view.
bool startRecord(const File &file) override
Starts recording video to a file.
void updateRecorderState(int state)
Updates the UI based on the recorder state.
virtual void invertScreenColors(bool invert) override
Inverts the screen colors.
LocalVideoRenderer * m_video_widget
The video renderer widget.
virtual void setRemoteSource(const StringView &remote)
Sets a remote media source URL for the camera view.
virtual bool takeImage(const File &file) override
Captures a single image to a file.
virtual void setCameraZoom(fltp08 zoom) override
Sets the zoom level for the camera display.
void findBestFormat(const QCameraDevice &camera_evice)
Selects the best camera format for the given device.
LocalVideoRenderer * videoWidget()
Gets the video renderer widget.
File m_screenshot_location
The file path for screenshot output.
QImageCapture * m_image_capture
The image capture handler.
QGraphicsLineItem * m_cross_hair_y
Vertical cross-hair overlay line.
QMediaCaptureSession * m_capture_session
The media capture session.
void adjustCrossHairs()
Adjusts the cross-hair overlay to match the current view size.
LocalPhysicalCameraView(const DynamicPointer< Camera > &camera, QWidget *parent=nullptr)
Constructs a view for a specific camera.
virtual void resizeEvent(QResizeEvent *event) override
Handles resize events by adjusting the video and cross-hairs.
void init() override
Initializes the camera view UI and connections.
virtual bool pauseRecord(bool paused, const File &file) override
Pauses or resumes recording.
void updateRecorderTimespan()
Updates the displayed recording timespan.
void handleScreenshotError(int id, int error, const QString &errorString)
Handles a screenshot capture error.
A QGraphicsVideoItem subclass that provides custom rendering for local camera video streams.
Factory for creating PhysicalCameraView instances and querying supported output formats.
A Viewport that represents a physical camera stream, or real world camera view.
virtual ConstPointer< Camera > camera() const override
Returns a read-only pointer to the Camera.
PhysicalCameraView()
Default constructor for subclass use only.
A compact way to present a list of options to the user.
The core String View class for the NDEVR API.
The core String class for the NDEVR API.
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
The primary namespace for the NDEVR SDK.
double fltp08
Defines an alias representing an 8 byte floating-point number.