Home || Visual Search || Applications || Architecture || Important Messages || OGL || Src

bool Impala::Core::Table::Bayes::LoadMatrixConceptConditionalProbability ( String  name,
double **  matrix,
int &  nRow,
int &  nCol,
bool  bAnnoSet = true 
) [inline]

Definition at line 539 of file Bayes.h.

References Impala::Core::Database::RawDataSet::GetFilePathAnnotation(), mAnnoImgSet, mAnnoVidSet, mImgSet, mIsImageSet, and mVidSet.

Referenced by LoadMatrix().

00540     {
00541         // mMatrixFile, mProb_c_g, mConceptNum, mGenreNum
00542 
00543         std::string fName;
00544 
00545         if (bAnnoSet)
00546         {
00547             // loading from annotation set (training set)
00548 
00549             if (mIsImageSet)
00550                 fName = mAnnoImgSet->GetFilePathAnnotation(name,false,false);
00551             else
00552                 fName = mAnnoVidSet->GetFilePathAnnotation(name,false,false);
00553 
00554             /*String strAnnoSetName = mAnnoSetName;
00555             strAnnoSetName.resize(strAnnoSetName.size() - 4);
00556             fName = String("../") + strAnnoSetName + "/Annotations/" + name;*/
00557        }
00558         else
00559         {
00560             // loading from test set itself.
00561 
00562             if (mIsImageSet)
00563             {
00564                 if (NULL != mImgSet)
00565                 {
00566                     fName = mImgSet->GetFilePathAnnotation(name,false,false);
00567 
00568                     /*String strSetName = mSetName;
00569                     strSetName.resize(strSetName.size()-4);
00570                     fName = String("../") + strSetName + "/Annotations/" + name;*/
00571 
00572                 }
00573                 else
00574                 {
00575                     std::cout << "mImgSet: Not initialized." << std::endl;
00576                     return false;
00577                 }
00578             }
00579             else
00580             {
00581                 if (NULL != mVidSet)
00582                 {
00583                     fName = mVidSet->GetFilePathAnnotation(name,false,false);
00584 
00585                     /*String strSetName = mSetName;
00586                     strSetName.resize(strSetName.size()-4);
00587                     fName = String("../") + strSetName + "/Annotations/" + name;*/
00588 
00589                 }
00590                 else
00591                 {
00592                     std::cout << "mVidSet: Not initialized." << std::endl;
00593                     return false;
00594                 }
00595             }
00596 
00597             
00598         }
00599 
00600         FILE* fp = fopen(fName.c_str(),"rb");
00601 
00602         if (NULL == fp)
00603         {
00604             std::cout << "File does NOT exist: [" << fName << "]" << std::endl;
00605             return false;
00606         }
00607 
00608         int nLocalRow, nLocalCol;
00609 
00610         fread(&nLocalRow, sizeof(int), 1, fp);  //mConceptNum
00611         fread(&nLocalCol, sizeof(int), 1, fp);  //mGenreNum
00612 
00613         // verify the dimension of matrix
00614         if ( nRow == nLocalRow && nCol == nLocalCol)
00615         {
00616             // data file: first column, second column, ...
00617             // be sure to be consistent with save funcion
00618             for (int i=0; i<nRow; i++)
00619             {
00620                 for (int j=0; j<nCol; j++)
00621                 {
00622                     //printf("%.3f ", matrix[i][j]);
00623                     fread( &(matrix[i][j]), sizeof(double), 1, fp);
00624                 }
00625                 //std::cout << std::endl;
00626 
00627             }
00628 
00629             fclose(fp);
00630             return true;
00631 
00632         } else {
00633 
00634             // verification fails
00635             std::cout << "Loaded Matrix dimension is not the same as Annotation" << std::endl;
00636 
00637             fclose(fp);
00638             return false;
00639         }
00640 
00641         //fclose(fp);
00642 
00643     }

Here is the call graph for this function:


Generated on Thu Jan 13 09:20:47 2011 for ImpalaSrc by  doxygen 1.5.1