WPILibC++ 2024.3.2
Raw Image Functions

Classes

class  cs::RawSource
 A source for user code to provide video frames as raw bytes. More...
 
class  cs::RawSink
 A sink for user code to accept video frames as raw bytes. More...
 

Functions

CS_Source cs::CreateRawSource (std::string_view name, const VideoMode &mode, CS_Status *status)
 
CS_Sink cs::CreateRawSink (std::string_view name, CS_Status *status)
 
CS_Sink cs::CreateRawSinkCallback (std::string_view name, std::function< void(uint64_t time)> processFrame, CS_Status *status)
 
void cs::PutSourceFrame (CS_Source source, const WPI_RawFrame &image, CS_Status *status)
 
uint64_t cs::GrabSinkFrame (CS_Sink sink, WPI_RawFrame &image, CS_Status *status)
 
uint64_t cs::GrabSinkFrameTimeout (CS_Sink sink, WPI_RawFrame &image, double timeout, CS_Status *status)
 
 cs::RawSource::RawSource ()=default
 
 cs::RawSource::RawSource (std::string_view name, const VideoMode &mode)
 Create a raw frame source. More...
 
 cs::RawSource::RawSource (std::string_view name, VideoMode::PixelFormat pixelFormat, int width, int height, int fps)
 Create a raw frame source. More...
 
void cs::RawSource::PutFrame (wpi::RawFrame &image)
 Put a raw image and notify sinks. More...
 
 cs::RawSink::RawSink ()=default
 
 cs::RawSink::RawSink (std::string_view name)
 Create a sink for accepting raw images. More...
 
 cs::RawSink::RawSink (std::string_view name, std::function< void(uint64_t time)> processFrame)
 Create a sink for accepting raws images in a separate thread. More...
 
uint64_t cs::RawSink::GrabFrame (wpi::RawFrame &image, double timeout=0.225) const
 Wait for the next frame and get the image. More...
 
uint64_t cs::RawSink::GrabFrameNoTimeout (wpi::RawFrame &image) const
 Wait for the next frame and get the image. More...
 

Detailed Description

Function Documentation

◆ CreateRawSink()

CS_Sink cs::CreateRawSink ( std::string_view  name,
CS_Status status 
)

◆ CreateRawSinkCallback()

CS_Sink cs::CreateRawSinkCallback ( std::string_view  name,
std::function< void(uint64_t time)>  processFrame,
CS_Status status 
)

◆ CreateRawSource()

CS_Source cs::CreateRawSource ( std::string_view  name,
const VideoMode mode,
CS_Status status 
)

◆ GrabFrame()

uint64_t cs::RawSink::GrabFrame ( wpi::RawFrame image,
double  timeout = 0.225 
) const
inlineprotected

Wait for the next frame and get the image.

Times out (returning 0) after timeout seconds. The provided image will have three 8-bit channels stored in BGR order.

Returns
Frame time, or 0 on error (call GetError() to obtain the error message); the frame time is in the same time base as wpi::Now(), and is in 1 us increments.

◆ GrabFrameNoTimeout()

uint64_t cs::RawSink::GrabFrameNoTimeout ( wpi::RawFrame image) const
inlineprotected

Wait for the next frame and get the image.

May block forever. The provided image will have three 8-bit channels stored in BGR order.

Returns
Frame time, or 0 on error (call GetError() to obtain the error message); the frame time is in the same time base as wpi::Now(), and is in 1 us increments.

◆ GrabSinkFrame()

uint64_t cs::GrabSinkFrame ( CS_Sink  sink,
WPI_RawFrame image,
CS_Status status 
)

◆ GrabSinkFrameTimeout()

uint64_t cs::GrabSinkFrameTimeout ( CS_Sink  sink,
WPI_RawFrame image,
double  timeout,
CS_Status status 
)

◆ PutFrame()

void cs::RawSource::PutFrame ( wpi::RawFrame image)
inlineprotected

Put a raw image and notify sinks.

Parameters
imageraw frame image

◆ PutSourceFrame()

void cs::PutSourceFrame ( CS_Source  source,
const WPI_RawFrame image,
CS_Status status 
)

◆ RawSink() [1/3]

cs::RawSink::RawSink ( )
default

◆ RawSink() [2/3]

cs::RawSink::RawSink ( std::string_view  name)
inlineexplicit

Create a sink for accepting raw images.

GrabFrame() must be called on the created sink to get each new image.

Parameters
nameSource name (arbitrary unique identifier)

◆ RawSink() [3/3]

cs::RawSink::RawSink ( std::string_view  name,
std::function< void(uint64_t time)>  processFrame 
)
inline

Create a sink for accepting raws images in a separate thread.

A thread will be created that calls WaitForFrame() and calls the processFrame() callback each time a new frame arrives.

Parameters
nameSource name (arbitrary unique identifier)
processFrameFrame processing function; will be called with a time=0 if an error occurred. processFrame should call GetImage() or GetError() as needed, but should not call (except in very unusual circumstances) WaitForImage().

◆ RawSource() [1/3]

cs::RawSource::RawSource ( )
default

◆ RawSource() [2/3]

cs::RawSource::RawSource ( std::string_view  name,
const VideoMode mode 
)
inline

Create a raw frame source.

Parameters
nameSource name (arbitrary unique identifier)
modeVideo mode being generated

◆ RawSource() [3/3]

cs::RawSource::RawSource ( std::string_view  name,
VideoMode::PixelFormat  pixelFormat,
int  width,
int  height,
int  fps 
)
inline

Create a raw frame source.

Parameters
nameSource name (arbitrary unique identifier)
pixelFormatPixel format
widthwidth
heightheight
fpsfps