[Jderobot-admin] jderobot-r915 - trunk/src/components/calibrator

agallardo en jderobot.org agallardo en jderobot.org
Dom Mayo 12 23:06:24 CEST 2013


Author: agallardo
Date: 2013-05-12 23:05:23 +0200 (Sun, 12 May 2013)
New Revision: 915

Modified:
   trunk/src/components/calibrator/calibrator.cfg
   trunk/src/components/calibrator/calibrator.glade
   trunk/src/components/calibrator/module_dlt.cpp
   trunk/src/components/calibrator/module_extrinsics.cpp
   trunk/src/components/calibrator/module_extrinsics.h
   trunk/src/components/calibrator/module_rectifier.cpp
   trunk/src/components/calibrator/view.cpp
   trunk/src/components/calibrator/view.h
Log:


Modified: trunk/src/components/calibrator/calibrator.cfg
===================================================================
--- trunk/src/components/calibrator/calibrator.cfg	2013-05-09 10:38:13 UTC (rev 914)
+++ trunk/src/components/calibrator/calibrator.cfg	2013-05-12 21:05:23 UTC (rev 915)
@@ -1,6 +1,6 @@
-Calibrator.Camera.Proxy=cameraB:tcp -h 0.0.0.0 -p 9999
+Calibrator.Camera.Proxy=cameraA:tcp -h 0.0.0.0 -p 9999
 #Calibrator.Camera.FileOut=./config-example/cam-out
-Calibrator.World.File=./config-example/mundoTest.cal
+Calibrator.World.File=./config-example/robotics-lab
 
 #Extrinsics, position
 Calibrator.Config.Position.X=215

Modified: trunk/src/components/calibrator/calibrator.glade
===================================================================
--- trunk/src/components/calibrator/calibrator.glade	2013-05-09 10:38:13 UTC (rev 914)
+++ trunk/src/components/calibrator/calibrator.glade	2013-05-12 21:05:23 UTC (rev 915)
@@ -106,7 +106,7 @@
                           </packing>
                         </child>
                         <child>
-                          <widget class="GtkButton" id="button_load_world">
+                          <widget class="GtkButton" id="load_world_button">
                             <property name="label" translatable="yes">Load World</property>
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
@@ -119,6 +119,32 @@
                           </packing>
                         </child>
                         <child>
+                          <widget class="GtkButton" id="save_calibration_button">
+                            <property name="label" translatable="yes">Save calibration  matrix</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">True</property>
+                          </widget>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">2</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <widget class="GtkButton" id="load_calibration_button">
+                            <property name="label" translatable="yes">Load calibration matrix</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">True</property>
+                          </widget>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">3</property>
+                          </packing>
+                        </child>
+                        <child>
                           <placeholder/>
                         </child>
                       </widget>
@@ -560,6 +586,8 @@
                         <child>
                           <widget class="GtkImage" id="dlt_image">
                             <property name="visible">True</property>
+                            <property name="xalign">0</property>
+                            <property name="yalign">0</property>
                             <property name="stock">gtk-missing-image</property>
                           </widget>
                         </child>

Modified: trunk/src/components/calibrator/module_dlt.cpp
===================================================================
--- trunk/src/components/calibrator/module_dlt.cpp	2013-05-09 10:38:13 UTC (rev 914)
+++ trunk/src/components/calibrator/module_dlt.cpp	2013-05-12 21:05:23 UTC (rev 915)
@@ -963,23 +963,23 @@
 gboolean Module_DLT::on_button_press_image(GdkEventButton* event)
 {
 
-/*
+
 	if (this->getCounterPointsImage() < NUM_POINTSS){
 
 		int x = event->x;
 		int y = event->y;
 		std::cout << "PRESS " << x << " " << y << std::endl;
 
-		this->controllerCamera2->points_image[this->controllerCamera2->getCounterPointsImage()].x = event->x; 
-		this->controllerCamera2->points_image[this->controllerCamera2->getCounterPointsImage()].y = event->y;
+		this->points_image[this->getCounterPointsImage()].x = event->x; 
+		this->points_image[this->getCounterPointsImage()].y = event->y;
 	
-		this->controllerCamera2->counter_points_image++;
+		this->counter_points_image++;
 
 		return TRUE;
 	}else{
 		std::cout << "Clear the buffer" << std::endl;
 	}
-*/
+/*
 	int mark[NUM_POINTSS*2] = {
 				173, 87
 				,160,82
@@ -1021,9 +1021,8 @@
 		this->points_image[this->getCounterPointsImage()].y = mark[i*2+1];
 	
 		this->counter_points_image++;
-
-
 	}
+*/
 }
 
 void Module_DLT::on_capture_button_clicked()

Modified: trunk/src/components/calibrator/module_extrinsics.cpp
===================================================================
--- trunk/src/components/calibrator/module_extrinsics.cpp	2013-05-09 10:38:13 UTC (rev 914)
+++ trunk/src/components/calibrator/module_extrinsics.cpp	2013-05-12 21:05:23 UTC (rev 915)
@@ -132,6 +132,32 @@
 		return this->camera;
 	}
 
+	void Module_Extrinsics::setCam(TPinHoleCamera camera){
+
+		setPos(camera.position.X, camera.position.Y, camera.position.Z);
+		setFoa(camera.foa.X, camera.foa.Y, camera.foa.Z);
+		setFdistX(camera.fdistx);
+		setFdistY(camera.fdisty);
+		setU0(camera.u0);
+		setV0(camera.v0);	
+		setRoll(camera.roll);
+
+		update_camera_matrix(&(this->camera));
+
+		vscale_pos_x->set_value((double)this->getPos()->X);
+		vscale_pos_y->set_value((double)this->getPos()->Y);
+		vscale_pos_z->set_value((double)this->getPos()->Z);
+		vscale_foa_x->set_value((double)this->getFoa()->X);
+		vscale_foa_y->set_value((double)this->getFoa()->Y);
+		vscale_foa_z->set_value((double)this->getFoa()->Z);		
+		vscale_fx->set_value((double)this->getFdistX());
+		vscale_fy->set_value((double)this->getFdistY());
+		vscale_u0->set_value((double)this->getU0());
+		vscale_v0->set_value((double)this->getV0());
+		vscale_roll->set_value((double)this->getRoll());
+
+	}
+
 	void
 	Module_Extrinsics::changeDrawCenter() {
 		this->drawCenter = !this->drawCenter;	
@@ -146,7 +172,7 @@
 		/* initializes the 3D world */
 		worldconfig=fopen(this->world.c_str(),"r");
 		if(worldconfig==NULL){
-			cerr << "Calibrator: World configuration configuration file " << this->world << " does not exits" << endl;
+			cerr << "Calibrator: World configuration file " << this->world << " does not exits" << endl;
 		}else{
 			do{
 				i=load_world_line(worldconfig);
@@ -154,7 +180,7 @@
 			fclose(worldconfig);
 		}
 
-		this->load_world();
+		
 
 		/*Default values for camera parameters*/
 		this->camera.position.X = 0.;
@@ -180,13 +206,6 @@
 
 		update_camera_matrix(&(this->camera));
 
-		/*Load parameters from file*/
-		Ice::PropertyDict pd = prop->getPropertiesForPrefix("Calibrator.Config");
-		this->load_camera_config(pd);
-
-		/* for the undo operation be ready from the very beginning */
-		/*save_cam(cameraOUTfile);*/ 
-
 	}
 	
 	void Module_Extrinsics::resetLines(){
@@ -262,68 +281,8 @@
     		}
 
 	}
-
-	int
-	Module_Extrinsics::load_camera_config(Ice::PropertyDict pd) {
-
-		for(Ice::PropertyDict::const_iterator it = pd.begin(); it != pd.end(); it++) {
-
-			if((*it).first.compare("Calibrator.Config.Position.X")==0) {
-				this->camera.position.X=(float)atof((*it).second.c_str());
-				this->lastx = this->camera.position.X;
-			}
-			else if((*it).first.compare("Calibrator.Config.Position.Y")==0) {
-				this->camera.position.Y=(float)atof((*it).second.c_str());
-				this->lasty = this->camera.position.Y;
-			}
-			else if((*it).first.compare("Calibrator.Config.Position.Z")==0) {
-				this->camera.position.Z=(float)atof((*it).second.c_str());
-				this->lastz = this->camera.position.Z;
-			}
-			else if((*it).first.compare("Calibrator.Config.Position.H")==0) {
-				this->camera.position.H=(float)atof((*it).second.c_str());
-			} 
-			else if((*it).first.compare("Calibrator.Config.FOAPosition.X")==0) {
-				this->camera.foa.X=(float)atof((*it).second.c_str());
-			} 
-			else if((*it).first.compare("Calibrator.Config.FOAPosition.Y")==0) {
-				this->camera.foa.Y=(float)atof((*it).second.c_str());
-			} 
-			else if((*it).first.compare("Calibrator.Config.FOAPosition.Z")==0) {
-				this->camera.foa.Z=(float)atof((*it).second.c_str());
-			} 
-			else if((*it).first.compare("Calibrator.Config.FOAPosition.H")==0) {
-				this->camera.foa.H=(float)atof((*it).second.c_str());
-			} 
-			else if((*it).first.compare("Calibrator.Config.Roll")==0) {
-				this->camera.roll=(float)atof((*it).second.c_str());
-			} 
-			else if((*it).first.compare("Calibrator.Config.Fx")==0) {
-				this->camera.fdistx=(float)atof((*it).second.c_str());
-			} 
-			else if((*it).first.compare("Calibrator.Config.Fy")==0) {
-				this->camera.fdisty=(float)atof((*it).second.c_str());
-			} 
-			else if((*it).first.compare("Calibrator.Config.Skew")==0) {
-				this->camera.skew=(float)atof((*it).second.c_str());
-			} 
-			else if((*it).first.compare("Calibrator.Config.U0")==0) {
-				this->camera.u0=(float)atof((*it).second.c_str());
-			} 
-			else if((*it).first.compare("Calibrator.Config.V0")==0) {
-				this->camera.v0=(float)atof((*it).second.c_str());
-			} 
-			else if((*it).first.compare("Calibrator.Config.Columns")==0) {
-				this->camera.columns=(int)atof((*it).second.c_str());
-			} 
-			else if((*it).first.compare("Calibrator.Config.Rows")==0) {
-				this->camera.rows=(int)atof((*it).second.c_str());
-			} 
-		}
-	}
 	
-	int
-	Module_Extrinsics::load_world_line(FILE *myfile) {			
+	int Module_Extrinsics::load_world_line(FILE *myfile) {			
 
 		int limit = 256;		
 		char word1[limit],word2[limit],word3[limit],word4[limit],word5[limit];
@@ -382,179 +341,69 @@
 		}
 
 	}
-	
-	int Module_Extrinsics::saveParameters(const char* fileName){
-	    FILE* fp;
-        fp = fopen (fileName , "w");
-        if (fp == NULL) 
-            return -1;
-        else{
-            fprintf ( fp, "Calibrator.Camera.Proxy=cameraB:tcp -h 0.0.0.0 -p 9999\n" );
-            fprintf ( fp, "Calibrator.Camera.FileOut=./config-example/cam-out\n");
-            fprintf ( fp, "Calibrator.World.File=./config-example/calib-world\n");
-            
-            fprintf ( fp, "\n#Extrinsics, position\n");
-            fprintf ( fp, "Calibrator.Config.Position.X=%lf\n", this->camera.position.X);
-            fprintf ( fp, "Calibrator.Config.Position.Y=%lf\n", this->camera.position.Y );
-            fprintf ( fp, "Calibrator.Config.Position.Z=%lf\n", this->camera.position.Z );
-            fprintf ( fp, "Calibrator.Config.Position.H=%lf\n", this->camera.position.H );
-            
-            fprintf ( fp, "\n#Extrinsics, orientation\n");
-            fprintf ( fp, "Calibrator.Config.FOAPosition.X=%lf\n", this->camera.foa.X );
-            fprintf ( fp, "Calibrator.Config.FOAPosition.Y=%lf\n", this->camera.foa.Y );
-            fprintf ( fp, "Calibrator.Config.FOAPosition.Z=%lf\n", this->camera.foa.Z );
-            fprintf ( fp, "Calibrator.Config.FOAPosition.H=%lf\n", this->camera.foa.H );
-            
-            fprintf ( fp, "\n#Intrinsics\n");
-            fprintf ( fp, "Calibrator.Config.Fx=%lf\n",   this->camera.fdistx);
-            fprintf ( fp, "Calibrator.Config.Fy=%lf\n",   this->camera.fdisty);
-            fprintf ( fp, "Calibrator.Config.Skew=%lf\n", this->camera.skew);
-            fprintf ( fp, "Calibrator.Config.U0=%lf\n",   this->camera.u0 );
-            fprintf ( fp, "Calibrator.Config.V0=%lf\n",   this->camera.v0 );
-            fprintf ( fp, "Calibrator.Config.Columns=%d\n", this->camera.columns);
-            fprintf ( fp, "Calibrator.Config.Rows=%d\n", this->camera.rows);
-            fprintf ( fp, "Calibrator.Config.Roll=%lf\n", this->camera.roll);        
-        }
-        fclose(fp);
-            
-	    return 1;
-	}
 
-	int
-	Module_Extrinsics::load_world() {	
-/*
-		std::string filepath = "./config-example/world.xml";
 
-		try
-		{
-		  xmlpp::TextReader reader(filepath);
-
-			while(reader.read())
-		  {
-		    int depth = reader.get_depth();
-		    std::cout << "--- node ---" << std::endl;
-		    std::cout << "name: " << reader.get_name() << std::endl;
-		    std::cout << "depth: " << reader.get_depth() << std::endl;
-
-		    if(reader.has_value())
-		      std::cout << "value: '" << reader.get_value() << "'" << std::endl;
-		    else
-		      std::cout << "novalue" << std::endl;
-		  }
-
-		}
-		catch(const std::exception& ex)
-		{
-		  std::cout << "Exception caught: " << ex.what() << std::endl;
-		}
-*/
-	}
-
 /** Extrinsics **/
 void Module_Extrinsics::pos_x_changed(){
-		this->setPos((float)vscale_pos_x->get_value(), (float)vscale_pos_y->get_value(), (float)vscale_pos_z->get_value()); 
+		this->setPos((float)vscale_pos_x->get_value(), this->camera.position.Y, this->camera.position.Z); 
 		vscale_foa_x->set_value((double)this->getFoa()->X);
 		vscale_foa_y->set_value((double)this->getFoa()->Y);
 		vscale_foa_z->set_value((double)this->getFoa()->Z);
-		button_KRT_clicked();
+		
   }
 
 	void Module_Extrinsics::pos_y_changed(){
-		this->setPos((float)vscale_pos_x->get_value(), (float)vscale_pos_y->get_value(), (float)vscale_pos_z->get_value()); 
+		this->setPos(this->camera.position.X, (float)vscale_pos_y->get_value(), this->camera.position.Z); 
 		vscale_foa_x->set_value((double)this->getFoa()->X);
 		vscale_foa_y->set_value((double)this->getFoa()->Y);
 		vscale_foa_z->set_value((double)this->getFoa()->Z);
-		button_KRT_clicked();
+		
   }
 
 	void Module_Extrinsics::pos_z_changed(){
-		this->setPos((float)vscale_pos_x->get_value(), (float)vscale_pos_y->get_value(), (float)vscale_pos_z->get_value());
+		this->setPos(this->camera.position.X, this->camera.position.Y, (float)vscale_pos_z->get_value());
 		vscale_foa_x->set_value((double)this->getFoa()->X);
 		vscale_foa_y->set_value((double)this->getFoa()->Y);
 		vscale_foa_z->set_value((double)this->getFoa()->Z); 
-		button_KRT_clicked();
   }
 
 	void Module_Extrinsics::foa_x_changed(){
-		this->setFoa((float)vscale_foa_x->get_value(), (float)vscale_foa_y->get_value(), (float)vscale_foa_z->get_value());
-		button_KRT_clicked(); 
+		this->setFoa((float)vscale_foa_x->get_value(), this->camera.foa.Y, this->camera.foa.Z);
   }
 
 	void Module_Extrinsics::foa_y_changed(){
-		this->setFoa((float)vscale_foa_x->get_value(), (float)vscale_foa_y->get_value(), (float)vscale_foa_z->get_value()); 
-        button_KRT_clicked();
+		this->setFoa(this->camera.foa.X, (float)vscale_foa_y->get_value(), this->camera.foa.Z); 
   }
 
 	void Module_Extrinsics::foa_z_changed(){
-		this->setFoa((float)vscale_foa_x->get_value(), (float)vscale_foa_y->get_value(), (float)vscale_foa_z->get_value()); 
-        button_KRT_clicked();
+		this->setFoa(this->camera.foa.X, this->camera.foa.Y, (float)vscale_foa_z->get_value()); 
   }
 
 	void Module_Extrinsics::fx_changed(){
 		this->setFdistX((float)vscale_fx->get_value()); 
-		button_KRT_clicked();
   }
 
 	void Module_Extrinsics::fy_changed(){
-		this->setFdistY((float)vscale_fy->get_value()); 
-		button_KRT_clicked();
+		this->setFdistY((float)vscale_fy->get_value()); 		
   }
 
 	void Module_Extrinsics::u0_changed(){
 		this->setU0((float)vscale_u0->get_value()); 
-		button_KRT_clicked();
   }
 
 	void Module_Extrinsics::v0_changed(){
 		this->setV0((float)vscale_v0->get_value()); 
-		button_KRT_clicked();
   }
 
 	void Module_Extrinsics::roll_changed(){
 		this->setRoll((float)vscale_roll->get_value()); 
-		button_KRT_clicked();
   }
 
 	void Module_Extrinsics::button_center_clicked(){
 		this->changeDrawCenter();
   }
   
