Commit 35a6408f authored by Davis King's avatar Davis King

Simplified examples by using load_image() instead of load_bmp()

parent 739c68ad
...@@ -34,23 +34,16 @@ int main(int argc, char** argv) ...@@ -34,23 +34,16 @@ int main(int argc, char** argv)
return 1; 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 // 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 // dlib there is no explicit image object, just a 2D array and
// various pixel types. // various pixel types.
array2d<rgb_pixel>::kernel_1a img; array2d<rgb_pixel>::kernel_1a img;
// now load the bmp file into our image. If the file isn't really a BMP // Now load the image file into our image. If something is wrong then
// or is corrupted then load_bmp() will throw an exception. // load_image() will throw an exception. Also, if you compiled with libpng
load_bmp(img, fin); // 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 // Now lets use some image functions. This example is going to perform
// simple edge detection on the image. First lets find the horizontal and // simple edge detection on the image. First lets find the horizontal and
...@@ -66,7 +59,8 @@ int main(int argc, char** argv) ...@@ -66,7 +59,8 @@ int main(int argc, char** argv)
// window to display them on the screen. // 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); image_window my_window(edge_image);
// also make a window to display the original image // also make a window to display the original image
......
...@@ -40,28 +40,22 @@ int main(int argc, char** argv) ...@@ -40,28 +40,22 @@ int main(int argc, char** argv)
return 1; 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 // 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 // dlib there is no explicit image object, just a 2D array and
// various pixel types. // various pixel types.
array2d<rgb_pixel>::kernel_1a img; array2d<rgb_pixel>::kernel_1a img;
// now load the bmp file into our image. If the file isn't really a BMP // Now load the image file into our image. If something is wrong then
// or is corrupted then load_bmp() will throw an exception. // load_image() will throw an exception. Also, if you compiled with libpng
load_bmp(img, fin); // 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 // get the 100 strongest SURF points from the image
std::vector<surf_point> sp = get_surf_points(img, 100); std::vector<surf_point> 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); image_window my_window(img);
// Now lets draw some rectangles on top of the image so we can see where // Now lets draw some rectangles on top of the image so we can see where
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment