void Controller::process_request(){ if(this->_property_manager->_flag_requests[PropertyManager::R_FLOOR_AREA]){ if(this->_aux_points->size() > 2){ Floor *floor = new Floor(); floor->set_area(this->_aux_points); this->add_floor(floor); this->_gui->update_floor_manager(); } this->_property_manager->_flag_requests[PropertyManager::R_FLOOR_AREA] = false; } if(this->_property_manager->_flag_requests[PropertyManager::R_FLOOR_POINTS]){ double a,b,c,d; //if(this->_kinect->get_floor_plane(&a,&b,&c,&d)){ // printf("%f, %f, %f, %f\n",a,b,c,d); // this->_floor->set_plane(a,b,c,d); // this->_property_manager->_flag_processed[PropertyManager::P_FLOOR_PLANE] = true; // //cv::destroyWindow("Add Floor"); //} //else{ if(this->_aux_points->size() > 2){ std::vector<cv::Point3f*> points3d; XnPoint3D *points_in = (XnPoint3D*)malloc(sizeof(XnPoint3D) * _aux_points->size()); XnPoint3D *points_out = (XnPoint3D*)malloc(sizeof(XnPoint3D) * _aux_points->size()); UINT16* ptr_16u = (UINT16*)this->_mat_depth16UC1.data; for(int i = 0 ; i < _aux_points->size() ; ++i){ points_in[i].X = _aux_points->at(i)->x; points_in[i].Y = _aux_points->at(i)->y; points_in[i].Z = ptr_16u[((int)points_in[i].Y) * XN_VGA_X_RES + ((int)points_in[i].X)]; } if(! this->_kinect->convert_to_realworld(_aux_points->size(),points_in,points_out)){ this->_property_manager->_flag_processed[PropertyManager::P_FLOOR_PLANE] = false; } else{ for(int i = 0 ; i < _aux_points->size() ; ++i){ points3d.push_back(new cv::Point3f(points_out[i].X,points_out[i].Y,points_out[i].Z)); } ToolBoxPCL::calc_plane_from_points(&points3d,&a,&b,&c,&d,1); this->_floor->set_plane(a,b,c,d); this->_gui->update_floor_manager(); this->_property_manager->_flag_processed[PropertyManager::P_FLOOR_PLANE] = true; } } else{ this->_property_manager->_flag_processed[PropertyManager::P_FLOOR_PLANE] = false; } //} this->_property_manager->_flag_requests[PropertyManager::R_FLOOR_POINTS] = false; } if(this->_property_manager->_flag_requests[PropertyManager::R_MIRROR_AREA]){ if(this->_aux_points->size() > 2){ Mirror *mirror = new Mirror(); mirror->set_area(this->_aux_points); this->add_mirror(mirror); this->_gui->update_mirror_manager(); //this->_gui->point_selection(3); } this->_property_manager->_flag_requests[PropertyManager::R_MIRROR_AREA] = false; } if(this->_property_manager->_flag_requests[PropertyManager::R_MIRROR_POINTS]){ if(this->_aux_points->size() > 2){ Mirror *mirror = this->_mirrors[this->_mirrors.size()-1]; std::vector<cv::Point3f*> points3d; XnPoint3D *points_in = (XnPoint3D*)malloc(sizeof(XnPoint3D) * this->_aux_points->size()); XnPoint3D *points_out = (XnPoint3D*)malloc(sizeof(XnPoint3D) * this->_aux_points->size()); UINT16* ptr_16u = (UINT16*)this->_mat_depth16UC1.data; for(int i = 0 ; i < this->_aux_points->size() ; ++i){ if(ptr_16u[this->_aux_points->at(i)->y * XN_VGA_X_RES + this->_aux_points->at(i)->x] > 1){ points_in[i].X = this->_aux_points->at(i)->x; points_in[i].Y = this->_aux_points->at(i)->y; points_in[i].Z = ptr_16u[((int)points_in[i].Y) * XN_VGA_X_RES + ((int)points_in[i].X)]; } } if(! this->_kinect->convert_to_realworld(this->_aux_points->size(),points_in,points_out)){ this->_property_manager->_flag_processed[PropertyManager::P_MIRROR] = false; } else{ for(int i = 0 ; i < this->_aux_points->size() ; ++i){ points3d.push_back(new cv::Point3f(points_out[i].X,points_out[i].Y,points_out[i].Z)); } double a,b,c,d; if(ToolBoxPCL::calc_plane_from_points(&points3d,&a,&b,&c,&d,1)){ mirror->set_plane(a,b,c,d); //this->add_mirror(mirror); this->_property_manager->_flag_processed[PropertyManager::P_MIRROR] = true; this->_gui->update_mirror_manager(); } else{ this->_property_manager->_flag_processed[PropertyManager::P_MIRROR] = false; } } } else{ this->_property_manager->_flag_processed[PropertyManager::P_MIRROR] = false; } } if(this->_property_manager->_flag_requests[PropertyManager::R_SAVE]){ this->save_to_file("..\\data\\config","arena"); this->_property_manager->_flag_requests[PropertyManager::R_SAVE] = false; } if(this->_property_manager->_flag_requests[PropertyManager::R_LOAD]){ this->load_from_file("..\\data\\config\\arena.xml"); this->_gui->update_mirror_manager(); this->_property_manager->_flag_processed[PropertyManager::P_MIRROR] = true; this->_property_manager->_flag_processed[PropertyManager::P_FLOOR_PLANE] = true; this->_property_manager->_flag_requests[PropertyManager::R_LOAD] = false; } if(this->_property_manager->_flag_requests[PropertyManager::R_CAPTURE]){ this->_model_frames_depth.clear(); this->_model_frames_color.clear(); this->_model_cloud.clear(); this->_model_n_points = 0; this->_property_manager->_flag_processed[PropertyManager::P_CAPTURE] = true; this->_property_manager->_flag_requests[PropertyManager::R_CAPTURE] = false; } if(this->_property_manager->_flag_requests[PropertyManager::R_SAVE_PCL]){ if(this->_property_manager->_flag_update[PropertyManager::U_PCL]){ pcl::PointCloud<pcl::PointXYZRGB> cloud; if(this->_property_manager->_flag_processed[PropertyManager::P_CAPTURE_SHOW]){ //Model Point Cloud cloud = this->_model_cloud; } else{ //Current Point Cloud cloud = this->_pcl_cloud; } if(this->_property_manager->_save_pcl_mode == 1){ ToolBoxPCL::write_to_pcd_file(cloud,this->_property_manager->_file_name); } else if(this->_property_manager->_save_pcl_mode == 2){ ToolBoxPCL::write_to_ply_file(cloud,this->_property_manager->_file_name); }else if(this->_property_manager->_save_pcl_mode == 3){ ToolBoxPCL::write_to_obj_file(cloud,this->_property_manager->_file_name); } this->_property_manager->_flag_requests[PropertyManager::R_SAVE_PCL] = false; } } this->_property_manager->_flag_requests[PropertyManager::R_REQUEST] = false; }