Changeset 2662


Ignore:
Timestamp:
04/28/08 18:59:58 (16 years ago)
Author:
mattausch
Message:

working on gvs pixel error evaluation bugfixing

Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp

    r2653 r2662  
    125125 
    126126#endif 
     127 
    127128        mFrame = 0; 
    128129        mWireFrame = false; 
     
    15331534                mPvsErrorBuffer[i].mError = -1.0f; 
    15341535        } 
    1535          
    1536          
    1537         // atlanta problematic frames: 325 525 691 1543 
    1538 #if 0 
    1539         if (mFrame != 325 && 
    1540                 mFrame != 525 && 
    1541                 mFrame != 691 && 
    1542                 mFrame != 1543) 
    1543           mPvsErrorBuffer[i] = -1; 
    1544         else { 
    1545           Debug<<"frame ="<<mFrame<<" vp="<<mViewPoint<<" vd="<<mViewDirection<<endl; 
    1546         } 
    1547 #endif 
    1548          
     1536 
    15491537 
    15501538        if (mPvsErrorBuffer[i].mError > 0.0f) { 
     
    16151603void GlRenderer::EvalPvsStat(const SimpleRayContainer &viewPoints) 
    16161604{ 
    1617   mPvsStat.Reset(); 
    1618  
    1619   SetupProjection(GetWidth(), GetHeight()); 
    1620    
    1621   cout << "mPvsStatFrames=" << viewPoints.size() << endl; 
    1622    
    1623   SimpleRayContainer::const_iterator sit, sit_end = viewPoints.end(); 
    1624   int i = 0; 
    1625    
    1626   for (sit = viewPoints.begin(); sit != sit_end; ++ sit, ++ i)  
    1627         { 
    1628           //cout << "\n\nvp: " << (*sit) << endl; 
    1629           SimpleRay sray = *sit; 
    1630            
    1631           // set frame id for saving the error buffer 
    1632           mFrame = i; 
    1633           mViewPoint = sray.mOrigin; 
    1634           mViewDirection = sray.mDirection; 
    1635  
    1636           // skip all frames which have already 0 pixel error 
    1637           // $$ Reverted back by JB for efficiency 
    1638           if (mPvsErrorBuffer[i].mError > 0.0f)  
    1639           { 
    1640                   int pvsSize; 
    1641  
    1642                   // compute the pixel error 
    1643                   float error = GetPixelError(pvsSize); 
    1644                    
    1645                   mPvsErrorBuffer[i].mError = error; 
    1646                   mPvsErrorBuffer[i].mPvsSize = pvsSize; 
    1647  
    1648                   cout << "(" << i << "," << mViewPoint << "," << mViewDirection << mPvsErrorBuffer[i].mError <<")"; 
    1649                   //              cout << "(vc: " << i << ", er: " << mPvsErrorBuffer[i].mError <<")" << endl; 
    1650           } 
    1651  
    1652           const float err = mPvsErrorBuffer[i].mError; 
    1653  
    1654           // do not account for the case that no PVS is rendered - hack for 08 rebuttal GVS evaluation 
    1655           // (correct would be >=0.0f) 
    1656           if (err >= 0.0f && err < 0.99999f)  
    1657           { 
    1658                   if (err > mPvsStat.maxError) 
    1659                   { 
    1660                           mPvsStat.maxError = err; 
    1661                           cout << "new max error: " << mPvsStat.maxError << endl; 
    1662                   } 
    1663  
    1664                   mPvsStat.sumError += err; 
    1665                   mPvsStat.sumPvsSize += mPvsErrorBuffer[i].mPvsSize; 
    1666  
    1667                   if (err == 0.0f) 
    1668                           ++ mPvsStat.errorFreeFrames; 
    1669  
    1670                   // $$ JB 
    1671                   // moved it back here not to count frames with negative err (backfacing triangle) 
    1672                   ++ mPvsStat.frames; 
    1673           } 
    1674            
    1675         } 
    1676    
    1677   glFinish(); 
    1678  
    1679    
    1680   cout << endl << flush; 
     1605        mPvsStat.Reset(); 
     1606 
     1607        SetupProjection(GetWidth(), GetHeight()); 
     1608 
     1609        cout << "mPvsStatFrames=" << viewPoints.size() << endl; 
     1610 
     1611        SimpleRayContainer::const_iterator sit, sit_end = viewPoints.end(); 
     1612 
     1613        int i = 0; 
     1614 
     1615        for (sit = viewPoints.begin(); sit != sit_end; ++ sit, ++ i)  
     1616        { 
     1617                //cout << "\n\nvp: " << (*sit) << endl; 
     1618                SimpleRay sray = *sit; 
     1619                int pvsSize = 0; 
     1620 
     1621                // set frame id for saving the error buffer 
     1622                mFrame = i; 
     1623                mViewPoint = sray.mOrigin; 
     1624                mViewDirection = sray.mDirection; 
     1625 
     1626                // skip all frames which have already 0 pixel error 
     1627                // $$ Reverted back by JB for efficiency 
     1628                if (mPvsErrorBuffer[i].mError > 0.0f)  
     1629                { 
     1630                        // compute the pixel error 
     1631                        float error = GetPixelError(pvsSize); 
     1632 
     1633                        mPvsErrorBuffer[i].mError = error; 
     1634                        mPvsErrorBuffer[i].mPvsSize = pvsSize; 
     1635 
     1636                        int pixelError = (int)mPvsErrorBuffer[i].mError * GetWidth() * GetHeight(); 
     1637 
     1638                        if (0 && (pixelError > 0) && (pvsSize > 0))  
     1639                        { 
     1640                                cout << "!err: " << i << "," << mViewPoint << "," << mViewDirection << " " << mPvsErrorBuffer[i].mError * GetWidth() * GetHeight() << endl; 
     1641                        } 
     1642                } 
     1643 
     1644                const float err = mPvsErrorBuffer[i].mError; 
     1645 
     1646                // hack: 
     1647                // do not account for the case that no PVS is rendered - hack for 08 rebuttal GVS evaluation 
     1648                // drop the first frame (for some reason, the first frame yields wrong pixel error) 
     1649                 
     1650                if ((mFrame > 0) && (err >= 0.0f) && (err < (1.0f - 1e-6f)) && (pvsSize > 0))  
     1651                { 
     1652                        if (err > mPvsStat.maxError) 
     1653                        { 
     1654                                mPvsStat.maxError = err; 
     1655 
     1656                                cout << "new max error: " << mPvsStat.maxError * GetWidth()*GetHeight()  << endl; 
     1657                        } 
     1658 
     1659                        mPvsStat.sumError += err; 
     1660                        mPvsStat.sumPvsSize += mPvsErrorBuffer[i].mPvsSize; 
     1661 
     1662                        if (err == 0.0f) 
     1663                                ++ mPvsStat.errorFreeFrames; 
     1664 
     1665                        // $$ JB 
     1666                        // moved it back here not to count frames with negative err (backfacing triangle) 
     1667                        ++ mPvsStat.frames; 
     1668                } 
     1669 
     1670        } 
     1671 
     1672        glFinish(); 
     1673 
     1674 
     1675        cout << endl << flush; 
    16811676} 
    16821677 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp

    r2648 r2662  
    846846                { 
    847847                        mViewCells.push_back((*vit)->first); 
     848 
     849                        if (mViewCells.size() >= mMaxViewCells) 
     850                                break; 
    848851                } 
    849  
    850                 return; 
    851         } 
    852  
    853         while ((int)mViewCells.size() < mMaxViewCells) 
    854     { 
    855                 if (0) 
     852        } 
     853        else 
     854        { 
     855                while ((int)mViewCells.size() < mMaxViewCells) 
    856856                { 
    857                         mViewCells.push_back(mViewCellsManager->GetViewCell((int)mViewCells.size())); 
    858                         continue; 
    859                 } 
    860                  
    861                 // HACK 
    862                 const int tries = 10000; 
    863                 int i = 0; 
    864  
    865                 for (i = 0; i < tries; ++ i) 
    866                 { 
    867                         const int idx = (int)RandomValue(0.0f, (float)mViewCellsManager->GetNumViewCells() - 0.5f); 
    868          
    869                         ViewCell *viewCell = mViewCellsManager->GetViewCell(idx); 
    870  
    871                         if (!viewCell->Mailed()) 
     857                        if (0) 
    872858                        { 
    873                                 viewCell->Mail(); 
     859                                mViewCells.push_back(mViewCellsManager->GetViewCell((int)mViewCells.size())); 
     860                                continue; 
     861                        } 
     862 
     863                        // HACK 
     864                        const int tries = 10000; 
     865                        int i = 0; 
     866 
     867                        for (i = 0; i < tries; ++ i) 
     868                        { 
     869                                const int idx = (int)RandomValue(0.0f, (float)mViewCellsManager->GetNumViewCells() - 0.5f); 
     870 
     871                                ViewCell *viewCell = mViewCellsManager->GetViewCell(idx); 
     872 
     873                                if (!viewCell->Mailed()) 
     874                                { 
     875                                        viewCell->Mail(); 
     876                                        break; 
     877                                } 
     878 
     879                                mViewCells.push_back(viewCell); 
     880                        } 
     881 
     882                        if (i == tries) 
     883                        { 
     884                                cerr << "big error! no view cell found" << endl; 
    874885                                break; 
    875886                        } 
    876  
    877                         mViewCells.push_back(viewCell); 
    878887                } 
    879  
    880                 if (i == tries) 
    881                 { 
    882                         cerr << "big error! no view cell found" << endl; 
    883                         return; 
    884                 } 
    885         } 
     888        } 
     889 
     890        cout << "\ncomputing list of " << mViewCells.size() << " view cells" << endl; 
    886891} 
    887892 
     
    11141119                cout << "finished view cell construction" << endl; 
    11151120        } 
    1116 #if 0 
    1117         else 
    1118         {        
    1119                 //-- test successful view cells loading by exporting them again 
    1120                 VssRayContainer dummies; 
    1121                 mViewCellsManager->Visualize(mObjects, dummies); 
    1122                 mViewCellsManager->ExportViewCells("test.xml.gz", mViewCellsManager->GetExportPvs(), mObjects); 
    1123         } 
    1124 #endif 
    11251121 
    11261122        if (mPerViewCell) 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HavranRayCaster.cpp

    r2655 r2662  
    8585#ifdef USE_HAVRAN_RAYCASTER  
    8686  return mKtbtree->ExportBinTree(filename); 
     87#else 
     88        return false; 
    8789#endif 
    8890} 
     
    9294{ 
    9395#ifdef USE_HAVRAN_RAYCASTER  
    94   return mKtbtree->ImportBinTree(filename, objects); 
     96        return mKtbtree->ImportBinTree(filename, objects); 
     97#else 
     98        return false; 
    9599#endif 
    96100} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp

    r2660 r2662  
    132132{ 
    133133 
    134   MakeCurrent(); 
    135  
    136   float pErrorPixels = -1.0f; 
     134        MakeCurrent(); 
     135 
     136        float pErrorPixels = -1.0f; 
    137137 
    138138 
     
    142142 
    143143        ViewCell *viewcell = mViewCellsManager->GetViewCell(mViewPoint); 
    144          
    145         //cout << "vp: " << mViewPoint << endl; 
    146144 
    147145        if (viewcell == NULL) 
     
    154152 
    155153        if (!evaluateFilter)  
    156           pvs = viewcell->GetPvs(); 
     154                pvs = viewcell->GetPvs(); 
    157155        else { 
    158156 
    159           mViewCellsManager->ApplyFilter2(viewcell, 
    160                                                                           false, 
    161                                                                           mViewCellsManager->GetFilterWidth(), 
    162                                                                           pvs); 
     157                mViewCellsManager->ApplyFilter2(viewcell, 
     158                        false, 
     159                        mViewCellsManager->GetFilterWidth(), 
     160                        pvs); 
    163161        } 
    164162 
     
    174172        glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);  
    175173 
    176  
    177174        pvsSize = pvs.GetSize(); 
    178         cout << "vc id: " << viewcell->GetId() << " pvs: " << pvsSize << endl; 
    179175         
    180176        RenderPvs(pvs); 
    181          
     177 
    182178        //glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE); 
    183179        glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 
     
    185181        glColor3f(1,0,0); 
    186182 
    187          
     183 
    188184        OcclusionQuery *query = mOcclusionQueries[0]; 
    189185 
    190         //      SetupCamera(); 
    191  
    192186        Intersectable::NewMail(); 
    193187 
     
    195189 
    196190        RenderScene(); 
    197          
     191 
    198192        query->EndQuery(); 
    199193        glDisable(GL_STENCIL_TEST);  
     
    204198        //      wait++; 
    205199        //  } 
    206          
     200 
    207201 
    208202        pixelCount = query->GetQueryResult(); 
    209         //      cout<<"pc="<<pixelCount<<endl; 
    210          
    211         pErrorPixels = ((float)pixelCount)/(GetWidth()*GetHeight()); 
    212  
    213  
    214         if (mSnapErrorFrames && (pErrorPixels >= 0.01f)) { 
    215           glReadBuffer(GL_BACK); 
    216           //glReadBuffer(GL_FRONT); 
    217            
    218           char filename[256]; 
    219           sprintf(filename, "error-frame-%04d-%0.5f.png", mFrame, pErrorPixels); 
    220           QImage im = toImage(); 
    221           string str = mSnapPrefix + filename; 
    222           QString qstr(str.c_str()); 
    223            
    224           im.save(qstr, "PNG"); 
    225           if (0) { //0 && mFrame == 1543) { 
    226                 int x,y; 
    227                 int lastIndex = -1; 
    228                 for (y=0; y < im.height(); y++) 
    229                   for (x=0; x < im.width(); x++) { 
    230                         QRgb p = im.pixel(x,y); 
    231                         int index = qRed(p) + (qGreen(p)<<8) + (qBlue(p)<<16); 
    232                         if (qGreen(p) != 255 && index!=0) { 
    233                           if (index != lastIndex) { 
    234                                 //                              Debug<<"ei="<<index<<" "; 
    235                                 lastIndex = index; 
    236                           } 
    237                         } 
    238                   } 
    239           } 
    240            
    241           mUseFalseColors = false; 
    242           glPushAttrib(GL_CURRENT_BIT); 
    243           glColor3f(0,1,0); 
    244           glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 
    245           glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    246            
    247           RenderPvs(pvs); 
    248  
    249           mUseForcedColors = false; 
    250           im = toImage(); 
    251           sprintf(filename, "error-frame-%04d-%0.5f-pvs.png", mFrame, pErrorPixels); 
    252           str = mSnapPrefix + filename; 
    253           qstr = str.c_str(); 
    254           im.save(qstr, "PNG"); 
    255           glPopAttrib(); 
    256         } 
    257          
     203 
     204        if ((pixelCount > 0) && (pvsSize > 0)) 
     205        { 
     206                cout << "vc id: " << viewcell->GetId() << " pvs: " << pvsSize << " pc: " << pixelCount << endl; 
     207        } 
     208 
     209        pErrorPixels = ((float)pixelCount) / (GetWidth() * GetHeight()); 
     210 
     211 
     212        if (mSnapErrorFrames && (pixelCount > 0)) { 
     213                glReadBuffer(GL_BACK); 
     214                //glReadBuffer(GL_FRONT); 
     215 
     216                char filename[256]; 
     217                sprintf(filename, "error-frame-%04d-%0.5f.png", mFrame, pErrorPixels); 
     218                QImage im = toImage(); 
     219                string str = mSnapPrefix + filename; 
     220                QString qstr(str.c_str()); 
     221 
     222                im.save(qstr, "PNG"); 
     223                if (0) { //0 && mFrame == 1543) { 
     224                        int x,y; 
     225                        int lastIndex = -1; 
     226                        for (y=0; y < im.height(); y++) 
     227                                for (x=0; x < im.width(); x++) { 
     228                                        QRgb p = im.pixel(x,y); 
     229                                        int index = qRed(p) + (qGreen(p)<<8) + (qBlue(p)<<16); 
     230                                        if (qGreen(p) != 255 && index!=0) { 
     231                                                if (index != lastIndex) { 
     232                                                        //                              Debug<<"ei="<<index<<" "; 
     233                                                        lastIndex = index; 
     234                                                } 
     235                                        } 
     236                                } 
     237                } 
     238 
     239                mUseFalseColors = false; 
     240                glPushAttrib(GL_CURRENT_BIT); 
     241                glColor3f(0,1,0); 
     242                glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 
     243                glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
     244 
     245                RenderPvs(pvs); 
     246 
     247                mUseForcedColors = false; 
     248                im = toImage(); 
     249                sprintf(filename, "error-frame-%04d-%0.5f-pvs.png", mFrame, pErrorPixels); 
     250                str = mSnapPrefix + filename; 
     251                qstr = str.c_str(); 
     252                im.save(qstr, "PNG"); 
     253                glPopAttrib(); 
     254        } 
     255 
    258256        glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 
    259257 
     
    614612        glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);  
    615613 
    616         //mUseForcedColors = true; 
    617  
    618         //      glColor3f(0.0f, 0.8f, 0.2f); 
    619         //      glColor3f(0.5f, 0.5f, 0.5f); 
    620  
    621614        glColor3f(0.6f, 0.6f, 0.6f); 
    622615 
     
    626619        glEnable(GL_STENCIL_TEST);  
    627620 
    628         //mUseFalseColors = true; 
    629  
    630621        glDisable(GL_LIGHTING); 
     622 
     623        SetupCamera(); 
     624 
     625        mUseForcedColors = true; 
     626 
     627        glColor3f(1.0f, 0.0f, 0.0f); 
     628 
    631629 
    632630        OcclusionQuery *query = mOcclusionQueries[0]; 
    633631        query->BeginQuery(); 
    634  
    635         SetupCamera(); 
    636  
    637         mUseForcedColors = true; 
    638  
    639         glColor3f(1.0f, 0.0f, 0.0f); 
    640632 
    641633        RenderScene(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor05.vcproj

    r2660 r2662  
    100100                        Name="Release|Win32" 
    101101                        OutputDirectory="..\bin\$(ConfigurationName)" 
    102                         IntermediateDirectory="$(SolutionDir)\obj05\$(ConfigurationName)" 
     102                        IntermediateDirectory="..\obj05\$(ConfigurationName)" 
    103103                        ConfigurationType="1" 
    104104                        InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" 
Note: See TracChangeset for help on using the changeset viewer.