void Main::cmdReceivedCB(const std_msgs::CharConstPtr & cmd) { switch (cmd->data) { case 'b': clearBackground(); break; case 'c': stopTracking(); break; case 'l': toggleLearning(); break; case 'a': alternatingMode(); break; case 'e': exportModel(); break; case 'i': importModel(); break; case 'r': reset(); break; case 'v': sendCenterView(); break; default: break; } }
//void Main::cmdReceivedCB(const std_msgs::CharConstPtr & cmd) void Main::cmdReceivedCB(const std_msgs::StringConstPtr & cmd) { char cd=cmd->data.c_str()[0]; //switch (cmd->data) switch (cd) { case 'b': clearBackground(); break; case 'c': stopTracking(); break; case 'l': toggleLearning(); break; case 'a': alternatingMode(); break; case 'e': exportModel(); break; case 'i': importModel(); break; case 'r': reset(); break; default: break; } }
bool Obj::loadFromFile(FILE *f) { fp = f; if (importModel(&OBJModel) == false) { error("OBJ file not loaded"); return false; } if (importTextures() == false) warning("textures of OBJ file not loaded"); return loaded = true; //success }
void AELoadedResourcesTreeView::createActions() { _importModelAct = new QAction(tr("Import &model"), _contextMenu); _importModelAct->setStatusTip(tr("Import a new model into the resources")); connect(_importModelAct, SIGNAL(triggered()), this, SLOT(importModel())); _importTextureAct = new QAction(tr("Import &texture"), _contextMenu); _importTextureAct->setStatusTip(tr("Import a new texture into the resources")); connect(_importTextureAct, SIGNAL(triggered()), this, SLOT(importTexture())); _addNewMaterialAct = new QAction(tr("Add new m&aterial"), _contextMenu); _addNewMaterialAct->setStatusTip(tr("Add a new material to the resources")); connect(_addNewMaterialAct, SIGNAL(triggered()), this, SLOT(addNewMaterial())); _createModelInstanceAct = new QAction(tr("Create instance"), _contextMenu); _createModelInstanceAct->setStatusTip(tr("Creates a new instance of the selected model")); connect(_createModelInstanceAct, SIGNAL(triggered()), this, SLOT(createModelInstance())); }
/* * \brief Constructor of the model class. Import the model and the three textures and prepare the buffers. * \param[in] name a string containing the name of the model * \param[in] fModele a const character array containing the path of the file of the model * \param[in] fTex a const character array containing the path of the file of the diffuse color texture * \param[in] fNormalmap a const character array containing the path of the file of the normalmap texture * \param[in] fSpecularmap a const character array containing the path of the file of the specular color texture * \return A well initialized model respecting the parameters */ Model::Model(std::string name, const GLchar * fModele, const GLchar * fTex, const GLchar * fNormalmap, const char * fSpecularmap) : Object() { m_name = name; m_texture_id.push_back(0); m_texture_id.push_back(0); m_texture_id.push_back(0); glGenTextures(3, &m_texture_id[0]); if (!importModel(fModele)) { throw ModelImportException(); } if (!importTexture(fTex, 0)) { throw TextureImportException(); } if (!importTexture(fNormalmap, 1)) { throw NormalmapImportException(); } if (!importTexture(fSpecularmap, 2)) { throw SpecularmapImportException(); } computeTangentSpace(); indexBuffers(); glBindBuffer(GL_ARRAY_BUFFER, m_buffer_id[0]); glBufferData(GL_ARRAY_BUFFER, m_vertices.size() * sizeof(glm::vec3), &m_vertices[0], GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, m_buffer_id[1]); glBufferData(GL_ARRAY_BUFFER, m_uvs.size() * sizeof(glm::vec2), &m_uvs[0], GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, m_buffer_id[2]); glBufferData(GL_ARRAY_BUFFER, m_normals.size() * sizeof(glm::vec3), &m_normals[0], GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, m_buffer_id[3]); glBufferData(GL_ARRAY_BUFFER, m_tangents.size() * sizeof(glm::vec3), &m_tangents[0], GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, m_buffer_id[4]); glBufferData(GL_ARRAY_BUFFER, m_bitangents.size() * sizeof(glm::vec3), &m_bitangents[0], GL_STATIC_DRAW); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_buffer_id[5]); glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_indexes.size() * sizeof(GLushort), &m_indexes[0], GL_STATIC_DRAW); }
int main(int argc, char* argv[]){ int c, i; char *inputImageFile = NULL; char *inputLabelFile = NULL; char *inputModel = "noname.model"; char *outputResult = "result.txt"; while( (c=getopt(argc, argv, "i:y:m:o:h")) != -1 ){ switch(c) { case 'h': printf("usage: \n-i input image file\n-m inputModel\n-o outputResult\n-y (optional)input label file\n\tif provided, it calculate accuracy immediately.\n"); break; case 'i': inputImageFile = optarg; break; case 'y': inputLabelFile = optarg; break; case 'm': inputModel = optarg; break; case 'o': outputResult = optarg; break; case '?': printf("Illegal option\n"); printf("usage: \n-i input image file\n-m inputModel\n-o outputResult\n-y (optional)input label file\n\tif provided, it calculate accuracy immediately.\n"); exit(1); break; default: printf("usage: \n-i input image file\n-m inputModel\n-o outputResult\n-y (optional)input label file\n\tif provided, it calculate accuracy immediately.\n"); exit(1); break; } } int test_num ; double **test_x = mnist_load_data(inputImageFile, &test_num); int dim = 28 * 28; // supposed data dimension // normalization parameters double* mean = (double*) malloc( dim * sizeof(double)); double* sigma = (double*) malloc( dim * sizeof(double)); // load from model NN* mm = importModel(mean, sigma, inputModel); normalize_zscore_apply(test_x, test_num, mean, sigma, dim); if(inputLabelFile != NULL){ double **test_y = mnist_load_labels(inputLabelFile, &test_num); double errorRate = nneval(mm, test_num, (const double**)test_x, (const double**) test_y); printf("Error rate=%f\n", errorRate); } // write result FILE* fp = fopen(outputResult, "w"); for(i=0; i< test_num; i++){ fprintf(fp, "%d\n", nnpredict(mm, i, (const double**)test_x) ); } fclose(fp); return 0; }
/*! slot for opening the contextmenu */ void Item_node::contextmenu(const QPoint& point){ context = this; if(!menuinit){ DQMENU(Item_node, menu); menu->addAction( QIcon(":/images/xpm/armature.xpm"), QString("Add Armature") , this, SLOT( addArmature())); menu->addSeparator(); menu->addAction( QIcon( ":/images/xpm/importer.xpm"), QString("Import Model"), this, SLOT(importModel()) ); menu->addSeparator(); SCRIPT2MENU(menu); menu->addSeparator(); menu->addAction( QIcon( ":/images/xpm/del.xpm"), QString("Delete") , this, SLOT( deleteLater())); menuinit = true; } menu->popup( point ); }