Skip to content

blob_display

Alexandre Marcireau edited this page Jun 3, 2018 · 7 revisions

In header "../third_party/chameleon/source/blob_display.hpp"

chameleon::blob_display displays gaussian blobs as ellipses.

namespace chameleon {
    class blob_display : public QQuickItem {
        Q_OBJECT
        Q_PROPERTY(QSize canvas_size READ canvas_size WRITE set_canvas_size)
        Q_PROPERTY(QColor stroke_color READ stroke_color WRITE set_stroke_color)
        Q_PROPERTY(qreal stroke_thickness READ stroke_thickness WRITE set_stroke_thickness)
        Q_PROPERTY(QColor fill_color READ fill_color WRITE fill_color)
        Q_PROPERTY(qreal confidence READ confidence WRITE set_confidence)
        public:
        blob_display(QQuickItem* parent = nullptr);

        /// set_canvas_size defines the display coordinates.
        virtual void set_canvas_size(QSize canvas_size);

        /// canvas_size returns the currently used canvas_size.
        virtual QSize canvas_size() const;

        /// set_stroke_color defines the stroke color for the blobs.
        virtual void set_stroke_color(QColor color);

        /// stroke_color returns the currently used stroke color.
        virtual QColor stroke_color() const;

        /// set_stroke_thickness defines the stroke thickness for the blobs.
        virtual void set_stroke_thickness(qreal thickness);

        /// stroke_thickness returns the currently used stroke thickness.
        virtual qreal stroke_thickness() const;

        /// set_fill_color defines the fill color for the blobs.
        virtual void set_fill_color(QColor color);

        /// fill_color returns the currently used fill color.
        virtual QColor fill_color() const;

        /// set_confidence defines the confidence level for gaussian representation.
        virtual void set_confidence(qreal confidence);

        /// confidence returns the currently used confidence level.
        virtual qreal confidence() const;

        /// insert displays a blob, which can be updated later on using its id.
        template <typename Blob>
        void insert(std::size_t id, Blob blob);

        /// update modifies the parameters of an existing blob.
        template <typename Blob>
        void update(std::size_t id, Blob blob);

        /// erase removes an existing blob.
        virtual void erase(std::size_t id);

        /// paint is called by the render thread when drawing is required.
        virtual void paint(QPainter* painter) override;
    };
}
  • confidence is the confidence level used to compute an ellipse from a blob. The larger the confidence, the larger the ellipse for a given blob.
  • Blob must have at least the properties x, y, sigma_x_squared, sigma_xy and sigma_y_squared.
  • id uniquely identifies a blob. An error is thrown if insert is called with an already registered id, or if update or erase are called with an unknown id.

A typical QML instantiation has the following syntax:

BlobDisplay {
    canvas_size: "320x240" // required
    stroke_color: "#000000" // optional, defaults to "#000000"
    stroke_thickness: 1 // optional, defaults to 1
    fill_color: "#00000000" /// optional, defaults to "#00000000" (transparent)
}
Clone this wiki locally