diff --git a/examples/image_ex.cpp b/examples/image_ex.cpp index 54813fa3d..dff359bc6 100644 --- a/examples/image_ex.cpp +++ b/examples/image_ex.cpp @@ -34,23 +34,16 @@ int main(int argc, char** argv) return 1; } - // Here we open the image file. Note that when you open a binary file with - // the C++ ifstream you must supply the ios::binary flag. - ifstream fin(argv[1],ios::binary); - if (!fin) - { - cout << "error, can't find " << argv[1] << endl; - return 1; - } - // Here we declare an image object that can store rgb_pixels. Note that in // dlib there is no explicit image object, just a 2D array and // various pixel types. array2d::kernel_1a img; - // now load the bmp file into our image. If the file isn't really a BMP - // or is corrupted then load_bmp() will throw an exception. - load_bmp(img, fin); + // Now load the image file into our image. If something is wrong then + // load_image() will throw an exception. Also, if you compiled with libpng + // and libjpeg then load_image() can also load PNG and JPEG files in addition + // to BMP files. + load_image(img, argv[1]); // Now lets use some image functions. This example is going to perform // simple edge detection on the image. First lets find the horizontal and @@ -66,7 +59,8 @@ int main(int argc, char** argv) // window to display them on the screen. - // create a window to display the edge image + // create a window to display the edge image. (Note that you can zoom into + // the window by holding CTRL and scrolling the mouse wheel) image_window my_window(edge_image); // also make a window to display the original image diff --git a/examples/surf_ex.cpp b/examples/surf_ex.cpp index eb7fd8874..f79bf71d8 100644 --- a/examples/surf_ex.cpp +++ b/examples/surf_ex.cpp @@ -40,28 +40,22 @@ int main(int argc, char** argv) return 1; } - // Here we open the image file. Note that when you open a binary file with - // the C++ ifstream you must supply the ios::binary flag. - ifstream fin(argv[1],ios::binary); - if (!fin) - { - cout << "error, can't find " << argv[1] << endl; - return 1; - } - // Here we declare an image object that can store rgb_pixels. Note that in // dlib there is no explicit image object, just a 2D array and // various pixel types. array2d::kernel_1a img; - // now load the bmp file into our image. If the file isn't really a BMP - // or is corrupted then load_bmp() will throw an exception. - load_bmp(img, fin); + // Now load the image file into our image. If something is wrong then + // load_image() will throw an exception. Also, if you compiled with libpng + // and libjpeg then load_image() can also load PNG and JPEG files in addition + // to BMP files. + load_image(img, argv[1]); // get the 100 strongest SURF points from the image std::vector sp = get_surf_points(img, 100); - // create a window to display the input image and the SURF boxes + // create a window to display the input image and the SURF boxes. (Note that + // you can zoom into the window by holding CTRL and scrolling the mouse wheel) image_window my_window(img); // Now lets draw some rectangles on top of the image so we can see where