group plugin-lcvcore

OpenCV core module wrappers for Livekeys.

Summary

Members Descriptions
classQMat Open cv matrix wrapper.
classQMatDisplay Main matrix display class.
classQMatFilter An abstract filter that transforms an input matrix into it's output.
classQMatNode Node containing matrix state.
classQMatShader Matrix shader.
classQMatState Matrix texture state.
classQUMat Open cv universal matrix wrapper.
classQWritableMat Similar to QMat, but used for quick writeable functions like drawing.

class QMat

class QMat
  : public lv::Shared

Open cv matrix wrapper.

The class represents the wrapper for the opencv matrix element to be passed around in the QML structure. To access it's cv mat value, use the internal() function.

To access it's pixels within qml, use the Mat::buffer() function.

Summary

Members Descriptions
public explicitQMat(QObject * parent) QMat constructor.
publicQMat(cv::Mat * mat,QObject * parent) QMat constructor with internal mat.
publicQMat(int width,int height,QMat::Typetype,int channels,QObject * parent) QMat memory-based constructor.
public virtual~QMat() QMat::~QMat.
publicQMat*clone() const Deep clones the mat.
public virtual voidrecycleSize(int size) Memory allocation.
public inline virtual Shared *transfer()
{slot} public QByteArraybuffer() const Returns an equivalent ArrayBuffer to access the matrix values.
{slot} public intchannels() const Returns the number of channels.
{slot} public intdepth() const Returns the matrix depth (CV8U, CV16S, ...)
{slot} public QSizedimensions() const Returns the size of the matrix.
{slot} publicQMat*createOwnedObject() Returns a shallow copied matrix that is owned by the javascript engine.
{slot} publicQMat*cloneMat() const Returns a cloned matrix that is owned by the javascript engine.
enumType Type of the QMat
typedefInternalType Type.

Members

public explicitQMat(QObject * parent)

QMat constructor.

publicQMat(cv::Mat * mat,QObject * parent)

QMat constructor with internal mat.

publicQMat(int width,int height,QMat::Typetype,int channels,QObject * parent)

QMat memory-based constructor.

Parameters

  • width

  • height

  • type

  • channels

  • parent

public virtual~QMat()

QMat::~QMat.

publicQMat*clone() const

Deep clones the mat.

public virtual voidrecycleSize(int size)

Memory allocation.

public inline virtual Shared *transfer()

{slot} public QByteArraybuffer() const

Returns an equivalent ArrayBuffer to access the matrix values.

{slot} public intchannels() const

Returns the number of channels.

{slot} public intdepth() const

Returns the matrix depth (CV8U, CV16S, ...)

{slot} public QSizedimensions() const

Returns the size of the matrix.

{slot} publicQMat*createOwnedObject()

Returns a shallow copied matrix that is owned by the javascript engine.

{slot} publicQMat*cloneMat() const

Returns a cloned matrix that is owned by the javascript engine.

enumType

Values Descriptions
CV8U
CV8S
CV16U
CV16S
CV32S
CV32F
CV64F

Type of the QMat

typedefInternalType

Type.

class QMatDisplay

class QMatDisplay
  : public QQuickItem

Main matrix display class.

Extend this class if you want to have a matrix type item that displays on screen. The display parameter is called output, which you can access by it's setter QMatDisplay::setOutput() and getter QMatDisplay::output().

Within a QML application, if an item is visible, the updatePaintNode() function is called when drawing the element. This can become useful if you have a matrix that requires extra processing only if it will be displayed on screen. when deriving this class, you can override the QMatDisplay::updatePaintNode() function, and implement the actual refurbishing in there. This way, if the element is not visible, you can save some processing time.

Summary

Members Descriptions
public explicitQMatDisplay(QQuickItem * parent) QMatDisplay constructor.
publicQMatDisplay(QMat* output,QQuickItem * parent) QMatDisplay constructor.
public virtual~QMatDisplay() QMatDisplay destructor.
public inlineQMat*output() See also: MatDisplay::output
public inline boollinearFilter() const See also: MatDisplay::linearFilter
public inline voidsetLinearFilter(bool filter) Setter for linearFilter.
protected inline voidsetOutput(QMat* mat) Set the mat to be displayed.
protected virtual QSGNode *updatePaintNode(QSGNode * node,UpdatePaintNodeData * nodeData) Updates the scene graph node with the set matrix.
{signal} public voidoutputChanged() Triggered when output is changed.
{signal} public voidlinearFilterChanged() Triggered when linearFilter is changed.

Members

public explicitQMatDisplay(QQuickItem * parent)

QMatDisplay constructor.

Parameters: parent

publicQMatDisplay(QMat* output,QQuickItem * parent)

QMatDisplay constructor.

