System::System(uint VE,uint ent,uint sal):System(){ setDimenciones(VE,ent,sal); uint fil[mat::MATRIX_NO]={n,n,p,p,n,n,n ,n*p,0,0}; uint col[mat::MATRIX_NO]={n,m,n,m,n,m,n*m,n ,0,0}; for (int i = 0; i <= mat::Psi; i++){ if ( fil[i] != 0 ){ Mat *new_mat = new Mat(fil[i],col[i],CV_64FC1,0.0); setMat( static_cast<mat>(i) ,new_mat); } } }
void MapManager::createFromTexture( GLuint texture ) { GLint width, height, glFormat; int depth=0, channels=0, type; glBindTexture(GL_TEXTURE_2D, texture); glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width); glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &height); glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &glFormat); switch(glFormat) { case GL_RGB8: depth = CV_8U; channels = 3; break; case GL_RGBA8: depth = CV_8U; channels = 4; break; case GL_RGB16: depth = CV_16U; channels = 3; break; case GL_RGBA16: depth = CV_16U; channels = 4; break; default: qDebug() << "Unsupported texture format"; return; break; } type = (depth == CV_8U)? ((channels == 3)?CV_8UC3:CV_8UC4): ((channels == 3)?CV_16UC3:CV_16UC4); cv::Mat newMat(height, width, type); glGetTexImage(GL_TEXTURE_2D,0, (channels == 3)?GL_BGR_EXT:GL_BGRA_EXT, (depth == CV_8U)?GL_UNSIGNED_BYTE:GL_UNSIGNED_SHORT, newMat.data); m_fileName.clear(); resetHistory(); setMat(newMat); }