Commit 92c8729a authored by Sergi Hernandez's avatar Sergi Hernandez
Browse files

Implemented the function to save the yaml file.

parent 0c7a2ed8
......@@ -132,6 +132,7 @@ class ColorCalibrationAlgNode : public algorithm_base::IriBaseAlgorithm<ColorCal
void load_params(const std::string &filename);
void save_params(const std::string &filename);
void get_color_id(std::string &color_id);
void set_color_id(const std::string &color_id);
/**
* \brief Destructor
*
......
......@@ -24,6 +24,7 @@ class MainGui : public QWidget
void on_blob_min_size_textChanged(const QString &new_value);
void on_load_params_pressed(void);
void on_save_params_pressed(void);
void on_color_id_value_textChanged(const QString &new_value);
void timerDone();
protected:
......
......@@ -32,6 +32,7 @@ ColorCalibrationAlgNode::ColorCalibrationAlgNode(MainGui *gui) :
set_filter_client_ = this->public_node_handle_.serviceClient<iri_blob_detector::set_hsv_filter>("set_filter");
this->filter_pixels.clear();
this->alg_.update_filter(this->filter_pixels,this->set_filter_srv_.request.params);
this->color_id="none";
// [init action servers]
......@@ -415,7 +416,21 @@ void ColorCalibrationAlgNode::load_params(const std::string &filename)
void ColorCalibrationAlgNode::save_params(const std::string &filename)
{
std::ofstream params_file;
this->filter_mutex_enter();
params_file.open(filename.c_str(),std::ofstream::out);
params_file << "color_id: " << this->color_id << std::endl;
params_file << "H_center: " << this->set_filter_srv_.request.params.hue_center << std::endl;
params_file << "H_window: " << this->set_filter_srv_.request.params.hue_window << std::endl;
params_file << "S_center: " << this->set_filter_srv_.request.params.saturation_center << std::endl;
params_file << "S_window: " << this->set_filter_srv_.request.params.saturation_window << std::endl;
params_file << "V_center: " << this->set_filter_srv_.request.params.value_center << std::endl;
params_file << "V_window: " << this->set_filter_srv_.request.params.value_window << std::endl;
params_file << "max_area: " << this->set_filter_srv_.request.params.blob_max_size << std::endl;
params_file << "min_area: " << this->set_filter_srv_.request.params.blob_min_size << std::endl;
params_file.close();
this->filter_mutex_exit();
}
void ColorCalibrationAlgNode::get_color_id(std::string &color_id)
......@@ -425,6 +440,13 @@ void ColorCalibrationAlgNode::get_color_id(std::string &color_id)
this->filter_mutex_exit();
}
void ColorCalibrationAlgNode::set_color_id(const std::string &color_id)
{
this->filter_mutex_enter();
this->color_id=color_id;
this->filter_mutex_exit();
}
/* main function */
// int main(int argc,char *argv[])
// {
......
......@@ -180,6 +180,8 @@ void MainGui::on_load_params_pressed(void)
yaml_file = QFileDialog::getOpenFileName(this,tr("Open YAML file"), "./", tr("YAML Files (*.yaml)"));
this->ui->params_file->setText(yaml_file);
this->node->load_params(yaml_file.toUtf8().constData());
this->ui->pixel_list->clearContents();
this->ui->pixel_list->setRowCount(0);
this->show_filter_params();
}
......@@ -192,6 +194,11 @@ void MainGui::on_save_params_pressed(void)
this->node->save_params(yaml_file.toUtf8().constData());
}
void MainGui::on_color_id_value_textChanged(const QString &new_value)
{
this->node->set_color_id(new_value.toUtf8().constData());
}
void MainGui::show_filter_params(void)
{
unsigned int h_center,h_window,s_center,s_window,v_center,v_window;
......
......@@ -376,8 +376,6 @@
<header>image_label.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../resources/images.qrc"/>
</resources>
<resources/>
<connections/>
</ui>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment