CVB++ 14.0
Recorder Class Reference

Movie recorder for writing video files to disk. More...

#include <cvb/movie2/recorder.hpp>

Public Member Functions

void * Handle () const noexcept
 Classic API classifier handle. More...
 
void Write (const Image &image, const String &metaData=String())
 Writes the given image into the stream. More...
 

Static Public Member Functions

static RecorderPtr FromHandle (HandleGuard< Recorder > &&guard)
 Creates a recorder from a classic API handle. More...
 
static std::unique_ptr< RecorderCreate (const String &path, Size2D< int > size, RecorderPixelFormat pixelFormat, const RecordingSettings &settings)
 Creates a recorder object writing video streams with the given pixel format and recording engine. More...
 
static std::unique_ptr< RecorderCreate (const String &path, Size2D< int > size, RecorderPixelFormat pixelFormat)
 Creates a recorder object writing video streams with the given pixel format. Uses the DirectShowEngine per default. More...
 

Detailed Description

Movie recorder for writing video files to disk.

Example:
Cvb::String path(Cvb::ExpandPath(CVB_LIT("%CVB%Tutorial\\ClassicSwitch.emu")));
// Open the device
auto device = Cvb::DeviceFactory::Open(path);
// Get the first stream of the device
auto stream = device->Stream();
// Start the stream - start the acquisition
stream->Start();
// Start recording (default with DirectShowEngine)
auto recorder = Cvb::Movie2::Recorder::Create(CVB_LIT("W:\\Temp\\test.avi"), device->DeviceImage()->Size(), Cvb::Movie2::RecorderPixelFormat::Mono);
for (int i = 0; i < 100; ++i)
{
// Wait for an image with a timeout of 10 seconds
auto waitResult = stream->WaitFor(std::chrono::seconds(10));
if (waitResult.Status == Cvb::WaitStatus::Timeout)
throw std::runtime_error("acquisition timeout");
recorder->Write(*waitResult.Image);
}
// Stop recording
recorder.reset();
// Stop the stream
stream->Stop();
static std::shared_ptr< T > Open(const String &provider, AcquisitionStack acquisitionStack=AcquisitionStack::PreferVin)
Opens a device with the given provider with its default board and port (if applicable).
Definition: decl_device_factory.hpp:50
static std::unique_ptr< Recorder > Create(const String &path, Size2D< int > size, RecorderPixelFormat pixelFormat, const RecordingSettings &settings)
Creates a recorder object writing video streams with the given pixel format and recording engine.
Definition: recorder.hpp:96
@ Mono
Recorder writes single-plane monochrome data.
@ Timeout
A timeout occurred, no image buffer has been returned.

Member Function Documentation

◆ Create() [1/2]

static std::unique_ptr< Recorder > Create ( const String path,
Size2D< int >  size,
RecorderPixelFormat  pixelFormat 
)
inlinestatic

Creates a recorder object writing video streams with the given pixel format. Uses the DirectShowEngine per default.

Parameters
[in]pathPath to write avi container to.
[in]sizeSize of the video frames in pixels.
[in]pixelFormatDefines whether mono or color images are written.
Returns
Pointer to recorder object.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ Create() [2/2]

static std::unique_ptr< Recorder > Create ( const String path,
Size2D< int >  size,
RecorderPixelFormat  pixelFormat,
const RecordingSettings settings 
)
inlinestatic

Creates a recorder object writing video streams with the given pixel format and recording engine.

Parameters
[in]pathPath to write avi container to.
[in]sizeSize of the video frames in pixels.
[in]pixelFormatDefines whether mono or color images are written.
[in]settingsRecorder settings to use for the recording engine.
Returns
Pointer to recorder object.
Exceptions
Anyexception derived from std::exception including CvbException.
Examples
Movie2/QtMovie2.

◆ FromHandle()

static RecorderPtr FromHandle ( HandleGuard< Recorder > &&  guard)
inlinestatic

Creates a recorder from a classic API handle.

Parameters
[in]guardLife time guard for C-API handle.
Returns
The classifier created from the classic API handle.
Exceptions
Anyexception derived from std::exception including CvbException.

The classifier takes ownership of the handle, so you must share it before using this function.

◆ Handle()

void * Handle ( ) const
inlinenoexcept

Classic API classifier handle.

Returns
Classic API handle.
Exceptions
Doesnot throw any exception.

It is normally not necessary to work with this handle.

◆ Write()

void Write ( const Image image,
const String metaData = String() 
)
inline

Writes the given image into the stream.

Parameters
[in]imageImage to write into the stream.
[in]metaDataMetadata text to write into the stream (must be ASCII).
Exceptions
Anyexception derived from std::exception including CvbException.