int main(int argc, char* argv[]) { /* Arguments */ if ( argc != 2 ) { printf("\nUsage: %s <file>\n\n", argv[0]); exit(0); } pgm_t* src = pgm_read(argv[1]); dmap_t* sobx = sobel_x(src); dmap_t* soby = sobel_y(src); dmap_t* sobm = magnitude(src, sobx, soby); dmap_t* mxx = multiply(src, sobx, sobx); dmap_t* myy = multiply(src, soby, soby); dmap_t* mxy = multiply(src, sobx, soby); dmap_t* mxxf = binomial_filter(mxx); dmap_t* myyf = binomial_filter(myy); dmap_t* mxyf = binomial_filter(mxy); dmap_t* harris1 = harris(src, mxxf, myyf, mxyf, 1); dmap_t* harris1f = harris(src, mxxf, myyf, mxyf, 1); dmap_write(sobx, argv[1], "sobel_x"); dmap_write(soby, argv[1], "sobel_y"); dmap_write(sobm, argv[1], "sobel_magnitude"); dmap_write(mxx, argv[1], "xx"); dmap_write(myy, argv[1], "yy"); dmap_write(mxy, argv[1], "xy"); dmap_write(mxxf, argv[1], "xxf"); dmap_write(myyf, argv[1], "yyf"); dmap_write(mxyf, argv[1], "xyf"); dmap_write(harris1, argv[1], "harris1"); dmap_write(harris1f, argv[1], "harris1f"); pgm_free(src); dmap_free(sobx); dmap_free(soby); dmap_free(sobm); dmap_free(mxx); dmap_free(myy); dmap_free(mxy); dmap_free(harris1); return 0; }
// ・占有数を持つファイルを作る // ・必要なら初期MOのファイルと、規格直交表現の初期MOを作り、ファイルに保存する // ・必要なら密度行列からRou1を作る // ・Rou1からMyu1, Nyu1を作る void DfPreScf::prepareGuess() { switch (this->initialGuessType_) { case GUESS_LCAO: { switch (this->m_nMethodType) { case METHOD_RKS: this->createInitialGuessUsingLCAO(RUN_RKS); break; case METHOD_UKS: this->createInitialGuessUsingLCAO(RUN_UKS_ALPHA); this->createInitialGuessUsingLCAO(RUN_UKS_BETA); break; case METHOD_ROKS: this->createInitialGuessUsingLCAO(RUN_ROKS); break; default: CnErr.abort(); break; } } break; case GUESS_RHO: case GUESS_DENSITY: { switch (this->m_nMethodType) { case METHOD_RKS: this->createOccupation(RUN_RKS); break; case METHOD_UKS: this->createOccupation(RUN_UKS_ALPHA); this->createOccupation(RUN_UKS_BETA); break; case METHOD_ROKS: this->createOccupation(RUN_ROKS); break; default: CnErr.abort(); break; } } break; case GUESS_HUCKEL: // go below case GUESS_CORE: { DfInitialGuessHuckel huckel(this->pPdfParam_); } break; case GUESS_HARRIS: { switch (this->m_nMethodType) { case METHOD_RKS: { DfInitialGuessHarris harris(this->pPdfParam_); harris.main(); } break; case METHOD_UKS: this->logger( "Sorry. harris method is not supported except RKS. stop.\n"); CnErr.abort(); break; case METHOD_ROKS: this->logger( "Sorry. harris method is not supported except RKS. stop.\n"); CnErr.abort(); break; default: CnErr.abort(); break; } } break; default: { this->logger("**** Error :: DfPreScf \n"); this->logger(" Inputted scf-start-guess is wrong.\n"); CnErr.abort(); } break; } }
int deplacement_zero() { #ifdef DEBUG2 printf("entrer deplacement_zero odile.c\n"); #endif #ifdef DEBUGIA1 struct timeval start,stop,res; #endif open_capture(0,160,120); if ( !capture ) { fprintf( stderr, "ERROR: capture is NULL \n" ); getchar(); return -1; } //recuperation d une premiere image pour avoir les dimensions IplImage* frame = cvQueryFrame( capture ); //recuperation des dimensions de l image CvSize taille = cvGetSize(frame); int tailleInt = taille.width * taille.height; //creation des image et matrices intermediaires IplImage* frameGray = cvCreateImage(taille,8,1); float* matriceGradX = malloc(sizeof(float)*tailleInt); float* matriceGradY = malloc(sizeof(float)*tailleInt); float* matriceHarris= malloc(sizeof(float)*tailleInt); float** tabHarris = (float **)malloc(sizeof(float*)*_NBHARRIS); float** tabHarrisPrec = (float **)malloc(sizeof(float*)*_NBHARRIS); char * imageData; int j; for(j=0;j<_NBHARRIS;j++) { tabHarris[j]=(float*)malloc(sizeof(float)*3); } for(j=0;j<_NBHARRIS;j++) { tabHarrisPrec[j]=(float*)malloc(sizeof(float)*3); } vecteur *tabVect = (vecteur*) malloc(sizeof(vecteur)*_NBHARRIS); vecteur vecteurMoy; vecteurMoy.x = 0; vecteurMoy.y=0; int nbVect = 0; while(status == MODE_AUTO) { #ifdef DEBUGIA1 gettimeofday(&start,NULL); #endif //Recuperation de l image de la camera frame = cvQueryFrame( capture ); if ( ! frame ) { fprintf( stderr, "ERROR: pas d'image\n" ); return -1; } imageData = frameGray->imageData; //Passage en niveau de gris RGBTOGRAY_1CANAL(frame, frameGray); //Sobel pour les gradients SobelHV(imageData,taille.height, taille.width, matriceGradX, matriceGradY); //Detecteur de Harris harris(matriceHarris, matriceGradX, matriceGradY, tailleInt); //Maxima de Harris getMaxima(matriceHarris, taille.height, taille.width, tabHarris, _NBHARRIS); //Matching des points pour trouver les vecteurs nbVect = calcul_vecteur_interet(tabHarrisPrec, tabHarris, _NBHARRIS, _SEUIL_DISTANCE, tabVect); //Moyenne des vecteurs calcul_moyenne_vecteur(tabVect, nbVect,&vecteurMoy); for(j=0;j<_NBHARRIS;j++) { tabHarrisPrec[j][0] = tabHarris[j][0]; tabHarrisPrec[j][1] = tabHarris[j][1]; tabHarrisPrec[j][2] = tabHarris[j][2]; } #ifdef DEBUGIA1 printf("nbVecteur Match = %d \nVecteur moyen = %d %d\n",nbVect,vecteurMoy.x,vecteurMoy.y); gettimeofday(&stop,NULL); timersub(&stop, &start, &res); printf("time Harris= %d %d\n",(int)res.tv_sec, (int)res.tv_usec); #endif pilote_IA(vecteurMoy,1000, 255); } cvReleaseCapture( &capture ); #ifdef DEBUG2 printf("FIN deplacement_zero odile.c\n"); #endif return 0; }
int prise_photo() { #ifdef DEBUG2 printf("entrer prise_photo odile.c\n"); #endif struct timeval start,stop,res; open_capture(0,160,120); if ( !capture ) { fprintf( stderr, "ERROR: capture is NULL \n" ); getchar(); return -1; } //recuperation d une premiere image pour avoir les dimensions IplImage* frame = cvQueryFrame( capture ); //recuperation des dimensions de l image CvSize taille = cvGetSize(frame); int tailleInt = taille.width * taille.height; //creation des image et matrices intermediaires IplImage* frameGray = cvCreateImage(taille,8,1); float* matriceGradX = malloc(sizeof(float)*tailleInt); float* matriceGradY = malloc(sizeof(float)*tailleInt); float* matriceHarris= malloc(sizeof(float)*tailleInt); float** tabHarris = (float **)malloc(sizeof(float*)*_NBHARRIS); char * imageData; char* buffer = (char*) malloc(sizeof(char)*20); int i=0,j; for(j=0;j<_NBHARRIS;j++) { tabHarris[j]=(float*)malloc(sizeof(float)*3); } while(i < 30) { //Recuperation de l image de la camera frame = cvQueryFrame( capture ); if ( ! frame ) { fprintf( stderr, "ERROR: pas d'image\n" ); return -1; } imageData = frameGray->imageData; gettimeofday(&start,NULL); //Passage en niveau de gris RGBTOGRAY_1CANAL(frame, frameGray); //Sobel pour les gradients SobelHV(imageData,taille.height, taille.width, matriceGradX, matriceGradY); //Detecteur de Harris harris(matriceHarris, matriceGradX, matriceGradY, tailleInt); //Maxima de Harris getMaxima(matriceHarris, taille.height, taille.width, tabHarris, _NBHARRIS); for(j=0;j<_NBHARRIS;j++) { Dessine_croix(imageData,taille.height, taille.width,tabHarris[j][1],tabHarris[j][0]); } if(i > 19){ sprintf(buffer,"image%d.jpg",i-19); cvSaveImage(buffer,frameGray,0); } i++; gettimeofday(&stop,NULL); timersub(&stop, &start, &res); printf("time Harris = %i,%d sec i= %d\n",(int)res.tv_sec, (int)res.tv_usec,i); } cvReleaseCapture( &capture ); exit(0); #ifdef DEBUG2 printf("sortie prise_photo odile.c\n"); #endif return 0; }