arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
OutputOpenCV Class Reference

Display a video frame with OpenCV, to be used on the desktop - VideoFormat::MJPEG (the default) expects one complete, already-encoded JPEG image assembled across write() calls and closed off by flush(), as produced by e.g. DemuxerAVI. Any other setVideoFormat() value (e.g. RGB565, the common raw picture format decoders like H264Decoder produce) expects one complete, already-decoded picture per write() call instead - setSize() must be called too in that case, since unlike JPEG a raw picture doesn't carry its own dimensions. More...

#include <OutputOpenCV.h>

Inheritance diagram for OutputOpenCV:
VideoOutput

Public Member Functions

 OutputOpenCV ()=default
 
void flush () override
 
void setSize (uint16_t width, uint16_t height)
 
void setVideoFormat (VideoFormat format)
 Selects the format of the data passed to write() - see class comment.
 
size_t write (const uint8_t *data, size_t len) override
 

Protected Member Functions

void displayJpeg ()
 
void displayRaw (const uint8_t *data, size_t len)
 
void ensureWindow ()
 

Protected Attributes

bool create_window = true
 
uint16_t height = 0
 
std::vector< uint8_t > img_vector
 
size_t pos = 0
 
uint64_t start = 0
 
VideoFormat video_format = VideoFormat::MJPEG
 
uint16_t width = 0
 
const char * window = "Movie"
 

Detailed Description

Display a video frame with OpenCV, to be used on the desktop - VideoFormat::MJPEG (the default) expects one complete, already-encoded JPEG image assembled across write() calls and closed off by flush(), as produced by e.g. DemuxerAVI. Any other setVideoFormat() value (e.g. RGB565, the common raw picture format decoders like H264Decoder produce) expects one complete, already-decoded picture per write() call instead - setSize() must be called too in that case, since unlike JPEG a raw picture doesn't carry its own dimensions.

Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ OutputOpenCV()

OutputOpenCV ( )
default

Member Function Documentation

◆ displayJpeg()

void displayJpeg ( )
inlineprotected

◆ displayRaw()

void displayRaw ( const uint8_t *  data,
size_t  len 
)
inlineprotected

Wraps one complete, already-decoded raw picture (no copy - OpenCV reads directly out of 'data') and converts it to OpenCV's native BGR for display. Not every VideoFormat OpenCV could conceivably display is covered here - see the switch below for exactly which ones are.

◆ ensureWindow()

void ensureWindow ( )
inlineprotected

◆ flush()

void flush ( )
inlineoverridevirtual

Displays the assembled jpeg image, then resets for the next frame - only relevant for VideoFormat::MJPEG; raw formats display immediately from write() instead (one complete picture per call), so this is a no-op for those.

Reimplemented from VideoOutput.

◆ setSize()

void setSize ( uint16_t  width,
uint16_t  height 
)
inline

Defines the picture size - only needed (and used) for raw, non-MJPEG formats (see class comment). Call before the first write().

◆ setVideoFormat()

void setVideoFormat ( VideoFormat  format)
inline

Selects the format of the data passed to write() - see class comment.

◆ write()

size_t write ( const uint8_t *  data,
size_t  len 
)
inlineoverridevirtual

Implements VideoOutput.

Member Data Documentation

◆ create_window

bool create_window = true
protected

◆ height

uint16_t height = 0
protected

◆ img_vector

std::vector<uint8_t> img_vector
protected

◆ pos

size_t pos = 0
protected

◆ start

uint64_t start = 0
protected

◆ video_format

VideoFormat video_format = VideoFormat::MJPEG
protected

◆ width

uint16_t width = 0
protected

◆ window

const char* window = "Movie"
protected

The documentation for this class was generated from the following file: