//加载保存过的训练结果 int loadTrainingData(CvMat ** pTrainPersonNumMat) { CvFileStorage * fileStorage; int i; fileStorage = cvOpenFileStorage( "facedata.xml", 0, CV_STORAGE_READ ); if( !fileStorage ) { fprintf(stderr, "Can't open facedata.xml\n"); return 0; } nEigens = cvReadIntByName(fileStorage, 0, "nEigens", 0); nTrainFaces = cvReadIntByName(fileStorage, 0, "nTrainFaces", 0); *pTrainPersonNumMat = (CvMat *)cvReadByName(fileStorage, 0, "trainPersonNumMat", 0); eigenValMat = (CvMat *)cvReadByName(fileStorage, 0, "eigenValMat", 0); projectedTrainFaceMat = (CvMat *)cvReadByName(fileStorage, 0, "projectedTrainFaceMat", 0); pAvgTrainImg = (IplImage *)cvReadByName(fileStorage, 0, "avgTrainImg", 0); eigenVectArr = (IplImage **)cvAlloc(nTrainFaces*sizeof(IplImage *)); for(i=0; i<nEigens; i++) { char varname[200]; sprintf( varname, "eigenVect_%d", i ); eigenVectArr[i] = (IplImage *)cvReadByName(fileStorage, 0, varname, 0); } cvReleaseFileStorage( &fileStorage ); return 1; }
////////////////////////////////// // loadTrainingData() // int EigenFace::loadTrainingData() { LOGD("load from %s", mTrainingDataFile); CvFileStorage * fileStorage; int i; // create a file-storage interface fileStorage = cvOpenFileStorage( mTrainingDataFile, 0, CV_STORAGE_READ ); if( !fileStorage ) { LOGE("Can't open facedata.xml\n"); return 0; } nEigens = cvReadIntByName(fileStorage, 0, "nEigens", 0); nTrainFaces = cvReadIntByName(fileStorage, 0, "nTrainFaces", 0); trainPersonNumMat = (CvMat *)cvReadByName(fileStorage, 0, "trainPersonNumMat", 0); eigenValMat = (CvMat *)cvReadByName(fileStorage, 0, "eigenValMat", 0); projectedTrainFaceMat = (CvMat *)cvReadByName(fileStorage, 0, "projectedTrainFaceMat", 0); pAvgTrainImg = (IplImage *)cvReadByName(fileStorage, 0, "avgTrainImg", 0); eigenVectArr = (IplImage **)cvAlloc(nTrainFaces*sizeof(IplImage *)); for(i=0; i<nEigens; i++) { char varname[200]; sprintf( varname, "eigenVect_%d", i ); eigenVectArr[i] = (IplImage *)cvReadByName(fileStorage, 0, varname, 0); } // release the file-storage interface cvReleaseFileStorage( &fileStorage ); return 1; }
void ReadFeature( char* fileName, FEATURE* feature){ CvFileStorage* fs = cvOpenFileStorage( fileName, 0, CV_STORAGE_READ, NULL); if (fs==NULL){ fprintf(stderr, "can't open feature file!\n"); return; } feature->radius = cvReadIntByName(fs, NULL, "radius", RADIUS); feature->neighbors = cvReadIntByName(fs, NULL, "neighbors", NEIGHBORS); feature->grid_x = cvReadIntByName(fs, NULL, "grid_x", GRID_X); feature->grid_y = cvReadIntByName(fs, NULL, "grid_y", GRID_Y); feature->num_faces = cvReadIntByName(fs, NULL, "num_faces", 0); char faceid[1024]; char id[20]; feature->histogram = (CvMat**) malloc(feature->num_faces*sizeof(CvMat*)); for (int i=0; i<feature->num_faces; i++){ strcpy(faceid, "face-"); sprintf(id, "%d", i); strcat(faceid, id); feature->histogram[i] = cvReadByName(fs, NULL, faceid, NULL); } if (HUELBP_ON){ feature->hue_histogram = (CvMat**) malloc(feature->num_faces*sizeof(CvMat*)); for (int i=0; i<feature->num_faces; i++){ strcpy(faceid, "hue-face-"); sprintf(id, "%d", i); strcat(faceid, id); feature->hue_histogram[i] = cvReadByName(fs, NULL, faceid, NULL); } } cvReleaseFileStorage( &fs ); }
// Open the training data from the file 'facedata.xml'. int loadTrainingData(CvMat ** pTrainPersonNumMat) { CvFileStorage * fileStorage; int i; // create a file-storage interface fileStorage = cvOpenFileStorage( facedata, 0, CV_STORAGE_READ ); if( !fileStorage ) { printf("Can't open training database file 'facedata.xml'.\n"); return 0; } // Load the person names. Added by Shervin. personNames.clear(); // Make sure it starts as empty. nPersons = cvReadIntByName( fileStorage, 0, "nPersons", 0 ); if (nPersons == 0) { printf("No people found in the training database 'facedata.xml'.\n"); return 0; } // Load each person's name. for (i=0; i<nPersons; i++) { string sPersonName; char varname[200]; sprintf( varname, "personName_%d", (i+1) ); sPersonName = cvReadStringByName(fileStorage, 0, varname ); personNames.push_back( sPersonName ); } // Load the data nEigens = cvReadIntByName(fileStorage, 0, "nEigens", 0); nTrainFaces = cvReadIntByName(fileStorage, 0, "nTrainFaces", 0); *pTrainPersonNumMat = (CvMat *)cvReadByName(fileStorage, 0, "trainPersonNumMat", 0); eigenValMat = (CvMat *)cvReadByName(fileStorage, 0, "eigenValMat", 0); projectedTrainFaceMat = (CvMat *)cvReadByName(fileStorage, 0, "projectedTrainFaceMat", 0); pAvgTrainImg = (IplImage *)cvReadByName(fileStorage, 0, "avgTrainImg", 0); eigenVectArr = (IplImage **)cvAlloc(nTrainFaces*sizeof(IplImage *)); for(i=0; i<nEigens; i++) { char varname[200]; sprintf( varname, "eigenVect_%d", i ); eigenVectArr[i] = (IplImage *)cvReadByName(fileStorage, 0, varname, 0); } // release the file-storage interface cvReleaseFileStorage( &fileStorage ); printf("Training data loaded (%d training images of %d people):\n", nTrainFaces, nPersons); printf("People: "); if (nPersons > 0) printf("<%s>", personNames[0].c_str()); for (i=1; i<nPersons; i++) { printf(", <%s>", personNames[i].c_str()); } printf(".\n"); return 1; }
void loadremap(CvMat* l_remap0, CvMat* l_remap1, CvMat* r_remap0, CvMat* r_remap1) { /* * Load remap information from saved remap.yml file, * which is generated by stereo calibration function from c++. * Because write a pure C-based one is too f*****g stupid. */ CvFileStorage *fs = cvOpenFileStorage("remap.yml", 0, CV_STORAGE_READ, NULL); l_remap0 = cvReadByName(fs, NULL, "left_remap0", NULL); l_remap1 = cvReadByName(fs, NULL, "left_remap1", NULL); r_remap0 = cvReadByName(fs, NULL, "right_remap0", NULL); r_remap1 = cvReadByName(fs, NULL, "right_remap1", NULL); if (l_remap0 == NULL || l_remap1 == NULL || r_remap0 == NULL || r_remap1 == NULL) { printf("what the f**k dude why is this happenening I hate my life.\n"); } }
int main (int argc, char *argv[]) { IplImage *img; CvFileStorage *fs; CvSeq* seq; CvMemStorage *str; int N,i; parse_args(argc,argv); str = cvCreateMemStorage(0); img = cvCreateImage(cvSize(WIDTH,HEIGHT), 8, 3); cvZero(img); fs = cvOpenFileStorage(infile, str, CV_STORAGE_READ, NULL); assert(fs); N = cvReadIntByName(fs, NULL, "N", 0); seq = cvReadByName(fs, NULL, "seq", 0); printf("N=%d\n", N); for (i=0; i<seq->total; i++) { CvPoint p; p = *(CvPoint*)cvGetSeqElem(seq, i); cvCircle(img, p, R, CV_RGB(255,0,0), -1, 8, 0); } cvShowImage("proto", img); cvWaitKey(0); cvReleaseFileStorage(&fs); cvReleaseImage(&img); return 0; }
int main(int argc, const char * argv[]) { CvMat *cmatrix = cvCreateMat(5,5,CV_32FC1); float element_3_2 = 7.7; *((float*)CV_MAT_ELEM_PTR( *cmatrix, 3,2) ) = element_3_2; cvmSet(cmatrix,4,4,0.5000); cvSetReal2D(cmatrix,3,3,0.5000); CvFileStorage* fs1 = cvOpenFileStorage("cfg.xml", 0, CV_STORAGE_WRITE); cvWriteInt( fs1, "frame_count", 10 ); cvStartWriteStruct( fs1, "frame_size", CV_NODE_SEQ ); cvWriteInt( fs1 , 0, 320 ); cvWriteInt( fs1 , 0, 200 ); cvEndWriteStruct( fs1 ); cvWrite( fs1, "color_cvt_matrix", cmatrix ); cvReleaseFileStorage( &fs1 ); CvFileStorage* fs2 = cvOpenFileStorage("cfg.xml", 0, CV_STORAGE_READ); int frame_count = cvReadIntByName( fs2 , 0, "frame_count"); CvSeq* s = cvGetFileNodeByName( fs2,0,"frame_size" )->data.seq; int frame_width = cvReadInt( (CvFileNode*)cvGetSeqElem(s,0) ); int frame_height = cvReadInt( (CvFileNode*)cvGetSeqElem(s,1) ); CvMat* color_cvt_matrix = (CvMat*) cvReadByName( fs2, 0 , "color_cvt_matrix"); printf("color_cvt_matrix: width=%d, height=%d\n",color_cvt_matrix->width, color_cvt_matrix->height ); printf("frame_count=%d, frame_width=%d, frame_height=%d\n",frame_count,frame_width,frame_height); cvReleaseFileStorage( &fs2 ); return 0; }
bool CameraParameters::loadParameters(const char* filename){ CvFileStorage* fstorage = 0; fstorage = cvOpenFileStorage(filename, NULL, CV_STORAGE_READ); if(!fstorage) return false; this->m_mat_camera_matrix = cvCloneMat( (CvMat*) cvReadByName(fstorage, 0, CAMERA_MATRIX_TAG)); this->m_mat_distortion_coeff = cvCloneMat((CvMat*) cvReadByName(fstorage, 0, DISTORTION_COEF_TAG)); cvReleaseFileStorage(&fstorage); return true; }
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; }
bool CvMatrix::read( CvFileStorage* fs, const char* mapname, const char* matname ) { void* obj = 0; CvMat* m = 0; if( mapname ) { CvFileNode* mapnode = cvGetFileNodeByName( fs, 0, mapname ); if( !mapnode ) obj = cvReadByName( fs, mapnode, matname ); } else obj = cvReadByName( fs, 0, matname ); m = icvRetrieveMatrix(obj); set( m, false ); return m != 0; }
bool CvImage::read( CvFileStorage* fs, const char* mapname, const char* imgname ) { void* obj = 0; IplImage* img = 0; if( mapname ) { CvFileNode* mapnode = cvGetFileNodeByName( fs, 0, mapname ); if( !mapnode ) obj = cvReadByName( fs, mapnode, imgname ); } else obj = cvReadByName( fs, 0, imgname ); img = icvRetrieveImage(obj); attach( img ); return img != 0; }
void CvGBTrees::read_params( CvFileStorage* fs, CvFileNode* fnode ) { CV_FUNCNAME( "CvGBTrees::read_params" ); __BEGIN__; CvFileNode* temp; if( !fnode || !CV_NODE_IS_MAP(fnode->tag) ) return; data = new CvDTreeTrainData(); CV_CALL( data->read_params(fs, fnode)); data->shared = true; params.max_depth = data->params.max_depth; params.min_sample_count = data->params.min_sample_count; params.max_categories = data->params.max_categories; params.priors = data->params.priors; params.regression_accuracy = data->params.regression_accuracy; params.use_surrogates = data->params.use_surrogates; temp = cvGetFileNodeByName( fs, fnode, "loss_function" ); if( !temp ) EXIT; if( temp && CV_NODE_IS_STRING(temp->tag) ) { const char* loss_function_type_str = cvReadString( temp, "" ); params.loss_function_type = strcmp( loss_function_type_str, "SquaredLoss" ) == 0 ? SQUARED_LOSS : strcmp( loss_function_type_str, "AbsoluteLoss" ) == 0 ? ABSOLUTE_LOSS : strcmp( loss_function_type_str, "HuberLoss" ) == 0 ? HUBER_LOSS : strcmp( loss_function_type_str, "DevianceLoss" ) == 0 ? DEVIANCE_LOSS : -1; } else params.loss_function_type = cvReadInt( temp, -1 ); if( params.loss_function_type < SQUARED_LOSS || params.loss_function_type > DEVIANCE_LOSS || params.loss_function_type == 2) CV_ERROR( CV_StsBadArg, "Unknown loss function" ); params.weak_count = cvReadIntByName( fs, fnode, "ensemble_length" ); params.shrinkage = (float)cvReadRealByName( fs, fnode, "shrinkage", 0.1 ); params.subsample_portion = (float)cvReadRealByName( fs, fnode, "subsample_portion", 1.0 ); if (data->is_classifier) { class_labels = (CvMat*)cvReadByName( fs, fnode, "class_labels" ); if( class_labels && !CV_IS_MAT(class_labels)) CV_ERROR( CV_StsParseError, "class_labels must stored as a matrix"); } data->is_classifier = 0; __END__; }
void CvANN_MLP::read( CvFileStorage* fs, CvFileNode* node ) { CvMat* _layer_sizes = 0; CV_FUNCNAME( "CvANN_MLP::read" ); __BEGIN__; CvFileNode* w; CvSeqReader reader; int i, l_count; _layer_sizes = (CvMat*)cvReadByName( fs, node, "layer_sizes" ); CV_CALL( create( _layer_sizes, SIGMOID_SYM, 0, 0 )); l_count = layer_sizes->cols; CV_CALL( read_params( fs, node )); w = cvGetFileNodeByName( fs, node, "input_scale" ); if( !w || CV_NODE_TYPE(w->tag) != CV_NODE_SEQ || w->data.seq->total != layer_sizes->data.i[0]*2 ) CV_ERROR( CV_StsParseError, "input_scale tag is not found or is invalid" ); CV_CALL( cvReadRawData( fs, w, weights[0], "d" )); w = cvGetFileNodeByName( fs, node, "output_scale" ); if( !w || CV_NODE_TYPE(w->tag) != CV_NODE_SEQ || w->data.seq->total != layer_sizes->data.i[l_count-1]*2 ) CV_ERROR( CV_StsParseError, "output_scale tag is not found or is invalid" ); CV_CALL( cvReadRawData( fs, w, weights[l_count], "d" )); w = cvGetFileNodeByName( fs, node, "inv_output_scale" ); if( !w || CV_NODE_TYPE(w->tag) != CV_NODE_SEQ || w->data.seq->total != layer_sizes->data.i[l_count-1]*2 ) CV_ERROR( CV_StsParseError, "inv_output_scale tag is not found or is invalid" ); CV_CALL( cvReadRawData( fs, w, weights[l_count+1], "d" )); w = cvGetFileNodeByName( fs, node, "weights" ); if( !w || CV_NODE_TYPE(w->tag) != CV_NODE_SEQ || w->data.seq->total != l_count - 1 ) CV_ERROR( CV_StsParseError, "weights tag is not found or is invalid" ); cvStartReadSeq( w->data.seq, &reader ); for( i = 1; i < l_count; i++ ) { w = (CvFileNode*)reader.ptr; CV_CALL( cvReadRawData( fs, w, weights[i], "d" )); CV_NEXT_SEQ_ELEM( reader.seq->elem_size, reader ); } __END__; }
int Eigenfaces::loadConfig(const string& dir) { d->configFile = dir + string("/libface-config.xml"); if (DEBUG) cout << "Load training data" << endl; CvFileStorage* fileStorage = cvOpenFileStorage(d->configFile.data(), 0, CV_STORAGE_READ); cout << "opened" << endl; if (!fileStorage) { if (DEBUG) cout << "Can't open config file for reading :" << d->configFile << endl; return 1; } //d->clearTrainingStructures(); int nIds = cvReadIntByName(fileStorage, 0, "nIds", 0), i; d->FACE_WIDTH = cvReadIntByName(fileStorage, 0, "FACE_WIDTH",d->FACE_WIDTH); d->FACE_HEIGHT = cvReadIntByName(fileStorage, 0, "FACE_HEIGHT",d->FACE_HEIGHT); d->THRESHOLD = cvReadRealByName(fileStorage, 0, "THRESHOLD", d->THRESHOLD); //LibFaceUtils::printMatrix(d->projectedTrainFaceMat); for ( i = 0; i < nIds; i++ ) { char facename[200]; sprintf(facename, "person_%d", i); d->faceImgArr.push_back( (IplImage*)cvReadByName(fileStorage, 0, facename, 0) ); } for ( i = 0; i < nIds; i++ ) { char idname[200]; sprintf(idname, "id_%d", i); d->indexMap.push_back( cvReadIntByName(fileStorage, 0, idname, 0)); } // Release file storage cvReleaseFileStorage(&fileStorage); return 0; }
int CvOneWayDescriptor::ReadByName(CvFileStorage* fs, CvFileNode* parent, const char* name) { CvMat* mat = (CvMat*)cvReadByName(fs, parent, name); if(!mat) { return 0; } for(int i = 0; i < m_pose_count; i++) { for(int y = 0; y < m_samples[i]->height; y++) { for(int x = 0; x < m_samples[i]->width; x++) { float val = cvmGet(mat, i, y*m_samples[i]->width + x); *((float*)(m_samples[i]->imageData + y*m_samples[i]->widthStep) + x) = val; } } } cvReleaseMat(&mat); return 1; }
void CalTarget::load(CvFileStorage *in, CvFileNode *node) { point.load(in, cvGetFileNodeByName(in, node, "point")); image.reset((cv::Mat*) cvReadByName(in, node, "image")); origImage.reset((cv::Mat*) cvReadByName(in, node, "origImage")); }
void * cvReadByName_wrap(CvFileStorage * fs , const CvFileNode * map , const char * name , CvAttrList * attributes ){ return cvReadByName(/*CvFileStorage*//***/fs , /*const*//*CvFileNode*//***/map , /*const*//*char*//***/name , /*CvAttrList*//***/attributes); }
LKInverseComp::LKInverseComp(char *path) { CvFileStorage *fs; fs = cvOpenFileStorage(path, 0, CV_STORAGE_READ ); nA = (int)cvReadRealByName(fs, 0, "numberOfAppearanceEigenVectors", 0); nS = (int)cvReadRealByName(fs, 0, "numberOfShapeEigenVectors", 0); printf("%d %d \n",nS,nA); //nS=16; // //nA=2; //nS=4;/ nA=10; nA+=1; negNewParam = (float *)malloc(sizeof(float)*(nS+4)); negNewParamnS = (float *)malloc(sizeof(float)*(nS+4)); negNewParam4 = (float *)malloc(sizeof(float)*(nS+4)); ParamnS = (float *)malloc(sizeof(float)*(nS+4)); Param4 = (float *)malloc(sizeof(float)*(nS+4)); ptemp1 = (float *)malloc(sizeof(float)*(nS+4)); ptemp2 = (float *)malloc(sizeof(float)*(nS+4)); param = (float *) malloc((4+nS)*sizeof(float)); nonRigidShapeVectors=(IplImage**)cvAlloc(sizeof(IplImage*) * nS); appearanceVectors=(IplImage**)cvAlloc(sizeof(IplImage*) * nA); globalShapeVectors=(IplImage**)cvAlloc(sizeof(IplImage*) * 4); combineshapevectors=(IplImage**)cvAlloc(sizeof(IplImage*) * (4+nS)); srcShape =cvCreateImage(cvSize(totalnumberofpoints,1),IPL_DEPTH_64F,1); destShape =cvCreateImage(cvSize(totalnumberofpoints,1),IPL_DEPTH_64F,1); destShapeTemp =cvCreateImage(cvSize(totalnumberofpoints,1),IPL_DEPTH_64F,1); destShapewithoutQ =cvCreateImage(cvSize(totalnumberofpoints,1),IPL_DEPTH_64F,1); for (int m=0;m<(nS+4);m++) { combineshapevectors[m]=cvCreateImage(cvSize(totalnumberofpoints,1),IPL_DEPTH_64F,1); param[m]=0; negNewParam[m]=0; negNewParamnS[m]=0; negNewParam4[m]=0; ParamnS[m]=0; Param4[m]=0; ptemp1[m]=0; ptemp2[m]=0; } for (int m=0;m<4;m++) globalShapeVectors[m]=cvCreateImage(cvSize(totalnumberofpoints,1),IPL_DEPTH_64F,1); CvMat * meanShapeDel=cvCreateMat(numberofpoints,2,CV_64FC1); eigenVal= (CvMat *)cvReadByName( fs,0,"eigenVal",0 ); // minProjVal=(IplImage *)cvReadByName( fs,0,"minProjVal",0 ); // maxProjVal=(IplImage *)cvReadByName( fs,0,"maxProjVal",0 ); meanAppearance=(IplImage *)cvReadByName( fs,0,"avgApp",0 ); ErrorImage = cvCreateMat((meanAppearance->width*meanAppearance->height),1, CV_64FC1); IplImage* meanShapeTemp=(IplImage *)cvReadByName( fs,0,"avgShape",0 ); meanShape=cvCreateImage(cvSize(meanShapeTemp->width,meanShapeTemp->height),IPL_DEPTH_64F,1); cvConvertScale( meanShapeTemp,meanShape,1,0); for (int m=0;m<nS;m++) { char temp[200]; sprintf(temp,"shapeEigenVectors%d",m); nonRigidShapeVectors[m]=(IplImage *)cvReadByName( fs,0,temp,0 ); } for (int m=0;m<nA-1;m++) { char temp[200]; sprintf(temp,"appEigenVectors%d",m); appearanceVectors[m]=(IplImage *)cvReadByName( fs,0,temp,0 ); } appearanceVectors[nA-1]=cvCreateImage(cvSize(appearanceVectors[nA-2]->width,appearanceVectors[nA-2]->height),IPL_DEPTH_32F,1); for(int i=0;i<(appearanceVectors[nA-2]->width);i++) { for(int j=0;j<appearanceVectors[nA-2]->height;j++) { CvScalar s; s.val[0]=1; cvSet2D(appearanceVectors[nA-1],j,i,s); } } // IplImage * newImage = cvCreateImage(cvSize(meanAppearance->width,meanAppearance->height),IPL_DEPTH_8U,1); for (int m=0;m<nA;m++) { // cvZero(newImage); for (int i=0;i<meanAppearance->width;i++) { for (int j=0;j<meanAppearance->height;j++) { CvScalar s= cvGet2D(appearanceVectors[m],j,i); s.val[0]*=255; CvScalar s1= cvGet2D(meanAppearance,j,i); s.val[0]+=s1.val[0]; ////printf("%e \n",s.val[0]); // cvSet2D(newImage,j,i,s); } } // cvNamedWindow("yoyo",1); //cvShowImage("yoyo",newImage); // cvWaitKey(-1); } for (int m=0;m<numberofpoints;m++) { CvScalar s1,s2; s1=cvGet2D(meanShape,0,2*m); s2=cvGet2D(meanShape,0,2*m+1); cvSet2D(meanShapeDel,m,0,s1); cvSet2D(meanShapeDel,m,1,s2); cvSet2D(globalShapeVectors[0],0,2*m,s1); cvSet2D(globalShapeVectors[0],0,2*m+1,s2); cvSet2D(combineshapevectors[0],0,2*m,s1); cvSet2D(combineshapevectors[0],0,2*m+1,s2); s2.val[0]*=-1; cvSet2D(globalShapeVectors[1],0,2*m,s2); cvSet2D(globalShapeVectors[1],0,2*m+1,s1); cvSet2D(combineshapevectors[1],0,2*m,s2); cvSet2D(combineshapevectors[1],0,2*m+1,s1); CvScalar one,zero; one.val[0]=1; zero.val[0]=0; cvSet2D(globalShapeVectors[2],0,2*m,one); cvSet2D(globalShapeVectors[2],0,2*m+1,zero); cvSet2D(globalShapeVectors[3],0,2*m,zero); cvSet2D(globalShapeVectors[3],0,2*m+1,one); cvSet2D(combineshapevectors[2],0,2*m,one); cvSet2D(combineshapevectors[2],0,2*m+1,zero); cvSet2D(combineshapevectors[3],0,2*m,zero); cvSet2D(combineshapevectors[3],0,2*m+1,one); } for (int i=0;i<numberofpoints;i++) { CvScalar avx,avy; avx=cvGet2D( meanShapeDel, i,0); avy=cvGet2D( meanShapeDel, i,1); // ////printf("%e %e \n",avx.val[0],avy.val[0]); } newDelaunayShapeCompute= new delaunay(meanShapeDel); newDelaunay = new delaunay(meanShapeDel); newDelaunayInverse = new delaunay(meanShapeDel); for (int m=0;m<4;m++) { double val= cvNorm(globalShapeVectors[m],NULL , CV_L2, 0 ); cvConvertScale( globalShapeVectors[m],globalShapeVectors[m],1/val,0); ////printf(" %e \n",val); // cvConvertScale( combineshapevectors[m],combineshapevectors[m],val,0); } for (int m=4;m<(nS+4);m++) { for (int j=0;j<totalnumberofpoints;j++) { CvScalar s1 = cvGet2D(nonRigidShapeVectors[m-4],0,j); cvSet2D(combineshapevectors[m],0,j,s1); } } for (int m=0;m<nS+4;m++) { double val= cvNorm(combineshapevectors[m],NULL , CV_L2, 0 ); cvConvertScale( combineshapevectors[m],combineshapevectors[m],1/val,0); ////printf(" %e \n",val); // cvConvertScale( combineshapevectors[m],combineshapevectors[m],val,0); } for (int m=0;m<nA;m++) { double val= cvNorm(appearanceVectors[m],NULL , CV_L2, 0 ); cvConvertScale( appearanceVectors[m],appearanceVectors[m],1/val,0); // //printf(" %e \n",val); } ////printf("%d %d \n",meanAppearance->width,meanAppearance->height); totalNumberOfPixels=newDelaunay->numberOfPixels(); interpolateMean=(float*)malloc(sizeof(float)*totalNumberOfPixels); for (int i=0;i<totalNumberOfPixels;i++) { interpolateMean[i]=0; pixel * pix = newDelaunay->getpixel(i); interpolateMean[i]=interpolate<float>(meanAppearance,double(pix->x+pix->tx),double(pix->y+pix->ty)); } preCompute(); ////printf("%d %d \n",meanAppearance->width,meanAppearance->height); // preCompute(); }