25 #include <VisionX/gui-plugins/HsvColorSegmentation/ui_HsvColorSegmentationWidget.h>
29 #include <Color/ColorParameterSet.h>
95 void loadSettings(QSettings* settings)
override;
100 void saveSettings(QSettings* settings)
override;
108 return "VisionX.HsvColorSegmentation";
114 virtual void onInitImageProcessor()
override;
115 virtual void onConnectImageProcessor()
override;
116 virtual void onDisconnectImageProcessor()
override;
117 virtual void onExitImageProcessor()
override;
119 virtual void process()
override;
125 void clickedButtonConnect(
bool toggled);
126 void clickedButtonDisconnect(
bool toggled);
127 void clickedButtonPlayPause(
bool toggled);
130 void addColorSelection(
int imageIndex,
float x,
float y);
131 void clearColorSelection();
136 void onColorSettingsChanged();
138 void onColorIndexChanged(
int value);
140 void setManualHueMid(
int value);
141 void setManualHueTol(
int value);
142 void setManualSatMin(
int value);
143 void setManualSatMax(
int value);
144 void setManualValMin(
int value);
145 void setManualValMax(
int value);
147 void onToggledCheckBoxAutoAll(
bool enabled);
148 void onToggledCheckBoxAuto(
bool enabled);
149 void onChangedAddTolerance(
int value);
151 void resetCurrentColorSettings();
156 void loadColorParameterSetFromFile(
bool showMsgBoxes =
true);
157 void saveColorParameterSetToFile();
159 void searchColorParameterFile();
160 void resetColorParameterFile();
163 void updateImageMonitorUI();
167 void imageProviderConnected(
bool connected);
173 HUE_MID, HUE_TOL, SAT_MIN, SAT_MAX, VAL_MIN, VAL_MAX, NUM_PARAMS
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;
260 SelectedPoint(
int imageIndex,
float xRel,
float yRel,
int red,
int green,
int blue) :
261 imageIndex(imageIndex), xRel(xRel), yRel(yRel),
264 rgbToHsv(
red,
green, blue, hue, sat, val);
273 std::vector<SelectedPoint> selectedPoints;
274 std::vector<int> autoValues;
277 int currentColorIndex = 0;
278 std::set<int> dirtyColors;
279 CColorParameterSet colorParameterSet;
284 std::vector<QCheckBox*> guiAutoCheckBoxes;
285 std::vector<QSpinBox*> guiValueSpinBoxes;
286 std::vector<QSlider*> guiValueSliders;