[ASIFT 1] Load images

来源:互联网 发布:动态分配二维数组 编辑:程序博客网 时间:2024/06/10 09:43

int main(int argc, char**argv[]){ if ((argc != 8) && (argc != 9)) {          std::cerr << " ******************************************************************************* " << std::endl                    << " ***************************  ASIFT image matching  **************************** " << std::endl                    << " ******************************************************************************* " << std::endl                    << "Usage: " << argv[0] << " imgIn1.png imgIn2.png imgOutVert.png imgOutHori.png " << std::endl                                            << "           matchings.txt keys1.txt keys2.txt [Resize option: 0/1] " << std::endl                                            << "- imgIn1.png, imgIn2.png: input images (in PNG format). " << std::endl                                            << "- imgOutVert.png, imgOutHori.png: output images (vertical/horizontal concatenated, " << std::endl                                            << "  in PNG format.) The detected matchings are connected by write lines." << std::endl                                            << "- matchings.txt: coordinates of matched points (col1, row1, col2, row2). " << std::endl                                            << "- keys1.txt keys2.txt: ASIFT keypoints of the two images." << std::endl                                                                                                                               << "- [optional 0/1]. 1: input images resize to 800x600 (default). 0: no resize. " << std::endl                     << " ******************************************************************************* " << std::endl                    << " *********************  Jean-Michel Morel, Guoshen Yu, 2010 ******************** " << std::endl                    << " ******************************************************************************* " << std::endl;          return 1;      }      }
argc: number of the parameters from the command line

         this project needs 8 or 9 parameters when you want to run it;

argv[]: argv[0] shows the name of the project

           use argv[1] to get the first string parameter, argv[2].......

           as you know, you can use char* to store a string, such as ' hello_world'. So, char **argv[] can store a set of       char*. But when your parameters are numbers, you can use char* argv[] to store them.


/**************************input images******************************/

      // Read image1      float * iarr1;      size_t w1, h1;      if (NULL == (iarr1 = read_png_f32_gray(argv[1], &w1, &h1))) {          std::cerr << "Unable to load image file " << argv[1] << std::endl;          return 1;      }      std::vector<float> ipixels1(iarr1, iarr1 + w1 * h1);      free(iarr1); /*memcheck*/            // Read image2      float * iarr2;      size_t w2, h2;     if (NULL == (iarr2 = read_png_f32_gray(argv[2], &w2, &h2))) {         std::cerr << "Unable to load image file " << argv[2] << std::endl;         return 1;     }     std::vector<float> ipixels2(iarr2, iarr2 + w2 * h2);     free(iarr2); /*memcheck*/   

argv[1] and argv[2] are the names of the images, then the width and height of the images are stored in w1,h1 and w2,h2 respectively.

read_png_f32_gray :  read .png image. you can learn it in theipol.




0 0
原创粉丝点击