35#ifndef VP_COLOR_HISTOGRAM_MASK_H
36#define VP_COLOR_HISTOGRAM_MASK_H
38#include <visp3/core/vpConfig.h>
39#include <visp3/core/vpException.h>
40#include <visp3/rbt/vpColorHistogram.h>
41#include <visp3/rbt/vpObjectMask.h>
42#include <visp3/core/vpDisplay.h>
43#include <visp3/core/vpImage.h>
45#ifdef VISP_HAVE_NLOHMANN_JSON
46#include VISP_NLOHMANN_JSON(json_fwd.hpp)
80 m_histBackground.setBinNumber(N);
81 m_histBackgroundFrame.setBinNumber(N);
82 m_histObject.setBinNumber(N);
83 m_histObjectFrame.setBinNumber(N);
92 m_depthErrorTolerance = errorMax;
98 if (updateRate < 0.f || updateRate > 1.f) {
101 m_objectUpdateRate = updateRate;
107 if (updateRate < 0.f || updateRate > 1.f) {
110 m_backgroundUpdateRate = updateRate;
116 m_computeOnBBOnly = bbOnly;
125 unsigned int numColor = 10;
127 unsigned int pady = 20;
128 unsigned int pad = 5;
129 unsigned int radius = 5;
131 std::vector<vpRGBa> bestColors = m_histObject.mostLikelyColors(numColor);
132 std::vector<vpRGBa> bestColorsBg = m_histBackground.mostLikelyColors(numColor);
135 for (
unsigned int i = 0; i < bestColors.size(); ++i) {
137 c.
R = bestColors[i].R;
138 c.
G = bestColors[i].G;
139 c.
B = bestColors[i].B;
145 c.
R = bestColorsBg[i].R;
146 c.
G = bestColorsBg[i].G;
147 c.
B = bestColorsBg[i].B;
160#if defined(VISP_HAVE_NLOHMANN_JSON)
165 vpColorHistogram m_histObject, m_histBackground, m_histObjectFrame, m_histBackgroundFrame;
166 float m_depthErrorTolerance;
167 float m_objectUpdateRate, m_backgroundUpdateRate;
173 bool m_computeOnBBOnly;
float getDepthErrorTolerance() const
float getObjectUpdateRate() const
virtual void reset() VP_OVERRIDE
virtual ~vpColorHistogramMask()=default
bool isComputedOnlyOnBoundingBox() const
void setComputeOnlyOnBoundingBox(bool bbOnly)
float getBackgroundUpdateRate() const
void setBinNumber(unsigned int N)
void setDepthErrorTolerance(float errorMax)
void display(const vpImage< float > &mask, vpImage< unsigned char > &Imask) const VP_OVERRIDE
void setObjectUpdateRate(float updateRate)
void setBackgroundUpdateRate(float updateRate)
Histogram representation of an RGB color distribution In this representation, probabilities are store...
Class to define RGB colors available for display functionalities.
static void displayCircle(const vpImage< unsigned char > &I, const vpImageCircle &circle, const vpColor &color, bool fill=false, unsigned int thickness=1)
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
error that can be emitted by ViSP classes.
@ badValue
Used to indicate that a value is not in the allowed range.
Definition of the vpImage class member functions.
virtual void loadJsonConfiguration(const nlohmann::json &j)=0
virtual void display(const vpImage< float > &mask, vpImage< unsigned char > &Imask) const
virtual void updateMask(const vpRBFeatureTrackerInput &frame, const vpRBFeatureTrackerInput &previousFrame, vpImage< float > &mask)=0
unsigned char B
Blue component.
unsigned char R
Red component.
unsigned char G
Green component.
unsigned char A
Additional component.