int main(int argc, char** argv) { timer *tic, *toc; CImage *cimg=NULL; Image *mask=NULL; Histogram *hist=NULL; if (argc != 4) { fprintf(stderr,"usage: extrai_bic <image> <mask> <outputfile>\n"); exit(-1); } cimg = ReadJPEGFile(argv[1]); mask = ReadImage(argv[2]); tic = Tic(); hist = BIC(cimg, mask); toc = Toc(); printf("BIC extracted in %f milliseconds\n\n",CTime(tic, toc)); FILE *fp; fp = fopen(argv[3],"w"); if (fp == NULL) { fprintf(stderr,"Cannot open %s\n",argv[3]); exit(-1); } WriteFHist(hist, fp); DestroyCImage(&cimg); DestroyHistogram(&hist); DestroyImage(&mask); fclose(fp); return(0); }
double SNRM2( PyArrayObject *pyobj1, unsigned int shadersize, unsigned int *shader ) { Tic(); Operation_t op1; op1.shaderSize = shadersize; op1.EA_shader = shader; op1.obj[0] = pyobj1; op1.num_SPES = speThreads; float *results[6]; unsigned int state = 2, r; unsigned int i; //printf( "Sending states to SPEs\n" ); for ( i = 0 ; i < speThreads ; i++ ) { results[i] = (float *)memalign( 128, ( 4 + 127 ) & ~127 ); r = (unsigned int)results[i]; spe_pointer_addr[i][0] = (unsigned int)&op1; spe_in_mbox_write ( speData[i].spe_ctx, &state, 1, SPE_MBOX_ALL_BLOCKING ); spe_in_mbox_write ( speData[i].spe_ctx, &r, 1, SPE_MBOX_ALL_BLOCKING ); } // Waiting for SPEs! //printf( "Waiting for SPEs\n" ); unsigned int checked = 0; while( checked < speThreads ) { if ( spe_out_mbox_status( speData[checked].spe_ctx ) ) { spe_out_mbox_read( speData[checked].spe_ctx, &r, 1 ); checked++; } } float r1 = 0.0f; for ( i = 0 ; i < speThreads ; i++ ) { r1 += results[i][0]; // Cleanup free( results[i] ); } r1 = sqrtf( r1 ); double time = Toc_d(); PrintTicToc( "Finished at ", Toc() ); printf( "Result=%f\n", r1 ); return time; }
int main(int argc, char *argv[]) { Image *img[2]; Kernel *K; timer *t1, *t2; /*--------------------------------------------------------*/ void *trash = malloc(1); struct mallinfo info; int MemDinInicial, MemDinFinal; free(trash); info = mallinfo(); MemDinInicial = info.uordblks; /*--------------------------------------------------------*/ if (argc != 4) Error("Usage: linearfilter <input.scn> <output.scn> <adj. radius>","windowlevel.c"); t1 = Tic(); img[0] = ReadImage(argv[1]); K = GaussianKernel(atof(argv[3])); img[1] = LinearFilter(img[0],K); WriteImage(img[1],argv[2]); DestroyImage(img[0]); DestroyImage(img[1]); DestroyKernel(K); t2 = Toc(); fprintf(stdout,"Linear filtering in %f ms\n",CompTime(t1,t2)); /* ------------------------------------------------------ */ info = mallinfo(); MemDinFinal = info.uordblks; if (MemDinInicial!=MemDinFinal) printf("\n\nDinamic memory was not completely deallocated (%d, %d)\n", MemDinInicial,MemDinFinal); return(0); }
void RUNSGEMM( unsigned int size ) { float *A = (float*)malloc( size*size*4 ); float *B = (float*)malloc( size*size*4 ); unsigned int i; for(i=0;i<size*size;i++) { A[i] = 1; B[i] = 1; } Tic(); cblas_sgemm( 101, 111, 111, size, size, size, -1, A, size, A, size, 1, B, size ); PrintTicToc( "Time taken: ", Toc() ); }
double SSCAL( PyArrayObject *pyobj1, PyArrayObject *pyscalar1, unsigned int shadersize, unsigned int *shader ) { Tic(); Operation_t op1; op1.shaderSize = shadersize; op1.EA_shader = shader; op1.obj[0] = pyobj1; op1.scalar[0] = pyscalar1; op1.num_SPES = speThreads; unsigned int state = 1, r; unsigned int i; //printf( "Sending states to SPEs\n" ); for ( i = 0 ; i < speThreads ; i++ ) { spe_pointer_addr[i][0] = (unsigned int)&op1; spe_in_mbox_write ( speData[i].spe_ctx, &state, 1, SPE_MBOX_ALL_BLOCKING ); } // Waiting for SPEs! //printf( "Waiting for SPEs\n" ); unsigned int checked = 0; while( checked < speThreads ) { if ( spe_out_mbox_status( speData[checked].spe_ctx ) ) { spe_out_mbox_read( speData[checked].spe_ctx, &r, 1 ); checked++; } } double time = Toc_d(); PrintTicToc( "Finished at ", Toc() ); for( i = 0 ; i < 3 ; i++ ) { printf( "%u=%f\n", i, ((float*)pyobj1->blockData[0])[i] ); } return time; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////// // da main int main( int argc, char** argv ) { // rpg::Robot Agnos; // Agnos.Init("../../RPG/dev/jmf/GwSim/rpg_config.xml"); // init driver CameraDevice Cam; Cam.SetProperty("Host", "localhost:5556"); Cam.InitDriver("NodeCam"); std::vector< rpg::ImageWrapper > Images; // Image to show on screen long unsigned int count = 0; double t = Tic(); while(1) { if( Cam.Capture(Images) ) { cv::imshow( "SimL", Images[0].Image ); // cv::imshow( "SimR", Images[1] ); } count ++; if(count > 5000) { break; } char c; c = cv::waitKey(2); if (c == 27) break; } double time = Toc(t); printf("Framerate %.2f\n",count/time); return 0; }
int main(int argc, char *argv[]){ int sockfd, n; timer *t1, *t2; struct sockaddr_in servaddr, cliaddr; struct hostent *hp; char sendline[9999]; char recvline[9999], resp[9999]; if (argc != 3) { printf("usage: ./clientUDP <IP address> <port>\n"); exit(1); } sprintf(resp, "\nChoose an option:\nCheck Position: [Position [posX,posY]]\n1 - All registered merchants: [1]\n2 - All merchants within 100 meters radius: [2 posX posY]\n3 - Merchants in 100 meters area with category: [3 posX posY category]\n4 - Merchant info (id): [4 merchantId]\n5 - Punctuate merchant: [5 merchantId newPoints]\n\n"); printf("%s", resp); char *host = argv[1]; /* ip */ int port = atoi(argv[2]); /* port */ hp = gethostbyname(host); sockfd = socket(AF_INET, SOCK_DGRAM, 0); bzero(&servaddr, sizeof(servaddr)); servaddr.sin_family = AF_INET; bcopy(hp->h_addr, (char *) &servaddr.sin_addr.s_addr, hp->h_length); servaddr.sin_port = htons(port); while (fgets(sendline, 10000,stdin) != NULL) { t1 = Tic(); sendto(sockfd, sendline, strlen(sendline), 0, (struct sockaddr *)&servaddr, sizeof(servaddr)); n = recvfrom(sockfd, recvline, 9999, 0, NULL, NULL); recvline[n] = '\0'; fputs(recvline, stdout); t2 = Toc(); fprintf(stdout, "Message sent and received in %f ms\n", CompTime(t1,t2)); } }
int main(int argc, char **argv) { timer *t1=NULL,*t2=NULL; Image *img=NULL,*grad=NULL; ImageForest *fst=NULL; CImage *cimg=NULL; Set *Obj=NULL,*Bkg=NULL; char outfile[100]; char *file_noext; /*--------------------------------------------------------*/ void *trash = malloc(1); struct mallinfo info; int MemDinInicial, MemDinFinal; free(trash); info = mallinfo(); MemDinInicial = info.uordblks; /*--------------------------------------------------------*/ if (argc!=4){ fprintf(stderr,"Usage: diffwatershed <image.pgm> <gradient.pgm> <seeds.txt>\n"); fprintf(stderr,"image.pgm: image to overlay the watershed lines on it\n"); fprintf(stderr,"gradient.pgm: gradient image to compute the watershed segmentation\n"); fprintf(stderr,"seeds.txt: seed pixels\n"); exit(-1); } img = ReadImage(argv[1]); grad = ReadImage(argv[2]); ReadSeeds(argv[3],&Obj,&Bkg); fst = CreateImageForest(img); file_noext = strtok(argv[1],"."); // Add object and background seeds t1 = Tic(); DiffWatershed(grad,fst,Obj,Bkg,NULL); t2 = Toc(); fprintf(stdout,"Adding object and background seeds in %f ms\n",CTime(t1,t2)); cimg = DrawLabeledRegions(img,fst->label); sprintf(outfile,"%s_result-a.ppm",file_noext); WriteCImage(cimg,outfile); DestroyCImage(&cimg); // Remove background trees t1 = Tic(); DiffWatershed(grad,fst,NULL,NULL,Bkg); t2 = Toc(); fprintf(stdout,"Removing background trees in %f ms\n",CTime(t1,t2)); cimg = DrawLabeledRegions(img,fst->label); sprintf(outfile,"%s_result-b.ppm",file_noext); WriteCImage(cimg,outfile); DestroyCImage(&cimg); // Adding background trees back to the forest t1 = Tic(); DiffWatershed(grad,fst,NULL,Bkg,NULL); t2 = Toc(); fprintf(stdout,"Adding the removed background trees in %f ms\n",CTime(t1,t2)); cimg = DrawLabeledRegions(img,fst->label); sprintf(outfile,"%s_result-c.ppm",file_noext); WriteCImage(cimg,outfile); DestroyCImage(&cimg); DestroyImageForest(&fst); DestroyImage(&img); DestroyImage(&grad); DestroySet(&Obj); DestroySet(&Bkg); /* ---------------------------------------------------------- */ info = mallinfo(); MemDinFinal = info.uordblks; if (MemDinInicial!=MemDinFinal) printf("\n\nDinamic memory was not completely deallocated (%d, %d)\n", MemDinInicial,MemDinFinal); return(0); }
void CTRCalibration::PrintOnConsole(double error, double max_error, int iter, double step, double error_val) { double time_taken = Toc(); double time_left = (m_maxIter - iter) * time_taken/60.0/(double)iter; ::std::cout << "iter:" << iter << " " << "mean_error (train):" << error << ", mean_error (val):" << error_val << " step:" << step << " Estimated Time left:" << time_left << ::std::endl; }
double SDOT2( PyArrayObject *pyobj1, PyArrayObject *pyobj2, unsigned int shadersize, unsigned int *shader ) { Operation_t op1; op1.shaderSize = shadersize; op1.EA_shader = shader; op1.obj[0] = pyobj1; op1.obj[1] = pyobj2; op1.num_SPES = speThreads; unsigned int state = 4; unsigned int i, r; unsigned int checked = 0; float *results[6]; // Setup SPEs for ( i = 0 ; i < speThreads ; i++ ) { results[i] = (float *)memalign( 128, ( 4 + 127 ) & ~127 ); r = (unsigned int)results[i]; spe_pointer_addr[i][0] = (unsigned int)&op1; spe_in_mbox_write ( speData[i].spe_ctx, &state, 1, SPE_MBOX_ALL_BLOCKING ); spe_in_mbox_write ( speData[i].spe_ctx, &r, 1, SPE_MBOX_ALL_BLOCKING ); } // Waiting for SPEs! while( checked < speThreads ) { if ( spe_out_mbox_status( speData[checked].spe_ctx ) ) { spe_out_mbox_read( speData[checked].spe_ctx, &r, 1 ); checked++; } } Tic(); // Make SPEs run state = 6; for ( i = 0 ; i < speThreads ; i++ ) { spe_in_mbox_write ( speData[i].spe_ctx, &state, 1, SPE_MBOX_ALL_BLOCKING ); } // Waiting for SPEs! checked = 0; while( checked < speThreads ) { if ( spe_out_mbox_status( speData[checked].spe_ctx ) ) { spe_out_mbox_read( speData[checked].spe_ctx, &r, 1 ); checked++; } } // Get result float r1 = 0.0f; for ( i = 0 ; i < speThreads ; i++ ) { r1 += results[i][0]; // Cleanup free( results[i] ); } double time = Toc_d(); PrintTicToc( "Finished at ", Toc() ); printf( "Result=%f\n", r1 ); return time; }
// ------------------------------------------------------------------------- // API :: DiscursiveTime::PrintToc // PURPOSE :: prints a 'toc' value, the second of a time pair // :: prints value of matching pair to ticType // PARAMETERS :: std::string ticType - the name of the tic value to compare to // RETURN :: None // ------------------------------------------------------------------------- void DiscursiveTime::PrintToc(std::string ticType) { struct timeval resultValue = Toc(ticType); DiscursivePrint("Elapsed : %ld seconds, %ld microseconds\n", resultValue.tv_sec,resultValue.tv_usec); };
int main(int argc, char **argv) { timer *t1=NULL,*t2=NULL; Image *img=NULL,*grad=NULL,*marker=NULL; Image *label=NULL; CImage *cimg=NULL; AdjRel *A=NULL; char outfile[100]; char *file_noext; /*--------------------------------------------------------*/ void *trash = malloc(1); struct mallinfo info; int MemDinInicial, MemDinFinal; free(trash); info = mallinfo(); MemDinInicial = info.uordblks; /*--------------------------------------------------------*/ if (argc!=4){ fprintf(stderr,"Usage: watergray <image.pgm> <gradient.pgm> <H>\n"); fprintf(stderr,"image.pgm: grayscale image to overlay the watershed lines on it\n"); fprintf(stderr,"gradient.pgm: gradient image to compute the watershed segmentation\n"); fprintf(stderr,"H: an integer that will be added to the gradient to eliminate irrelevant basins (typically <= 100)\n"); exit(-1); } img = ReadImage(argv[1]); grad = ReadImage(argv[2]); file_noext = strtok(argv[1],"."); // A grayscale marker can be created by any extensive operation: // A value H may be added to eliminate irrelevant basins, for instance. marker = AddValue(grad,atoi(argv[3])); // Watershed from grayscale marker A = Circular(1.0); // try also higher adjacency radii: 1.5, 2.5, etc. t1 = Tic(); label = WaterGray(grad,marker,A); t2 = Toc(); fprintf(stdout,"Processing time in %f ms\n",CTime(t1,t2)); // Draw watershed lines cimg = DrawLabeledRegions(img,label); sprintf(outfile,"%s_result.ppm",file_noext); WriteCImage(cimg,outfile); DestroyImage(&grad); DestroyImage(&img); DestroyImage(&marker); DestroyCImage(&cimg); DestroyImage(&label); DestroyAdjRel(&A); /* ---------------------------------------------------------- */ info = mallinfo(); MemDinFinal = info.uordblks; if (MemDinInicial!=MemDinFinal) printf("\n\nDinamic memory was not completely deallocated (%d, %d)\n", MemDinInicial,MemDinFinal); return(0); }