25 #include <VisionX/gui-plugins/HsvColorSegmentation/ui_HsvColorSegmentationWidget.h>
40 #include <Color/ColorParameterSet.h>
71 HsvColorSegmentationWidgetController>,
90 void loadSettings(QSettings* settings)
override;
95 void saveSettings(QSettings* settings)
override;
104 return "VisionX.HsvColorSegmentation";
109 virtual void onInitImageProcessor()
override;
110 virtual void onConnectImageProcessor()
override;
111 virtual void onDisconnectImageProcessor()
override;
112 virtual void onExitImageProcessor()
override;
114 virtual void process()
override;
120 void clickedButtonConnect(
bool toggled);
121 void clickedButtonDisconnect(
bool toggled);
122 void clickedButtonPlayPause(
bool toggled);
125 void addColorSelection(
int imageIndex,
float x,
float y);
126 void clearColorSelection();
131 void onColorSettingsChanged();
133 void onColorIndexChanged(
int value);
135 void setManualHueMid(
int value);
136 void setManualHueTol(
int value);
137 void setManualSatMin(
int value);
138 void setManualSatMax(
int value);
139 void setManualValMin(
int value);
140 void setManualValMax(
int value);
142 void onToggledCheckBoxAutoAll(
bool enabled);
143 void onToggledCheckBoxAuto(
bool enabled);
144 void onChangedAddTolerance(
int value);
146 void resetCurrentColorSettings();
151 void loadColorParameterSetFromFile(
bool showMsgBoxes =
true);
152 void saveColorParameterSetToFile();
154 void searchColorParameterFile();
155 void resetColorParameterFile();
158 void updateImageMonitorUI();
162 void imageProviderConnected(
bool connected);
177 static void rgbToHsv(
int r,
int g,
int b,
int& h,
int&
s,
int&
v);
179 static std::string getHomeDirectory();
180 static QString getDefaultColorParameterFile();
182 const static QStringList COLOR_PARAMETER_NAMES;
184 const static std::string DEFAULT_COLOR_PARAMETER_FILE;
188 void connectToProvider();
189 void disconnectFromProvider();
192 int value(
int param);
198 bool isAutoEnabled(
int param);
199 int additionalTolerance();
201 std::string colorParameterFile();
205 void recomputeAutoValues();
206 void onSelectedPointsChanged();
208 void drawSelectedPoints();
209 void runSegmentation();
214 void saveCurrentColorParameters(
int colorIndex);
216 void loadCurrentColorParameters(
int colorIndex);
219 void updatePausePlayButtonText();
221 void setUiParamValue(
int param,
int value);
222 void updateAutoValuesUI();
224 void updateColorVisualization();
226 void markCurrentColorDirty();
227 void markCurrentColorClean();
228 void markAllColorsClean();
232 Ui::HsvColorSegmentationWidget widget;
238 std::string imageProviderName;
240 visionx::ImageProviderInterfacePrx& imageProviderPrx = imageProviderInfo.
proxy;
242 int& imageWidth = imageProviderInfo.
imageFormat.dimension.width;
243 int& imageHeight = imageProviderInfo.
imageFormat.dimension.height;
245 bool connected =
false;
246 bool isPaused =
true;
249 std::recursive_mutex imageMutex;
250 HsvImageSegmentation segmentation;
252 SelectableImageViewer* imageViewerInput;
258 SelectedPoint(
int imageIndex,
float xRel,
float yRel,
int red,
int green,
int blue) :
259 imageIndex(imageIndex), xRel(xRel), yRel(yRel),
red(
red),
green(
green), blue(blue)
261 rgbToHsv(
red,
green, blue, hue, sat, val);
270 std::vector<SelectedPoint> selectedPoints;
271 std::vector<int> autoValues;
274 int currentColorIndex = 0;
275 std::set<int> dirtyColors;
276 CColorParameterSet colorParameterSet;
279 std::vector<QCheckBox*> guiAutoCheckBoxes;
280 std::vector<QSpinBox*> guiValueSpinBoxes;
281 std::vector<QSlider*> guiValueSliders;