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

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

Inheritance diagram for CameraCapture:
Inheritance graph
[legend]

Public Types

enum class  ContainerType { avi , mpeg2ts }
 Output container type. More...
 
- Public Types inherited from Object
using EventCallback = std::function< void(Event &event)>
 Event handler callback function. More...
 
using FilterFlags = FlagsBase< EventId >
 Event handler EventId filter. More...
 
using RegisterHandle = uint64_t
 Handle type. More...
 

Public Member Functions

 CameraCapture ()
 
 CameraCapture (CameraCapture &&)=default
 
 CameraCapture (const CameraCapture &)=delete
 
 CameraCapture (const std::string &output, ContainerType container=ContainerType::avi, 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, ContainerType container=ContainerType::avi, PixelFormat format=PixelFormat::yuyv)
 Set the output. More...
 
bool start ()
 Initialize camera pipeline to capture from the camera. More...
 
void stop ()
 Stop camera capture and finish the output. More...
 
- 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. More...
 
void invoke_handlers (Event &event)
 Invoke all handlers with the specified event. More...
 
void invoke_handlers (EventId event)
 Invoke all handlers with the specified EventId. More...
 
EGT_NODISCARD const std::string & name () const
 Get the name of the Object. More...
 
void name (const std::string &name)
 Set the name of the Object. More...
 
RegisterHandle on_event (const EventCallback &handler, const FilterFlags &mask={})
 Add an event handler to be called when the widget generates an event. More...
 
Objectoperator= (const Object &)=delete
 
Objectoperator= (Object &&)=default
 
void remove_handler (RegisterHandle handle)
 Remove an event handler. More...
 

Public Attributes

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

Protected Attributes

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

Additional Inherited Members

- Protected Types inherited from Object
using CallbackArray = std::vector< CallbackMeta >
 Helper type for an array of callbacks. More...
 

Detailed Description

Capture a camera video feed directly to an output file.

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

Member Enumeration Documentation

◆ ContainerType

enum ContainerType
strong

Output container type.

Enumerator
avi 
mpeg2ts 

Constructor & Destructor Documentation

◆ CameraCapture() [1/4]

◆ CameraCapture() [2/4]

CameraCapture ( const std::string &  output,
ContainerType  container = ContainerType::avi,
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() [3/4]

CameraCapture ( const CameraCapture )
delete

◆ CameraCapture() [4/4]

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,
ContainerType  container = ContainerType::avi,
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::CaptureImpl> m_impl
protected

Internal capture implementation.

◆ on_connect

Signal<const std::string&> on_connect

Generated when an USB camera connected.

◆ on_disconnect

Signal<const std::string&> on_disconnect

Generated when an USB camera disconnected.

◆ on_error

Signal<const std::string&> on_error

Event signal.

Invoked when an error occurs.