1.10
Public Member Functions | Protected Attributes | List of all members
CameraCapture Class Reference

Capture a camera video feed directly to an output file. More...

#include <capture.h>

Inheritance diagram for CameraCapture:
Inheritance graph
[legend]

Public Member Functions

 CameraCapture (CameraCapture &&)=default
 
 CameraCapture (const CameraCapture &)=delete
 
 CameraCapture (const std::string &output, PixelFormat format=PixelFormat::yuyv, const std::string &device="/dev/video0")
 
 ~CameraCapture () override
 
CameraCaptureoperator= (CameraCapture &&)=default
 
CameraCaptureoperator= (const CameraCapture &)=delete
 
void set_output (const std::string &output, const Size &size, PixelFormat format=PixelFormat::yuyv)
 Set the output.
 
bool start ()
 Initialize camera pipeline to capture from the camera.
 
void stop ()
 Stop camera capture and finish the output.
 
- Public Member Functions inherited from Object
 Object () noexcept=default
 
 Object (const Object &)=delete
 
 Object (Object &&)=default
 
virtual ~Object () noexcept=default
 
void clear_handlers ()
 Clear all registered event handlers.
 
void invoke_handlers (Event &event)
 Invoke all handlers with the specified event.
 
void invoke_handlers (EventId event)
 Invoke all handlers with the specified EventId.
 
EGT_NODISCARD const std::string & name () const
 Get the name of the Object.
 
void name (const std::string &name)
 Set the name of the Object.
 
RegisterHandle on_event (const EventCallback &handler, const FilterFlags &mask={})
 Add an event handler to be called when the widget generates an event.
 
Objectoperator= (const Object &)=delete
 
Objectoperator= (Object &&)=default
 
void remove_handler (RegisterHandle handle)
 Remove an event handler.
 

Public Attributes

SignalW< const std::string & > on_error
 Event signal.
 
SignalW< const std::string & > on_connect
 Generated when an USB camera connected.
 
SignalW< const std::string & > on_disconnect
 Generated when an USB camera disconnected.
 

Protected Attributes

std::unique_ptr< detail::GstDecoderImpl > m_impl
 Internal capture implementation.
 
- Protected Attributes inherited from Object
detail::CopyOnWriteAllocate< CallbackArraym_callbacks
 Array of callbacks.
 
RegisterHandle m_handle_counter {0}
 Counter used to generate unique handles for each callback registration.
 
std::string m_name
 A user defined name for the Object.
 

Additional Inherited Members

- Public Types inherited from Object
using EventCallback = std::function< void(Event &event)>
 Event handler callback function.
 
using FilterFlags = FlagsBase< EventId >
 Event handler EventId filter.
 
using RegisterHandle = uint64_t
 Handle type.
 
- Protected Types inherited from Object
using CallbackArray = std::vector< CallbackMeta >
 Helper type for an array of callbacks.
 

Detailed Description

Capture a camera video feed directly to an output file.

experimental::CameraCapture capture("output.avi");
capture.start();
...
capture.stop();

Constructor & Destructor Documentation

◆ CameraCapture() [1/3]

CameraCapture ( const std::string &  output,
PixelFormat  format = PixelFormat::yuyv,
const std::string &  device = "/dev/video0" 
)
explicit
Parameters
[in]outputThe output file path.
[in]containerThe output container format.
[in]formatThe input pixel format.
[in]deviceThe camera device.

◆ CameraCapture() [2/3]

CameraCapture ( const CameraCapture )
delete

◆ CameraCapture() [3/3]

CameraCapture ( CameraCapture &&  )
default

◆ ~CameraCapture()

~CameraCapture ( )
override

Member Function Documentation

◆ operator=() [1/2]

CameraCapture & operator= ( CameraCapture &&  )
default

◆ operator=() [2/2]

CameraCapture & operator= ( const CameraCapture )
delete

◆ set_output()

void set_output ( const std::string &  output,
const Size size,
PixelFormat  format = PixelFormat::yuyv 
)

Set the output.

Warning
If this is called while the camera is currently capturing, it will automatically stop the capture.
Parameters
[in]outputThe output file path.
[in]containerThe output container format.
[in]formatThe input pixel format.

◆ start()

bool start ( )

Initialize camera pipeline to capture from the camera.

Returns
true on success

◆ stop()

void stop ( )

Stop camera capture and finish the output.

Member Data Documentation

◆ m_impl

std::unique_ptr<detail::GstDecoderImpl> m_impl
protected

Internal capture implementation.

◆ on_connect

SignalW<const std::string&> on_connect

Generated when an USB camera connected.

◆ on_disconnect

SignalW<const std::string&> on_disconnect

Generated when an USB camera disconnected.

◆ on_error

SignalW<const std::string&> on_error

Event signal.

Invoked when an error occurs.