| 29 | // ---------------------------------------------------------------------------- |
| 30 | |
| 31 | int main(int argc, char** argv) |
| 32 | { |
| 33 | try |
| 34 | { |
| 35 | // make sure the user entered an argument to this program |
| 36 | if (argc != 2) |
| 37 | { |
| 38 | cout << "error, you have to enter a BMP file as an argument to this program" << endl; |
| 39 | return 1; |
| 40 | } |
| 41 | |
| 42 | // Here we declare an image object that can store rgb_pixels. Note that in dlib |
| 43 | // there is no explicit image object, just a 2D array and various pixel types. |
| 44 | array2d<rgb_pixel> img; |
| 45 | |
| 46 | // Now load the image file into our image. If something is wrong then load_image() |
| 47 | // will throw an exception. Also, if you linked with libpng and libjpeg then |
| 48 | // load_image() can load PNG and JPEG files in addition to BMP files. |
| 49 | load_image(img, argv[1]); |
| 50 | |
| 51 | // Get SURF points from the image. Note that get_surf_points() has some optional |
| 52 | // arguments that allow you to control the number of points you get back. Here we |
| 53 | // simply take the default. |
| 54 | std::vector<surf_point> sp = get_surf_points(img); |
| 55 | cout << "number of SURF points found: "<< sp.size() << endl; |
| 56 | |
| 57 | if (sp.size() > 0) |
| 58 | { |
| 59 | // A surf_point object contains a lot of information describing each point. |
| 60 | // The most important fields are shown below: |
| 61 | cout << "center of first SURF point: "<< sp[0].p.center << endl; |
| 62 | cout << "pyramid scale: " << sp[0].p.scale << endl; |
| 63 | cout << "SURF descriptor: \n" << sp[0].des << endl; |
| 64 | } |
| 65 | |
| 66 | // Create a window to display the input image and the SURF points. (Note that |
| 67 | // you can zoom into the window by holding CTRL and scrolling the mouse wheel) |
| 68 | image_window my_window(img); |
| 69 | draw_surf_points(my_window, sp); |
| 70 | |
| 71 | // wait until the user closes the window before we let the program |
| 72 | // terminate. |
| 73 | my_window.wait_until_closed(); |
| 74 | } |
| 75 | catch (exception& e) |
| 76 | { |
| 77 | cout << "exception thrown: " << e.what() << endl; |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | // ---------------------------------------------------------------------------- |
| 82 |
nothing calls this directly
no test coverage detected