Parameters: output**parent

public virtual~QMatDisplay()

QMatDisplay destructor.

public inlineQMat*output()

See also: MatDisplay::output

public inline boollinearFilter() const

See also: MatDisplay::linearFilter

public inline voidsetLinearFilter(bool filter)

Setter for linearFilter.

protected inline voidsetOutput(QMat* mat)

Set the mat to be displayed.

protected virtual QSGNode *updatePaintNode(QSGNode * node,UpdatePaintNodeData * nodeData)

Updates the scene graph node with the set matrix.

{signal} public voidoutputChanged()

Triggered when output is changed.

{signal} public voidlinearFilterChanged()

Triggered when linearFilter is changed.

class QMatFilter

class QMatFilter
  : public QMatDisplay

An abstract filter that transforms an input matrix into it's output.

Besides the QMatDisplay class it inherits, the QMatFilter adds an input element, and a transformation function to further ease implementing filters. The transformation function gets called every time the input element is changed. This means that to write a simple filter, all you have to do is extend this class and implement the transformation function. Here's a small example of a filter that transforms a BGR image into grayscale :

class QMatToGrey : public QMatFilter{

Q_OBJECT

public: QMatToGrey(QQuickItem* parent = 0):QMatFilter(parent){ }

void transform(const cv::Mat& in, cv::Mat& out){
    cvtColor(in, out, CV_BGR2GREY);
}

}

With that all that's left is to register the element to QML, after which you can use it like any other filter :

ImRead{
     id : src
     file : project.path + '/sample.jpg'
}
MatToGrey{
     input : src.output
}

Summary

Members Descriptions
public explicitQMatFilter(QQuickItem * parent) QMatFilter constructor parent.
public virtual~QMatFilter() QMatFilter destructor.
public inlineQMat*inputMat() See also: MatFilter::input
public inline voidsetInputMat(QMat* mat) Setter mofr the InputMat.
public voidtransform() Transformation function that handles notifications and state changes.
public virtual voidtransform(const cv::Mat & in,cv::Mat & out) Function to be implemented by derived classes to apply the filtering process. in**out.
protected voidcomponentComplete() Function used to initiate the transform function once the component is completed.
{signal} public voidinputChanged() Triggered when the input is changed.

Members

public explicitQMatFilter(QQuickItem * parent)

QMatFilter constructor parent.

public virtual~QMatFilter()

QMatFilter destructor.

public inlineQMat*inputMat()

See also: MatFilter::input

public inline voidsetInputMat(QMat* mat)

Setter mofr the InputMat.

public voidtransform()

Transformation function that handles notifications and state changes.

Call this function in order to trigger the filtering process.

public virtual voidtransform(const cv::Mat & in,cv::Mat & out)

Function to be implemented by derived classes to apply the filtering process. in**out.

protected voidcomponentComplete()

Function used to initiate the transform function once the component is completed.

{signal} public voidinputChanged()

Triggered when the input is changed.

class QMatNode

class QMatNode
  : public QSGGeometryNode

Node containing matrix state.

Summary

Members Descriptions
publicQMatNode() QMatNode constructor.

Members

publicQMatNode()

QMatNode constructor.

class QMatShader

class QMatShader
  : public QSGSimpleMaterialShader< QMatState >

Matrix shader.

Summary

Members Descriptions
publicQMatShader() QMatShader constructor.
public inline const char *vertexShader() const Returns the vertex shader.
public inline const char *fragmentShader() const Returns the fragment shader.
public inline QList< QByteArray >attributes() const Returns the gl program attributes.
public inline voidupdateState(constQMatState* state,constQMatState* oldState) Loads the matrixes texture.
public inline voidresolveUniforms() Resolves textureId uniform.
public boolloadTexture(QMat* mat,int index,bool linearFilter) Loads a matrix texture into the gpu program. Returns true on success, false otherwise.

Members

publicQMatShader()

QMatShader constructor.

public inline const char *vertexShader() const

Returns the vertex shader.

public inline const char *fragmentShader() const

Returns the fragment shader.

public inline QList< QByteArray >attributes() const

Returns the gl program attributes.

public inline voidupdateState(constQMatState* state,constQMatState* oldState)

Loads the matrixes texture.

public inline voidresolveUniforms()

Resolves textureId uniform.

public boolloadTexture(QMat* mat,int index,bool linearFilter)

Loads a matrix texture into the gpu program. Returns true on success, false otherwise.

class QMatState

Matrix texture state.

Summary

Members Descriptions
publicQMat*mat Matrix for which the state is for.
public boollinearFilter Linear filtering flag.
public mutable inttextureIndex Stored index of the texture to be displayed.
public mutable booltextureSync Stores wether the texture has been loaded (synced with opengl).
publicQMatState() QMatState constructor.
public intcompare(constQMatState* other) const Compares 2 states.

Members

publicQMat*mat

Matrix for which the state is for.

public boollinearFilter

Linear filtering flag.

public mutable inttextureIndex

Stored index of the texture to be displayed.

public mutable booltextureSync

Stores wether the texture has been loaded (synced with opengl).

publicQMatState()

QMatState constructor.

public intcompare(constQMatState* other) const

Compares 2 states.

class QUMat

class QUMat
  : public lv::Shared

Open cv universal matrix wrapper.

The class represents the wrapper for the opencv matrix element to be passed around in the QML structure. To access it's cv mat value, use the internal() function.

To access it's pixels within qml, use the Mat::buffer() function.

Summary

Members Descriptions
public explicitQUMat(QObject * parent) QUMat constructor.
publicQUMat(cv::UMat * mat,QObject * parent) QUMat constructor with internal mat.
publicQUMat(int width,int height,QUMat::Typetype,int channels,QObject * parent) QUMat memory-based constructor.
public virtual~QUMat() QUMat::~QUMat.
publicQUMat*clone() const Deep clones the mat.
public virtual voidrecycleSize(int size) Memory allocation.
public inline virtual Shared *transfer()
{slot} public intchannels() const Returns the number of channels.
{slot} public intdepth() const Returns the matrix depth (CV8U, CV16S, ...)
{slot} public QSizedimensions() const Returns the size of the matrix.
{slot} publicQUMat*createOwnedObject() Returns a shallow copied matrix that is owned by the javascript engine.
{slot} publicQUMat*cloneMat() const Returns a cloned matrix that is owned by the javascript engine.
{slot} publicQMat*getMat() const
enumType Type of the QUMat
typedefInternalType Type.

Members

public explicitQUMat(QObject * parent)

QUMat constructor.

publicQUMat(cv::UMat * mat,QObject * parent)

QUMat constructor with internal mat.

publicQUMat(int width,int height,QUMat::Typetype,int channels,QObject * parent)

QUMat memory-based constructor.

Parameters

  • width

  • height

  • type

  • channels

  • parent

public virtual~QUMat()

QUMat::~QUMat.

publicQUMat*clone() const

Deep clones the mat.

public virtual voidrecycleSize(int size)

Memory allocation.

public inline virtual Shared *transfer()

{slot} public intchannels() const

Returns the number of channels.

{slot} public intdepth() const

Returns the matrix depth (CV8U, CV16S, ...)

{slot} public QSizedimensions() const

Returns the size of the matrix.

{slot} publicQUMat*createOwnedObject()

Returns a shallow copied matrix that is owned by the javascript engine.

{slot} publicQUMat*cloneMat() const

Returns a cloned matrix that is owned by the javascript engine.

{slot} publicQMat*getMat() const

enumType

Values Descriptions
CV8U
CV8S
CV16U
CV16S
CV32S
CV32F
CV64F

Type of the QUMat

typedefInternalType

Type.

class QWritableMat

class QWritableMat
  : public QObject

Similar to QMat, but used for quick writeable functions like drawing.

This class will mostly used to preserve QMat's immutability accross functions.

To convert to a QMat, use:

QMat* m = writableMat.toMat();

Summary

Members Descriptions
public explicitQWritableMat(QObject * parent) QWritableMat constructor.
publicQWritableMat(cv::Mat * mat,QObject * parent) QWritableMat constructor with internal mat.
public virtual~QWritableMat() QWritableMat destructor.
{slot} public QByteArraybuffer() Returns an equivalent ArrayBuffer to access the matrix values.
{slot} public intchannels() const Returns the number of channels.
{slot} public intdepth() const Returns the matrix depth (CV8U, CV16S, ...)
{slot} public QSizedimensions() const Returns the size of the matrix.
{slot} publicQMat*toMat() const Returns copied QMat of this object.
{slot} public voidfill(const QColor & color,QMat* mask) Fills the matrix with a specified color.

Members

public explicitQWritableMat(QObject * parent)

QWritableMat constructor.

publicQWritableMat(cv::Mat * mat,QObject * parent)

QWritableMat constructor with internal mat.

public virtual~QWritableMat()

QWritableMat destructor.

{slot} public QByteArraybuffer()

Returns an equivalent ArrayBuffer to access the matrix values.

{slot} public intchannels() const

Returns the number of channels.

{slot} public intdepth() const

Returns the matrix depth (CV8U, CV16S, ...)

{slot} public QSizedimensions() const

Returns the size of the matrix.

{slot} publicQMat*toMat() const

Returns copied QMat of this object.

{slot} public voidfill(const QColor & color,QMat* mask)

Fills the matrix with a specified color.