Changeset 2679


Ignore:
Timestamp:
05/15/08 16:00:23 (16 years ago)
Author:
mattausch
Message:

found error with qglpixelbuffer

Location:
GTP/trunk/Lib/Vis/Preprocessing
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_vps.sh

    r2677 r2679  
    2828-preprocessor=gvs \ 
    2929-gvs_epsilon=0.0001 \ 
    30 -gvs_total_samples=1000000 \ 
    31 -gvs_samples_per_pass=1000000 \ 
     30-gvs_total_samples=100000 \ 
     31-gvs_samples_per_pass=100000 \ 
    3232-gvs_initial_samples=16 \ 
    33 -gvs_max_viewcells=20 \ 
     33-gvs_max_viewcells=1 \ 
    3434-gvs_min_contribution=50 \ 
    3535-gvs_per_viewcell=true \ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp

    r2678 r2679  
    10221022GlRendererBuffer::EvalPvsStat() 
    10231023{ 
    1024         MakeLive(); 
     1024        //MakeLive(); 
    10251025         
    10261026        GlRenderer::EvalPvsStat(); 
    10271027         
    1028         DoneLive(); 
     1028        //DoneLive(); 
    10291029        // mRenderingFinished.wakeAll(); 
    10301030} 
     
    10331033void GlRendererBuffer::EvalPvsStat(const SimpleRayContainer &viewPoints) 
    10341034{ 
    1035         MakeLive(); 
     1035        //MakeLive(); 
    10361036 
    10371037        GlRenderer::EvalPvsStat(viewPoints); 
    10381038   
    1039         DoneLive(); 
     1039        //DoneLive(); 
    10401040} 
    10411041 
     
    14761476GlRenderer::EvalPvsStat() 
    14771477{ 
    1478   mPvsStat.Reset(); 
    1479   halton.Reset(); 
    1480  
    1481   SetupProjection(GetWidth(), GetHeight()); 
    1482  
    1483   cout << "Random Pvs STATS, mPvsStatFrames=" << mPvsStatFrames << endl; 
    1484    
    1485   for (int i=0; i < mPvsStatFrames; i++) { 
    1486         float err; 
    1487         // set frame id for saving the error buffer 
    1488         mFrame = i; 
    1489  
    1490         //      cerr<<"RV"<<endl; 
    1491         RandomViewPoint(); 
    1492         //      cerr<<"RV2"<<endl; 
    1493  
    1494         if (mPvsErrorBuffer[i].mError == 1.0f) { 
    1495           // check if the view point is valid 
    1496           if (!ValidViewPoint()) { 
    1497                 mPvsErrorBuffer[i].mError = -1.0f; 
    1498           } 
    1499  
    1500           // manualy corrected view point 
    1501           if (mFrame == 5105) 
    1502                 mPvsErrorBuffer[i].mError = -1.0f; 
    1503         } 
    1504  
    1505  
    1506         if (mPvsErrorBuffer[i].mError > 0.0f) { 
    1507                 int pvsSize; 
    1508  
    1509                 float error = GetPixelError(pvsSize); 
    1510  
    1511                 mPvsErrorBuffer[i].mError = error; 
    1512                 mPvsErrorBuffer[i].mPvsSize = pvsSize; 
    1513  
    1514                 //cout<<"("<<i<<" ["<<mViewPoint<<"]["<<mViewDirection<<"] "<<mPvsErrorBuffer[i].mError<<")"; 
    1515         } 
    1516  
    1517         err = mPvsErrorBuffer[i].mError; 
    1518          
    1519         if (err >= 0.0f) { 
    1520           if (err > mPvsStat.maxError) 
    1521                 mPvsStat.maxError = err; 
    1522           mPvsStat.sumError += err; 
    1523           mPvsStat.sumPvsSize += mPvsErrorBuffer[i].mPvsSize; 
    1524            
    1525           if (err == 0.0f) 
    1526                 mPvsStat.errorFreeFrames++; 
    1527           mPvsStat.frames++; 
    1528         } 
    1529   } 
    1530    
    1531   glFinish(); 
    1532  
    1533   static bool first = true; 
    1534   if (first) { 
    1535          
    1536  
    1537         bool exportRandomViewCells; 
    1538         Environment::GetSingleton()->GetBoolValue("ViewCells.exportRandomViewCells", 
    1539                                                                                           exportRandomViewCells); 
    1540          
    1541         if (0 && exportRandomViewCells) 
    1542           { 
    1543                 char buff[512]; 
    1544                 Environment::GetSingleton()->GetStringValue("Scene.filename", buff); 
    1545                 string filename(buff); 
    1546  
    1547                 string viewCellPointsFile; 
    1548                  
    1549                 if (strstr(filename.c_str(), ".obj")) 
    1550                   viewCellPointsFile = ReplaceSuffix(filename, ".obj", ".vc"); 
    1551                 else if (strstr(filename.c_str(), ".dat")) 
    1552                   viewCellPointsFile = ReplaceSuffix(filename, ".dat", ".vc"); 
    1553                 else if (strstr(filename.c_str(), ".x3d")) 
    1554                   viewCellPointsFile = ReplaceSuffix(filename, ".x3d", ".vc"); 
    1555                  
    1556                  
    1557                 cout << "exporting random view cells" << endl; 
    1558                 preprocessor->mViewCellsManager->ExportRandomViewCells(viewCellPointsFile); 
    1559                 cout << "finished" << endl; 
    1560           } 
    1561         first = false; 
    1562   } 
    1563  
    1564   cout<<endl<<flush; 
     1478        mPvsStat.Reset(); 
     1479        halton.Reset(); 
     1480 
     1481        SetupProjection(GetWidth(), GetHeight()); 
     1482 
     1483        cout << "Random Pvs STATS, mPvsStatFrames=" << mPvsStatFrames << endl; 
     1484 
     1485        for (int i=0; i < mPvsStatFrames; i++) { 
     1486                float err; 
     1487                // set frame id for saving the error buffer 
     1488                mFrame = i; 
     1489 
     1490                //      cerr<<"RV"<<endl; 
     1491                RandomViewPoint(); 
     1492                //      cerr<<"RV2"<<endl; 
     1493 
     1494                if (mPvsErrorBuffer[i].mError == 1.0f) { 
     1495                        // check if the view point is valid 
     1496                        if (!ValidViewPoint()) { 
     1497                                mPvsErrorBuffer[i].mError = -1.0f; 
     1498                        } 
     1499 
     1500                        // manualy corrected view point 
     1501                        if (mFrame == 5105) 
     1502                                mPvsErrorBuffer[i].mError = -1.0f; 
     1503                } 
     1504 
     1505 
     1506                if (mPvsErrorBuffer[i].mError > 0.0f)  
     1507                { 
     1508                        int pvsSize; 
     1509 
     1510                        float error = GetPixelError(pvsSize); 
     1511 
     1512                        mPvsErrorBuffer[i].mError = error; 
     1513                        mPvsErrorBuffer[i].mPvsSize = pvsSize; 
     1514 
     1515                        //cout<<"("<<i<<" ["<<mViewPoint<<"]["<<mViewDirection<<"] "<<mPvsErrorBuffer[i].mError<<")"; 
     1516                } 
     1517 
     1518                err = mPvsErrorBuffer[i].mError; 
     1519 
     1520                if (err >= 0.0f) { 
     1521                        if (err > mPvsStat.maxError) 
     1522                                mPvsStat.maxError = err; 
     1523                        mPvsStat.sumError += err; 
     1524                        mPvsStat.sumPvsSize += mPvsErrorBuffer[i].mPvsSize; 
     1525 
     1526                        if (err == 0.0f) 
     1527                                mPvsStat.errorFreeFrames++; 
     1528                        mPvsStat.frames++; 
     1529                } 
     1530        } 
     1531 
     1532        glFinish(); 
     1533 
     1534        static bool first = true; 
     1535        if (first) { 
     1536 
     1537 
     1538                bool exportRandomViewCells; 
     1539                Environment::GetSingleton()->GetBoolValue("ViewCells.exportRandomViewCells", 
     1540                        exportRandomViewCells); 
     1541 
     1542                if (0 && exportRandomViewCells) 
     1543                { 
     1544                        char buff[512]; 
     1545                        Environment::GetSingleton()->GetStringValue("Scene.filename", buff); 
     1546                        string filename(buff); 
     1547 
     1548                        string viewCellPointsFile; 
     1549 
     1550                        if (strstr(filename.c_str(), ".obj")) 
     1551                                viewCellPointsFile = ReplaceSuffix(filename, ".obj", ".vc"); 
     1552                        else if (strstr(filename.c_str(), ".dat")) 
     1553                                viewCellPointsFile = ReplaceSuffix(filename, ".dat", ".vc"); 
     1554                        else if (strstr(filename.c_str(), ".x3d")) 
     1555                                viewCellPointsFile = ReplaceSuffix(filename, ".x3d", ".vc"); 
     1556 
     1557 
     1558                        cout << "exporting random view cells" << endl; 
     1559                        preprocessor->mViewCellsManager->ExportRandomViewCells(viewCellPointsFile); 
     1560                        cout << "finished" << endl; 
     1561                } 
     1562                first = false; 
     1563        } 
     1564 
     1565        cout<<endl<<flush; 
    15651566} 
    15661567 
     
    15801581        for (sit = viewPoints.begin(); sit != sit_end; ++ sit, ++ i)  
    15811582        { 
    1582                 if ((i % 10) == 99) 
     1583                if ((i % 100) == 99) 
    15831584                        cout << "processed " << i << " view points " << endl; 
    15841585 
     
    16031604 
    16041605                        const int pixelError = (int)mPvsErrorBuffer[i].mError * GetWidth() * GetHeight(); 
     1606 
    16051607                        if (0 && (pixelError > 0) && (pvsSize > 0))  
    16061608                        { 
     
    16231625                                mPvsStat.maxError = err; 
    16241626 
    1625                                 cout << "new max error: " << mPvsStat.maxError * GetWidth()*GetHeight()  << endl; 
     1627                                cout << "new max error: " << mPvsStat.maxError * GetWidth() * GetHeight()  << endl; 
    16261628                        } 
    16271629 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp

    r2678 r2679  
    3030 
    3131#include <QVBoxLayout> 
     32static GLint cubeArray[][3] = { 
     33    {0, 0, 0}, {0, 1, 0}, {1, 1, 0}, {1, 0, 0}, 
     34    {0, 0, 1}, {1, 0, 1}, {1, 1, 1}, {0, 1, 1}, 
     35    {0, 0, 0}, {1, 0, 0}, {1, 0, 1}, {0, 0, 1}, 
     36    {0, 1, 0}, {0, 1, 1}, {1, 1, 1}, {1, 1, 0}, 
     37    {0, 1, 0}, {0, 0, 0}, {0, 0, 1}, {0, 1, 1}, 
     38    {1, 0, 0}, {1, 1, 0}, {1, 1, 1}, {1, 0, 1} 
     39}; 
     40 
     41static GLint cubeTextureArray[][2] = { 
     42    {0, 0}, {1, 0}, {1, 1}, {0, 1}, 
     43    {0, 0}, {0, 1}, {1, 1}, {1, 0}, 
     44    {0, 0}, {1, 0}, {1, 1}, {0, 1}, 
     45    {1, 0}, {0, 0}, {0, 1}, {1, 1}, 
     46    {0, 0}, {1, 0}, {1, 1}, {0, 1}, 
     47    {1, 0}, {0, 0}, {0, 1}, {1, 1} 
     48}; 
     49 
     50static GLint faceArray[][2] = { 
     51    {1, -1}, {1, 1}, {-1, 1}, {-1, -1} 
     52}; 
     53 
     54static GLubyte colorArray[][4] = { 
     55    {170, 202, 0, 255}, 
     56    {120, 143, 0, 255}, 
     57    {83, 102, 0, 255}, 
     58    {120, 143, 0, 255} 
     59}; 
     60 
     61 
     62 
    3263 
    3364namespace GtpVisibilityPreprocessor  
     
    6899} 
    69100#endif 
     101 
     102 
     103void QtGlRendererBuffer::dummyBuffer() 
     104{  
     105        //QGLPixelBuffer *dummy = new QGLPixelBuffer(QSize(256, 256), format(), this); 
     106     
     107        // set up the pbuffer context 
     108    makeCurrent(); 
     109     
     110        glEnableClientState(GL_VERTEX_ARRAY); 
     111    glEnableClientState(GL_TEXTURE_COORD_ARRAY); 
     112    glVertexPointer(3, GL_INT, 0, cubeArray); 
     113    glTexCoordPointer(2, GL_INT, 0, cubeTextureArray); 
     114    glColorPointer(4, GL_UNSIGNED_BYTE, 0, colorArray); 
     115 
     116    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 
     117    glEnable(GL_BLEND); 
     118    glEnable(GL_TEXTURE_2D); 
     119    glEnable(GL_DEPTH_TEST); 
     120 
     121    glClearColor(1.0f, 1.0f, 1.0f, 1.0f); 
     122 
     123    glViewport(0, 0, size().width(), size().height()); 
     124    glMatrixMode(GL_PROJECTION); 
     125    glLoadIdentity(); 
     126    glOrtho(-1, 1, -1, 1, -99, 99); 
     127    glTranslatef(-0.5f, -0.5f, 0.0f); 
     128    glMatrixMode(GL_MODELVIEW); 
     129    glLoadIdentity(); 
     130 
     131    
     132        glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); 
     133 
     134        // draw cube background 
     135        glPushMatrix(); 
     136        glLoadIdentity(); 
     137        glTranslatef(0.5f, 0.5f, -2.0f); 
     138        glDisable(GL_TEXTURE_2D); 
     139        glEnableClientState(GL_COLOR_ARRAY); 
     140        glVertexPointer(2, GL_INT, 0, faceArray); 
     141        glDrawArrays(GL_QUADS, 0, 4); 
     142        glVertexPointer(3, GL_INT, 0, cubeArray); 
     143        glDisableClientState(GL_COLOR_ARRAY); 
     144        glEnable(GL_TEXTURE_2D); 
     145        glPopMatrix(); 
     146 
     147        // draw cube 
     148        glTranslatef(0.5f, 0.5f, 0.5f); 
     149        glRotatef(3.0f, 1.0f, 1.0f, 1.0f); 
     150        glTranslatef(-0.5f, -0.5f, -0.5f); 
     151        glColor4f(0.9f, 0.9f, 0.9f, 1.0f); 
     152        glDrawArrays(GL_QUADS, 0, 24); 
     153 
     154        QImage im = toImage(); 
     155        QString qstr("test.png"); 
     156 
     157        im.save(qstr, "PNG"); 
     158 
     159        doneCurrent(); 
     160} 
    70161 
    71162 
     
    99190        //mUseVbos = false; 
    100191         
     192        //makeCurrent(); 
    101193        MakeLive(); 
    102194        glViewport(0, 0, w, h); 
     
    109201 
    110202        InitGL(); 
    111          
    112         //mydynamicTexture = generateDynamicTexture(); 
    113     // bind the dynamic texture to the pbuffer - this is a no-op under X11 
    114         //bindToDynamicTexture(mydynamicTexture); 
    115  
    116         DoneLive(); 
     203 
     204        //doneCurrent(); 
     205        //DoneLive(); 
    117206} 
    118207 
     
    275364                        char filename[256]; 
    276365                        //sprintf(filename, "error-frame-%04d-%0.5f.png", mFrame, pErrorPixels); 
    277                         sprintf(filename, "error-frame-%04d-%04d.png", mFrame, pixelCount); 
     366                        sprintf(filename, "error-frame-%04d-%08d.png", mFrame, pixelCount); 
    278367                        QImage im = toImage(); 
    279368                        string str = mSnapPrefix + filename; 
     
    305394 
    306395                        im = toImage(); 
    307                         sprintf(filename, "error-frame-%04d-%04d-%0.5f-pvs.png", mFrame, viewcell->GetId(), pErrorPixels); 
     396                        sprintf(filename, "error-frame-%04d-%04d-%08d-pvs.png", mFrame, viewcell->GetId(), pixelCount); 
    308397                        str = mSnapPrefix + filename; 
    309398                        qstr = str.c_str(); 
     
    316405        glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 
    317406 
    318         DoneLive(); 
     407        //DoneLive(); 
    319408 
    320409        return pErrorPixels; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h

    r2678 r2679  
    7676 
    7777        unsigned int mydynamicTexture; 
    78  
     78void dummyBuffer(); 
    7979public: 
    8080 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtInterface05.vcproj

    r2676 r2679  
    212212                        > 
    213213                        <File 
     214                                RelativePath=".\glwidget.cpp" 
     215                                > 
     216                        </File> 
     217                        <File 
    214218                                RelativePath="LogReader.cpp" 
    215219                                > 
     
    241245                        UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" 
    242246                        > 
     247                        <File 
     248                                RelativePath=".\glwidget.h" 
     249                                > 
     250                        </File> 
    243251                        <File 
    244252                                RelativePath="LogReader.h" 
  • GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp

    r2677 r2679  
    3434        #include "QtGlRenderer.h" 
    3535        #include <QGLWidget> 
     36#include "glwidget.h" 
    3637 
    3738#else 
     
    292293        // create a qt application first (must be created before any opengl widget ...) 
    293294        QApplication *app = new QApplication(argc, NULL); 
     295 
     296        //Dummy dummy(1024, 1024); 
     297        //dummy.dummyBuffer(); 
     298 
    294299        pt = new QtPreprocessorThread(preprocessor);     
    295300 
     
    314319                // renderer must be initialised 
    315320                // $$matt 
    316                 preprocessor->renderer =  
     321                QtGlRendererBuffer *glbuf =  
    317322                        new QtGlRendererBuffer(1024, 1024, 
    318                         preprocessor->mSceneGraph, 
    319                         preprocessor->mViewCellsManager, 
    320                         preprocessor->mKdTree); 
    321  
     323                                                                   preprocessor->mSceneGraph, 
     324                                                                   preprocessor->mViewCellsManager, 
     325                                                                   preprocessor->mKdTree); 
     326 
     327                preprocessor->renderer = glbuf; 
     328                         
     329                //glbuf->dummyBuffer(); 
    322330        } 
    323331 
Note: See TracChangeset for help on using the changeset viewer.