Machine Imagination Technologies
マシン 想像力 テクノロジー

 

Useful Sample C++ Codes

 

estimating time ============
double dtime()
{
#ifdef LINUX
    struct timeval tv;
    gettimeofday(&tv, NULL);
    return ((double)tv.tv_sec + ((double)tv.tv_usec*1.0e-6));
#else //VS studio
    time_t ltime;
    time(&ltime);
    struct timeb tmb;
    ftime(&tmb);
    double sec = (double)(ltime);
    double milisec = (double)tmb.millitm;
    return (sec + milisec/1000); 
#endif
}
============
Read index files std::vector<int> test_image_class_order;
FILE *f = fopen(indexFile, "r");
char imgname[255];
int imgClass = -1;

while (fscanf(f, "%s %i", imgname, &imgClass) > 0)
{
    string iname(imgname);
    test_image_class_order.push_back(imgClass);
    test_image_name.push_back(iname); // filename
}
fclose(f);
   
   
   
   
   
   
   

 

 

 

Copyright©2016 Machine Imagination Technologies. All rights reserved.