1 // This example displays two images in a deck.
2 // Images are loaded from the two filenames
3 // on the command line.
4
5 #include <iostream>
6 #ifdef _MSC_VER
7 # include "vcl_msvc_warnings.h"
8 #endif
9 #include "vil/vil_load.h"
10 #include "vil/vil_resample_bilin.h"
11
12 //cvg includes
13 #include <cvg/cvg_hemisphere_tableau.h>
14
15 //vgui includes
16 #include "vgui/vgui.h"
17 #include "vgui/vgui_image_tableau.h"
18 #include "vgui/vgui_viewer2D_tableau.h"
19 #include "vgui/vgui_shell_tableau.h"
20
21 //executable args
22 #include "vul/vul_arg.h"
23
main(int argc,char ** argv)24 int main(int argc, char **argv)
25 {
26 //init vgui (should choose/determine toolkit)
27 vgui::init(argc, argv);
28 vul_arg<std::string> imgdir("-img", "image directory", "");
29 vul_arg_parse(argc, argv);
30
31 //read sphere
32 vsph_view_sphere<vsph_view_point<std::string> > isphere;
33 std::string sphere_path = imgdir() + "/sphere.bin";
34 vsl_b_ifstream sphere_os(sphere_path);
35 if (!sphere_os) {
36 std::cout<<"cannot open "<<sphere_path<<" for writing\n";
37 return -1;
38 }
39 vsl_b_read(sphere_os, isphere);
40 sphere_os.close();
41 std::cout<<"sphere info : "<<isphere.size()<<std::endl;
42
43 //grab first image
44 std::string* first_img = isphere.begin()->second.metadata();
45 std::cout<<"first_img "<<(*first_img)<<std::endl;
46 vil_image_resource_sptr im = vil_load_image_resource(first_img->c_str());
47 if ( !im ) {
48 std::cerr << "Could not load " << first_img->c_str() << '\n';
49 return 1;
50 }
51
52 //scale your image...
53 //get first one and put it in image
54 vil_image_view_base_sptr first = im->get_view();
55 double min_scale = std::pow(PYRAMID_SCALE, PYRAMID_MAX_LEVEL);
56 std::cout<<"Min scale: "<<min_scale<<std::endl;
57 int sni = (int) (min_scale * first->ni());
58 int snj = (int) (min_scale * first->nj());
59 std::cout<<"Min size = "<<sni<<','<<snj<<std::endl;
60 vil_image_view<vxl_byte>* firstb = static_cast<vil_image_view<vxl_byte>* >(first.ptr());
61 vil_image_view<vxl_byte>* scaled = new vil_image_view<vxl_byte>(sni, snj);
62 vil_resample_bilin(*firstb, *scaled, sni, snj);
63
64 // Load image (given in the first command line param) into an image tableau.
65 cvg_hemisphere_tableau_new image(*first, isphere);
66
67 // Put the image tableau inside a 2D viewer tableau (for zoom, etc).
68 vgui_viewer2D_tableau_new viewer(image);
69
70 // Put a shell tableau at the top of our tableau tree.
71 vgui_shell_tableau_new shell(viewer);
72
73 // Create a window, add the tableau and show it on screen.
74 return vgui::run(shell, sni, snj);
75 }
76