示例#1
0
void GazeTracker::load() {
	CvFileStorage *in = cvOpenFileStorage("calibration.xml", NULL, CV_STORAGE_READ);
	CvFileNode *root = cvGetRootFileNode(in);
	load(in, cvGetFileNodeByName(in, root, "GazeTracker"));
	cvReleaseFileStorage(&in);
	updateGaussianProcesses();
}
示例#2
0
CvMat * icvReadSVHNLabels(char * filename, const int max_samples)
{
  CvFileStorage * fs = cvOpenFileStorage(filename,0,CV_STORAGE_READ);
  if (!fs){fprintf(stderr,"file loading error: %s\n",filename);return 0;}
  CvFileNode * fnode = cvGetRootFileNode(fs);
  char tagname[20]; int ii;
  const int nparams = 4;
  CvMat * data = cvCreateMat(max_samples,1+nparams*10,CV_32S); cvZero(data);
  for (ii=0;;ii++){
    sprintf(tagname,"img%d",ii+1);
    CvMat * sample = (CvMat*)cvReadByName(fs,fnode,tagname);
    if (!sample || ii==max_samples){break;}
    int nnumbers = sample->rows;
    CV_MAT_ELEM(*data,int,ii,0)=nnumbers;
    for (int jj=0;jj<nnumbers;jj++){
      float xx = CV_MAT_ELEM(*sample,float,jj,0);
      float yy = CV_MAT_ELEM(*sample,float,jj,1);
      float ww = CV_MAT_ELEM(*sample,float,jj,2);
      float hh = CV_MAT_ELEM(*sample,float,jj,3);
      float ll = CV_MAT_ELEM(*sample,float,jj,4);
      CV_MAT_ELEM(*data,int,ii,1+nparams*jj+0)=cvRound(xx+ww*.5f);  // x
      CV_MAT_ELEM(*data,int,ii,1+nparams*jj+1)=cvRound(yy+hh*.5f);  // y
      CV_MAT_ELEM(*data,int,ii,1+nparams*jj+2)=cvRound(MAX(ww,hh));   // scale
      CV_MAT_ELEM(*data,int,ii,1+nparams*jj+3)=cvRound(ll);           // label
    }
    cvReleaseMat(&sample);
  }
  data->rows = ii;
  cvReleaseFileStorage(&fs);
  return data;
}
/*!
    \fn CvBinGabAdaFeatureSelect::loadweaks(const char* filename)
 */
void CvBinGabAdaFeatureSelect::loadweaks(const char* filename)
{
  //clear();
  {
    delete new_pool;
    weaks.clear();
  }
  CvMemStorage* fstorage = cvCreateMemStorage( 0 );
  CvFileStorage *fs;
  fs = cvOpenFileStorage( filename, fstorage, CV_STORAGE_READ );
  CvFileNode *root = cvGetRootFileNode( fs, 0);
  char *weakname = new char[20];
  int i = 0;
  
  CvMemStorage* storage = cvCreateMemStorage(0);
  CvSeq* seq = cvCreateSeq(0, sizeof(CvSeq), sizeof(CvGaborTree), storage );
  while(1)
  {
    sprintf( weakname, "weak_%d", i);
    CvFileNode *weaknode = cvGetFileNodeByName( fs, root, weakname);
    if (!weaknode) break;
    CvGaborTree tree;
    weaknode2tree(weaknode, fs, &tree);
    cvSeqPush( seq, &tree );
    i++;	
  }
  
    /* from squence to vector weaks*/
  new_pool = new CvGaborFeaturePool;
  for (int i = 0; i <seq->total; i++)
  {
    CvGaborTree *atree = (CvGaborTree*)cvGetSeqElem(seq, i);
    CvWeakLearner *weak = new CvWeakLearner;
    weak->setType( weaklearner_type );
    weak->setthreshold(atree->threshold);
    weak->setparity(atree->parity);
    weaks.push_back(*weak);
    CvGaborFeature *feature = new CvGaborFeature(atree->x, atree->y, atree->Mu, atree->Nu);
    new_pool->add(feature);
    alphas.push_back(atree->alpha);
    delete weak;
    delete feature;
  } 
  
  cvReleaseMemStorage( &storage );
  cvReleaseFileStorage(&fs);
  cvReleaseMemStorage( &fstorage );
  delete [] weakname;
  
    /* set member variables */
  current = new_pool->getSize();
  falsepositive = 0.0;
  nexpfeatures = new_pool->getSize();
  nselecfeatures = new_pool->getSize();
  printf(" %d weak classifiers have been loaded!\n", nselecfeatures);
}
示例#4
0
文件: image.cpp 项目: 93sam/opencv
bool CvMatrix::read( CvFileStorage* fs, const char* seqname, int idx )
{
    void* obj = 0;
    CvMat* m = 0;
    CvFileNode* seqnode = seqname ?
        cvGetFileNodeByName( fs, 0, seqname ) : cvGetRootFileNode(fs,0);

    if( seqnode && CV_NODE_IS_SEQ(seqnode->tag) )
        obj = cvRead( fs, (CvFileNode*)cvGetSeqElem( seqnode->data.seq, idx ));
    m = icvRetrieveMatrix(obj);
    set( m, false );
    return m != 0;
}
示例#5
0
文件: image.cpp 项目: 93sam/opencv
bool CvImage::read( CvFileStorage* fs, const char* seqname, int idx )
{
    void* obj = 0;
    IplImage* img = 0;
    CvFileNode* seqnode = seqname ?
        cvGetFileNodeByName( fs, 0, seqname ) : cvGetRootFileNode(fs,0);

    if( seqnode && CV_NODE_IS_SEQ(seqnode->tag) )
        obj = cvRead( fs, (CvFileNode*)cvGetSeqElem( seqnode->data.seq, idx ));
    img = icvRetrieveImage(obj);
    attach( img );
    return img != 0;
}
示例#6
0
int CV_MLBaseTest::read_params( CvFileStorage* _fs )
{
    if( !_fs )
        test_case_count = -1;
    else
    {
        CvFileNode* fn = cvGetRootFileNode( _fs, 0 );
        fn = (CvFileNode*)cvGetSeqElem( fn->data.seq, 0 );
        fn = cvGetFileNodeByName( _fs, fn, "run_params" );
        CvSeq* dataSetNamesSeq = cvGetFileNodeByName( _fs, fn, modelName.c_str() )->data.seq;
        test_case_count = dataSetNamesSeq ? dataSetNamesSeq->total : -1;
        if( test_case_count > 0 )
        {
            dataSetNames.resize( test_case_count );
            vector<string>::iterator it = dataSetNames.begin();
            for( int i = 0; i < test_case_count; i++, it++ )
                *it = ((CvFileNode*)cvGetSeqElem( dataSetNamesSeq, i ))->data.str.ptr;
        }
    }
    return CvTS::OK;;
}