- Timestamp:
- 04/28/08 18:59:58 (17 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
r2653 r2662 125 125 126 126 #endif 127 127 128 mFrame = 0; 128 129 mWireFrame = false; … … 1533 1534 mPvsErrorBuffer[i].mError = -1.0f; 1534 1535 } 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 1549 1537 1550 1538 if (mPvsErrorBuffer[i].mError > 0.0f) { … … 1615 1603 void GlRenderer::EvalPvsStat(const SimpleRayContainer &viewPoints) 1616 1604 { 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; 1681 1676 } 1682 1677 -
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
r2648 r2662 846 846 { 847 847 mViewCells.push_back((*vit)->first); 848 849 if (mViewCells.size() >= mMaxViewCells) 850 break; 848 851 } 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) 856 856 { 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) 872 858 { 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; 874 885 break; 875 886 } 876 877 mViewCells.push_back(viewCell);878 887 } 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; 886 891 } 887 892 … … 1114 1119 cout << "finished view cell construction" << endl; 1115 1120 } 1116 #if 01117 else1118 {1119 //-- test successful view cells loading by exporting them again1120 VssRayContainer dummies;1121 mViewCellsManager->Visualize(mObjects, dummies);1122 mViewCellsManager->ExportViewCells("test.xml.gz", mViewCellsManager->GetExportPvs(), mObjects);1123 }1124 #endif1125 1121 1126 1122 if (mPerViewCell) -
GTP/trunk/Lib/Vis/Preprocessing/src/HavranRayCaster.cpp
r2655 r2662 85 85 #ifdef USE_HAVRAN_RAYCASTER 86 86 return mKtbtree->ExportBinTree(filename); 87 #else 88 return false; 87 89 #endif 88 90 } … … 92 94 { 93 95 #ifdef USE_HAVRAN_RAYCASTER 94 return mKtbtree->ImportBinTree(filename, objects); 96 return mKtbtree->ImportBinTree(filename, objects); 97 #else 98 return false; 95 99 #endif 96 100 } -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
r2660 r2662 132 132 { 133 133 134 135 136 134 MakeCurrent(); 135 136 float pErrorPixels = -1.0f; 137 137 138 138 … … 142 142 143 143 ViewCell *viewcell = mViewCellsManager->GetViewCell(mViewPoint); 144 145 //cout << "vp: " << mViewPoint << endl;146 144 147 145 if (viewcell == NULL) … … 154 152 155 153 if (!evaluateFilter) 156 154 pvs = viewcell->GetPvs(); 157 155 else { 158 156 159 160 161 162 157 mViewCellsManager->ApplyFilter2(viewcell, 158 false, 159 mViewCellsManager->GetFilterWidth(), 160 pvs); 163 161 } 164 162 … … 174 172 glStencilOp(GL_KEEP, GL_KEEP, GL_INCR); 175 173 176 177 174 pvsSize = pvs.GetSize(); 178 cout << "vc id: " << viewcell->GetId() << " pvs: " << pvsSize << endl;179 175 180 176 RenderPvs(pvs); 181 177 182 178 //glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE); 183 179 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); … … 185 181 glColor3f(1,0,0); 186 182 187 183 188 184 OcclusionQuery *query = mOcclusionQueries[0]; 189 185 190 // SetupCamera();191 192 186 Intersectable::NewMail(); 193 187 … … 195 189 196 190 RenderScene(); 197 191 198 192 query->EndQuery(); 199 193 glDisable(GL_STENCIL_TEST); … … 204 198 // wait++; 205 199 // } 206 200 207 201 208 202 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 258 256 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 259 257 … … 614 612 glStencilOp(GL_KEEP, GL_KEEP, GL_INCR); 615 613 616 //mUseForcedColors = true;617 618 // glColor3f(0.0f, 0.8f, 0.2f);619 // glColor3f(0.5f, 0.5f, 0.5f);620 621 614 glColor3f(0.6f, 0.6f, 0.6f); 622 615 … … 626 619 glEnable(GL_STENCIL_TEST); 627 620 628 //mUseFalseColors = true;629 630 621 glDisable(GL_LIGHTING); 622 623 SetupCamera(); 624 625 mUseForcedColors = true; 626 627 glColor3f(1.0f, 0.0f, 0.0f); 628 631 629 632 630 OcclusionQuery *query = mOcclusionQueries[0]; 633 631 query->BeginQuery(); 634 635 SetupCamera();636 637 mUseForcedColors = true;638 639 glColor3f(1.0f, 0.0f, 0.0f);640 632 641 633 RenderScene(); -
GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor05.vcproj
r2660 r2662 100 100 Name="Release|Win32" 101 101 OutputDirectory="..\bin\$(ConfigurationName)" 102 IntermediateDirectory=" $(SolutionDir)\obj05\$(ConfigurationName)"102 IntermediateDirectory="..\obj05\$(ConfigurationName)" 103 103 ConfigurationType="1" 104 104 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
Note: See TracChangeset
for help on using the changeset viewer.