-  void Module_Extrinsics::button_save_clicked()
-  {
-	/* Implementar correctamente */
-      Gtk::FileChooserDialog dialog("Please choose a folder", Gtk::FILE_CHOOSER_ACTION_OPEN);
-      dialog.set_transient_for(*mainwindow);
-
-      //Add response buttons the the dialog:
-      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
-      dialog.add_button("Select", Gtk::RESPONSE_OK);
-
-      int result = dialog.run();
-
-      //Handle the response:
-      switch(result){
-        case(Gtk::RESPONSE_OK):
-        {
-          //std::cout << "Select clicked." << std::endl;
-          std::cout << "Folder selected: " << dialog.get_filename() << std::endl;
-          this->saveParameters(dialog.get_filename().data());
-          break;
-        }
-        case(Gtk::RESPONSE_CANCEL):
-        {
-          std::cout << "Cancel clicked." << std::endl;
-          break;
-        }
-        default:
-        {
-          std::cout << "Unexpected button clicked." << std::endl;
-          break;
-        }
-      }
-
-  }
-  
-    void Module_Extrinsics::button_Load_clicked(const char* filename)
+    void Module_Extrinsics::button_load_clicked(const char* filename)
     {
 
 		int i=0;
@@ -574,114 +423,9 @@
                 fclose(worldconfig);
                 }
 
-                this->load_world();
+                
     }
-  
-    void Module_Extrinsics::button_KRT_clicked(){
-        
 
-        TPinHoleCamera camera = this->getCam();
-        gchar *str;
-
-        
-        str = g_strdup_printf ("|\t%.1lf", camera.k11);
-        labelK[0].set_text(str); g_free (str);
-        str = g_strdup_printf ("%.1lf", camera.k12);
-        labelK[1].set_text(str); g_free (str);
-        str = g_strdup_printf ("%.1lf", camera.k13);
-        labelK[2].set_text(str); g_free (str);
-        str = g_strdup_printf ("%.1lf\t|", camera.k14);
-        labelK[3].set_text(str); g_free (str);
-        str = g_strdup_printf ("|\t%.1lf", camera.k21);
-        labelK[4].set_text(str); g_free (str);
-        str = g_strdup_printf ("%.1lf", camera.k22);
-        labelK[5].set_text(str); g_free (str);
-        str = g_strdup_printf ("%.1lf", camera.k23);
-        labelK[6].set_text(str); g_free (str);
-        str = g_strdup_printf ("%.1lf\t|", camera.k24);
-        labelK[7].set_text(str); g_free (str);
-        str = g_strdup_printf ("|\t%.1lf", camera.k31);
-        labelK[8].set_text(str); g_free (str);
-        str = g_strdup_printf ("%.1lf", camera.k32);
-        labelK[9].set_text(str); g_free (str);
-        str = g_strdup_printf ("%.1lf", camera.k33);
-        labelK[10].set_text(str); g_free (str);
-        str = g_strdup_printf ("%.1lf\t|", camera.k34);
-        labelK[11].set_text(str); g_free (str);
-        labelK[12].set_text("K Matrix");
-
-        m_table.attach(labelK[12],1 ,2 ,0, 1 );
-        m_table.attach(labelK[0] ,1 ,2 ,1, 2 );
-        m_table.attach(labelK[1] ,2 ,3 ,1, 2 );
-        m_table.attach(labelK[2] ,3 ,4 ,1, 2 );
-        m_table.attach(labelK[3] ,4 ,5 ,1, 2 );
-
-        m_table.attach(labelK[4] ,1 ,2 ,2 , 3 );
-        m_table.attach(labelK[5] ,2 ,3 ,2 , 3 );
-        m_table.attach(labelK[6] ,3 ,4 ,2 , 3 );
-        m_table.attach(labelK[7] ,4 ,5 ,2 , 3 );
-
-        m_table.attach(labelK[8] ,1 ,2 ,3 , 4 );
-        m_table.attach(labelK[9] ,2 ,3 ,3 , 4 );
-        m_table.attach(labelK[10] ,3 ,4 ,3 , 4 );
-        m_table.attach(labelK[11] ,4 ,5 ,3 , 4 );
-
-
-        str = g_strdup_printf ("|\t%.1lf", camera.rt11);
-        labelRT[0].set_text(str); g_free (str);
-        str = g_strdup_printf ("%.1lf", camera.rt12);
-        labelRT[1].set_text(str); g_free (str);
-        str = g_strdup_printf ("%.1lf", camera.rt13);
-        labelRT[2].set_text(str); g_free (str);
-        str = g_strdup_printf ("%.1lf\t|", camera.rt14);
-        labelRT[3].set_text(str); g_free (str);
-        str = g_strdup_printf ("|\t%.1lf", camera.rt21);
-        labelRT[4].set_text(str); g_free (str);
-        str = g_strdup_printf ("%.1lf", camera.rt22);
-        labelRT[5].set_text(str); g_free (str);
-        str = g_strdup_printf ("%.1lf", camera.rt23);
-        labelRT[6].set_text(str); g_free (str);
-        str = g_strdup_printf ("%.1lf\t|", camera.rt24);
-        labelRT[7].set_text(str); g_free (str);
-        str = g_strdup_printf ("|\t%.1lf", camera.rt31);
-        labelRT[8].set_text(str); g_free (str);
-        str = g_strdup_printf ("%.1lf", camera.rt32);
-        labelRT[9].set_text(str); g_free (str);
-        str = g_strdup_printf ("%.1lf", camera.rt33);
-        labelRT[10].set_text(str); g_free (str);
-        str = g_strdup_printf ("%.1lf\t|", camera.rt34);
-        labelRT[11].set_text(str); g_free (str);
-        labelRT[12].set_text("RT Matrix");
-
-        m_table.attach(labelRT[12],1 ,2 ,4, 5 );
-        m_table.attach(labelRT[0] ,1 ,2 ,5, 6 );
-        m_table.attach(labelRT[1] ,2 ,3 ,5, 6 );
-        m_table.attach(labelRT[2] ,3 ,4 ,5, 6 );
-        m_table.attach(labelRT[3] ,4 ,5 ,5, 6 );
-
-        m_table.attach(labelRT[4] ,1 ,2 ,6 , 7 );
-        m_table.attach(labelRT[5] ,2 ,3 ,6 , 7 );
-        m_table.attach(labelRT[6] ,3 ,4 ,6 , 7 );
-        m_table.attach(labelRT[7] ,4 ,5 ,6 , 7 );
-
-        m_table.attach(labelRT[8] ,1 ,2 ,7 , 8 );
-        m_table.attach(labelRT[9] ,2 ,3 ,7 , 8 );
-        m_table.attach(labelRT[10] ,3 ,4 ,7 , 8 );
-        m_table.attach(labelRT[11],4 ,5 ,7 , 8 );
-        
-        window->add(m_table);
-        window->show_all_children();
-        
-        printf("\tK Matrix:\n\t| %.1f\t%.1f\t%.1f\t%.1f\t|\n",camera.k11,camera.k12,camera.k13,camera.k14);
-        printf("\t| %.1f\t%.1f\t%.1f\t%.1f\t|\n",camera.k21,camera.k22,camera.k23,camera.k24);
-        printf("\t| %.1f\t%.1f\t%.1f\t%.1f\t|\n\n",camera.k31,camera.k32,camera.k33,camera.k34);
-        printf("\tR&T Matrix:\n\t| %.1f\t%.1f\t%.1f\t%.1f\t|\n",camera.rt11,camera.rt12,camera.rt13,camera.rt14);
-        printf("\t| %.1f\t%.1f\t%.1f\t%.1f\t|\n",camera.rt21,camera.rt22,camera.rt23,camera.rt24);
-        printf("\t| %.1f\t%.1f\t%.1f\t%.1f\t|\n",camera.rt31,camera.rt32,camera.rt33,camera.rt34);
-        printf("\t| %.1f\t%.1f\t%.1f\t%.1f\t|\n\n",camera.rt41,camera.rt42,camera.rt43,camera.rt44);
-        
-    }
-
 void Module_Extrinsics::get_widgets(Glib::RefPtr<Gnome::Glade::Xml> refXml){
 
 		refXml->get_widget("pos_x",vscale_pos_x);
@@ -699,21 +443,7 @@
 		refXml->get_widget("image_extrinsics",gtk_image);	
 		refXml->get_widget("button_center",button_center);	
 		refXml->get_widget("button_save",button_save);	
-			
-
-		/*Set default config--- It should be a function */
-		vscale_pos_x->set_value((double)this->getPos()->X);
-		vscale_pos_y->set_value((double)this->getPos()->Y);
-		vscale_pos_z->set_value((double)this->getPos()->Z);
-		vscale_foa_x->set_value((double)this->getFoa()->X);
-		vscale_foa_y->set_value((double)this->getFoa()->Y);
-		vscale_foa_z->set_value((double)this->getFoa()->Z);		
-		vscale_fx->set_value((double)this->getFdistX());
-		vscale_fy->set_value((double)this->getFdistY());
-		vscale_u0->set_value((double)this->getU0());
-		vscale_v0->set_value((double)this->getV0());
-		vscale_roll->set_value((double)this->getRoll());
-	
+				
 		/*Create callbacks*/
 		vscale_pos_x->signal_value_changed().connect(sigc::mem_fun(this,&Module_Extrinsics::pos_x_changed));
 		vscale_pos_y->signal_value_changed().connect(sigc::mem_fun(this,&Module_Extrinsics::pos_y_changed));
@@ -727,18 +457,6 @@
 		vscale_v0->signal_value_changed().connect(sigc::mem_fun(this,&Module_Extrinsics::v0_changed));
 		vscale_roll->signal_value_changed().connect(sigc::mem_fun(this,&Module_Extrinsics::roll_changed));
 		button_center->signal_clicked().connect(sigc::mem_fun(this,&Module_Extrinsics::button_center_clicked));
-		button_save->signal_clicked().connect(sigc::mem_fun(this,&Module_Extrinsics::button_save_clicked));
-		
-		/*RTHSDGFA EXSADWEATAWEF*/
-		m_table.resize(10,10);
-		window = NULL;
-		if(window!=NULL)
-			delete window;
-		
-		window = new Gtk::Window();
-		window->set_visible(true);
-		window->set_title("KRT");
-		button_KRT_clicked();
 }
 
 void Module_Extrinsics::set_mainwindow(Gtk::Window* mainwindow){

Modified: trunk/src/components/calibrator/module_extrinsics.h
===================================================================
--- trunk/src/components/calibrator/module_extrinsics.h	2013-05-09 10:38:13 UTC (rev 914)
+++ trunk/src/components/calibrator/module_extrinsics.h	2013-05-12 21:05:23 UTC (rev 915)
@@ -45,10 +45,11 @@
 			void get_widgets(Glib::RefPtr<Gnome::Glade::Xml> refXml);
 			void display(const colorspaces::Image& image);
 			TPinHoleCamera getCam();
+			void setCam(TPinHoleCamera camera);
 			void set_mainwindow(Gtk::Window* mainwindow);
 
 
-			void button_Load_clicked(const char* filename);
+			void button_load_clicked(const char* filename);
 
 		private:
 			#define IMAGE_WIDTH 320
@@ -74,9 +75,8 @@
 			void setV0(float value);	
 			void setRoll(float value);
 			void changeDrawCenter();
-			int saveParameters(const char* fileName);
-			int load_world();
 			int load_world_line(FILE *myfile);
+
 			void resetLines();
 
 			Gtk::VScale *vscale_pos_x;
@@ -99,12 +99,8 @@
 			Gtk::Window* window;
 			Gtk::Label labelK[13];
 			Gtk::Label labelRT[13];
-			Gtk::Table m_table;
 
-
 			void button_center_clicked();
-			void button_save_clicked();
-			void button_KRT_clicked();
 			void pos_x_changed();
 			void pos_y_changed();
 			void pos_z_changed();
@@ -117,10 +113,7 @@
 			void v0_changed();
 			void roll_changed();
 
-
-
 			void init(Ice::PropertiesPtr prop);
-			int load_camera_config(Ice::PropertyDict pd);
 			void drawLine(IplImage * src, HPoint3D pini, HPoint3D pend);
 
 

Modified: trunk/src/components/calibrator/module_rectifier.cpp
===================================================================
--- trunk/src/components/calibrator/module_rectifier.cpp	2013-05-09 10:38:13 UTC (rev 914)
+++ trunk/src/components/calibrator/module_rectifier.cpp	2013-05-12 21:05:23 UTC (rev 915)
@@ -321,7 +321,29 @@
 */
 void Module_Rectifier::drawSelectedPoints(int counter, Tpoint* points, guint8* buffer)
 {
+
+/*
+	CvPoint p, q;
+
+	/* Draw horizontal line 
 	for(int k=0;k<counter;k++){
+		/* Draw horizontal line 		
+		p.x = points[k].x-5;
+		p.y = points[k].y;
+		q.x = points[k].x+5;
+		q.y = points[k].y;
+		cvLine(&buffer, p, q, CV_RGB(0,0,0), 1, CV_AA, 0);
+
+		/* Draw vertical line 		
+		p.x = points[k].x;
+		p.y = points[k].y-5;
+		q.x = points[k].x;
+		q.y = points[k].y+5;
+		cvLine(&buffer, p, q, CV_RGB(0,0,0), 1, CV_AA, 0);
+
+	}
+*/
+	for(int k=0;k<counter;k++){
 		int height = points[k].y*IMAGE_WIDTH*3;
 		int width = points[k].x*3;
 		/* Draw horizontal line */

Modified: trunk/src/components/calibrator/view.cpp
===================================================================
--- trunk/src/components/calibrator/view.cpp	2013-05-09 10:38:13 UTC (rev 914)
+++ trunk/src/components/calibrator/view.cpp	2013-05-12 21:05:23 UTC (rev 915)
@@ -90,8 +90,8 @@
 
 		/* OpenGL World */
 		refXml->get_widget_derived("gl_world",world);
-		refXml->get_widget("button_load_world",button_Load_world);
-		button_Load_world->signal_clicked().connect(sigc::mem_fun(this,&View::button_Load_word_clicked));
+		refXml->get_widget("load_world_button",button_Load_world);
+		button_Load_world->signal_clicked().connect(sigc::mem_fun(this,&View::button_load_word_clicked));
 		
 
 		/* Update World OpenGl*/
@@ -107,6 +107,11 @@
 		refXml->get_widget("camera_combo",camera_set);
 		camera_set->set_model(m_refTreeModel);
 
+		/* Buttons */
+		refXml->get_widget("save_calibration_button",save_calibration_button);
+		refXml->get_widget("load_calibration_button",load_calibration_button);
+		save_calibration_button->signal_clicked().connect(sigc::mem_fun(this,&View::on_save_calibration_button_clicked));
+		load_calibration_button->signal_clicked().connect(sigc::mem_fun(this,&View::on_load_calibration_button_clicked));
 
 		camera_set->set_active(0);
 		camera_set->signal_changed().connect(sigc::mem_fun(this,&View::on_changed_camera_set));
@@ -133,11 +138,6 @@
 
 
 		mainwindow->show();
-/*
-		xmlReader(&camera, "/home/caupolican/robotica/newnewnew/trunk/src/components/calibrator/calibration.xml");
-		display_camerainfo(camera);
-		xmlWriter(camera, "/home/caupolican/robotica/newnewnew/trunk/src/components/calibrator/calibration2.xml");
-*/
 	}
 
 	View::~View() {
@@ -198,6 +198,7 @@
 		
 		/* Update information matrix */
 		std::stringstream labelString;
+		labelString.precision(4);
 		labelString << camera.k11;
 		k[0]->set_label(labelString.str());
 		labelString.str(""); labelString << camera.k12;
@@ -257,134 +258,12 @@
 		labelString.str(""); labelString << camera.rt44;
 		rt[15]->set_label(labelString.str());
 
-		/* Draw Camera */
-		world->draw_camera(10, 20, 1);
 
+		//world->draw_camera(10, 20, 1);
+
 		while (gtkmain.events_pending())
 			gtkmain.iteration();
 
-
-/* Module_Rectifier 
-
-		colorspaces::ImageRGB8 img_rgb84(image);//conversion will happen if needed
-		Glib::RefPtr<Gdk::Pixbuf> imgBuff4 = 
-		Gdk::Pixbuf::create_from_data((const guint8*)img_rgb84.data,
-			Gdk::COLORSPACE_RGB,
-			false,
-			8,
-			img_rgb84.width,
-			img_rgb84.height,
-			img_rgb84.step);
-
-		this->module_rectifier->gtkimage_notrectified->clear();
-		this->module_rectifier->gtkimage_notrectified->set(imgBuff3);
-
-
-		/* Image 
-		gtkimage_notrectified->clear(); 
-		gtkimage_notrectified->set(imgBuff4);
-		mybuffer_notrectified = imgBuff4->get_pixels();
-	
-		/* Rectified Image 
-		imgRectifiedBuff = imgBuff4->copy();
-		gtkimage_rectified->clear(); 
-		gtkimage_rectified->set(imgRectifiedBuff);
-		mybuffer_rectified = imgRectifiedBuff->get_pixels();
-
-
-		/* if the user have selected 4 points on each image the application rectify the second image 
-		if ((counter_points_image == NUM_POINTS_RECTIFIER) and (counter_points_image_rectified == NUM_POINTS_RECTIFIER)){
-
-			/* Calculate the solution matrix 
-			if (flag_resolved == false){
-				solve_equation_system();
-				flag_resolved = true;
-			}
-	  
-			/* Build the rectified image 
-			build_rectified_image(mybuffer_notrectified, mybuffer_rectified);
-
-		}
-
-		/* Draw selected points 
-		drawSelectedPoints(counter_points_image, points_image, mybuffer_notrectified);
-		drawSelectedPoints(counter_points_image_rectified, points_image_rectified, mybuffer_rectified);
-
-		/*Manage image
-		this->module_extrinsics2->drawWorld(image4);
-
-		/*Set image
-		colorspaces::ImageRGB8 img_rgb84(image4);//conversion will happen if needed
-		Glib::RefPtr<Gdk::Pixbuf> imgBuff4 = Gdk::Pixbuf::create_from_data((const guint8*)img_rgb84.data,
-				    Gdk::COLORSPACE_RGB,
-				    false,
-				    8,
-				    img_rgb84.width,
-				    img_rgb84.height,
-				    img_rgb84.step); 
-		gtk_image22->clear();
-		gtk_image22->set(imgBuff4);
-*/
-		/*Show window
-		this->module_dlt->displayFrameRate(fpslabel);
-		*/
-/*
-
-CvPoint pt1,pt2;
-			if (1){
-				colorspaces::ImageRGB8 img_rgb888(image);//conversion will happen if needed
-				Glib::RefPtr<Gdk::Pixbuf> imgBuff =  Gdk::Pixbuf::create_from_data((const guint8*) img_rgb888.data,Gdk::COLORSPACE_RGB,false,8,img_rgb888.width,img_rgb888.height,img_rgb888.step);    
-	    		gtk_image->clear();
-
-				/*si queremos pintar las lineas
-bool lines_rgb_active = true;
-				if (lines_rgb_active){
-					IplImage* src = cvCreateImage(cvSize(img_rgb888.width,img_rgb888.height), IPL_DEPTH_8U, 3);
-					memcpy((unsigned char *) src->imageData, &(img_rgb888.data[0]),img_rgb888.width*img_rgb888.height * 3);
-util->draw_room(src,0, world->lines, world->numlines);
-					memmove(&(img_rgb888.data[0]),(unsigned char *) src->imageData,img_rgb888.width*img_rgb888.height * 3);
-					
-				}
-gtk_image->set(imgBuff);
-//	    		displayFrameRate();
-	    		while (gtkmain.events_pending())
-	      		gtkmain.iteration();
-			}
-
-			if (1){
-	
-//				colorspaces::ImageRGB8 img_rgb888(imageDEPTH);//conversion will happen if needed
-colorspaces::ImageRGB8 img_rgb888(image);//conversion will happen if needed
-				Glib::RefPtr<Gdk::Pixbuf> imgBuff =  Gdk::Pixbuf::create_from_data((const guint8*) img_rgb888.data,Gdk::COLORSPACE_RGB,false,8,img_rgb888.width,img_rgb888.height,img_rgb888.step);    
-//	    		w_imageDEPTH->clear();
-gtk_patron->clear();
-bool lines_depth_active = true;
-				if (lines_depth_active){
-					IplImage* src = cvCreateImage(cvSize(img_rgb888.width,img_rgb888.height), IPL_DEPTH_8U, 3);
-					memcpy((unsigned char *) src->imageData, &(img_rgb888.data[0]),img_rgb888.width*img_rgb888.height * 3);
-					util->draw_room(src,1, world->lines, world->numlines);
-					memmove(&(img_rgb888.data[0]),(unsigned char *) src->imageData,img_rgb888.width*img_rgb888.height * 3);
-					
-				}
-//	    		w_imageDEPTH->set(imgBuff);
-gtk_patron->set(imgBuff);
-//	    		displayFrameRate();
-*/
-	    		while (gtkmain.events_pending())
-	      		gtkmain.iteration();
-/*
-			}
-
-bool reconstruct_depth_activate = true;
-			if (reconstruct_depth_activate){
-				add_depth_points(imageDEPTH, imageRGB);
-				//reconstruct_depth_activate=false;
-			}
-*/
-
-
-
-		//mainwindow->resize(1,1);
 	}
 
 int View::get_active_camera(){
@@ -431,9 +310,71 @@
 		std::cout << "Camara activa " << active_camera << std::endl;
 	}
 
-	void View::button_Load_word_clicked()
-	{
+	void View::on_save_calibration_button_clicked(){
+		Gtk::FileChooserDialog dialog("Please choose a calibration file", Gtk::FILE_CHOOSER_ACTION_SAVE);
+		dialog.set_transient_for(*mainwindow);
 
+		//Add response buttons the the dialog:
+		dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
+		dialog.add_button("Save", Gtk::RESPONSE_OK);
+
+		int result = dialog.run();
+
+		//Handle the response:
+		switch(result){
+			case(Gtk::RESPONSE_OK):{
+				display_camerainfo(camera);
+				xmlWriter(camera, dialog.get_filename().data());
+				break;
+			}
+
+			case(Gtk::RESPONSE_CANCEL):{
+				std::cout << "Cancel clicked." << std::endl;
+				break;
+			}
+
+			default:{
+				std::cout << "Unexpected button clicked." << std::endl;
+				break;
+			}
+		}
+	}
+
+	void View::on_load_calibration_button_clicked(){
+		Gtk::FileChooserDialog dialog("Please choose a calibration file", Gtk::FILE_CHOOSER_ACTION_OPEN);
+		dialog.set_transient_for(*mainwindow);
+
+		//Add response buttons the the dialog:
+		dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
+		dialog.add_button("Load", Gtk::RESPONSE_OK);
+
+		int result = dialog.run();
+
+		//Handle the response:
+		switch(result){
+			case(Gtk::RESPONSE_OK):{
+
+				display_camerainfo(camera);
+				xmlReader(&camera, dialog.get_filename().data());
+				display_camerainfo(camera);
+
+				// Actualizar componente extrinsics
+				this->module_extrinsics->setCam(camera);
+				break;
+			}
+			case(Gtk::RESPONSE_CANCEL):{
+				std::cout << "Cancel clicked." << std::endl;
+				break;
+			}
+			default:{
+				std::cout << "Unexpected button clicked." << std::endl;
+				break;
+			}
+		}
+	}
+
+	void View::button_load_word_clicked()
+	{
 		int i=0;
 		FILE *worldconfig;
 
@@ -449,17 +390,14 @@
 		//Handle the response:
 		switch(result){
 			case(Gtk::RESPONSE_OK):{
-
-				this->module_extrinsics->button_Load_clicked(dialog.get_filename().data());
-				world->readFile(dialog.get_filename());
+				this->module_extrinsics->button_load_clicked(dialog.get_filename().data());
+				world->readFile(dialog.get_filename());				
 				break;
 			}
-
 			case(Gtk::RESPONSE_CANCEL):{
 				std::cout << "Cancel clicked." << std::endl;
 				break;
 			}
-
 			default:{
 				std::cout << "Unexpected button clicked." << std::endl;
 				break;

Modified: trunk/src/components/calibrator/view.h
===================================================================
--- trunk/src/components/calibrator/view.h	2013-05-09 10:38:13 UTC (rev 914)
+++ trunk/src/components/calibrator/view.h	2013-05-12 21:05:23 UTC (rev 915)
@@ -87,6 +87,8 @@
 		Gtk::Table* estereo_panel;
 		Gtk::ComboBox* camera_set;
 		Gtk::Button* button_Load_world;
+		Gtk::Button* save_calibration_button;
+		Gtk::Button* load_calibration_button;
 
 		int active_camera;
 
@@ -102,7 +104,9 @@
 		void on_toggled_rectifier();
 		void on_toggled_estereo();
 		void on_changed_camera_set();
-		void button_Load_word_clicked();
+		void button_load_word_clicked();
+		void on_save_calibration_button_clicked();
+		void on_load_calibration_button_clicked();
 
 		Module_DLT * module_dlt;
 		Module_Extrinsics * module_extrinsics;



More information about the Jderobot-admin mailing list