1
- /* M///////////////////////////////////////////////////////////////////////////////////////
2
- //
3
- // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4
- //
5
- // By downloading, copying, installing or using the software you agree to this license.
6
- // If you do not agree to this license, do not download, install,
7
- // copy or use the software.
8
- //
9
- //
10
- // License Agreement
11
- // For Open Source Computer Vision Library
12
- //
13
- // Copyright (C) 2015, Itseez Inc, all rights reserved.
14
- // Third party copyrights are property of their respective owners.
15
- //
16
- // Redistribution and use in source and binary forms, with or without modification,
17
- // are permitted provided that the following conditions are met:
18
- //
19
- // * Redistribution's of source code must retain the above copyright notice,
20
- // this list of conditions and the following disclaimer.
21
- //
22
- // * Redistribution's in binary form must reproduce the above copyright notice,
23
- // this list of conditions and the following disclaimer in the documentation
24
- // and/or other materials provided with the distribution.
25
- //
26
- // * The name of the copyright holders may not be used to endorse or promote products
27
- // derived from this software without specific prior written permission.
28
- //
29
- // This software is provided by the copyright holders and contributors "as is" and
30
- // any express or implied warranties, including, but not limited to, the implied
31
- // warranties of merchantability and fitness for a particular purpose are disclaimed.
32
- // In no event shall the Itseez Inc or contributors be liable for any direct,
33
- // indirect, incidental, special, exemplary, or consequential damages
34
- // (including, but not limited to, procurement of substitute goods or services;
35
- // loss of use, data, or profits; or business interruption) however caused
36
- // and on any theory of liability, whether in contract, strict liability,
37
- // or tort (including negligence or otherwise) arising in any way out of
38
- // the use of this software, even if advised of the possibility of such damage.
39
- //
40
- //M*/
41
-
42
1
#include " opencv2/datasets/pd_inria.hpp"
43
- #include < opencv2/core .hpp>
44
-
2
+ #include < opencv2/highgui .hpp>
3
+ # include < opencv2/imgproc.hpp >
45
4
#include < iostream>
46
- #include < string>
47
- #include < vector>
48
5
49
6
using namespace std ;
50
7
using namespace cv ;
@@ -55,6 +12,7 @@ int main(int argc, char *argv[])
55
12
const char *keys =
56
13
" { help h usage ? | | show this message }"
57
14
" { path p |true| path to dataset }" ;
15
+
58
16
CommandLineParser parser (argc, argv, keys);
59
17
string path (parser.get <string>(" path" ));
60
18
if (parser.has (" help" ) || path==" true" )
@@ -66,28 +24,43 @@ int main(int argc, char *argv[])
66
24
Ptr<PD_inria> dataset = PD_inria::create ();
67
25
dataset->load (path);
68
26
69
- cout << " train size: " << (unsigned int )dataset->getTrain ().size () << endl;
27
+ size_t train_size = dataset->getTrain ().size ();
28
+ size_t test_size = dataset->getTest ().size ();
29
+ cout << " train size: " << train_size << endl;
30
+ cout << " test size: " << test_size << endl;
70
31
71
- PD_inriaObj *example = static_cast <PD_inriaObj *>(dataset->getTrain ()[0 ].get ());
72
- cout << " first train object: " << endl;
73
- cout << " name: " << example->filename << endl;
74
-
75
- // image size
76
- cout << " image size: " << endl;
77
- cout << " - width: " << example->width << endl;
78
- cout << " - height: " << example->height << endl;
79
- cout << " - depth: " << example->depth << endl;
80
-
81
- // bounding boxes
82
- for (unsigned int i = 0 ; i < (example->bndboxes ).size (); i++)
32
+ for ( size_t i = 0 ; i < train_size; i++ )
83
33
{
84
- cout << " object " << i << endl;
85
- int x = (example->bndboxes )[i].x ;
86
- int y = (example->bndboxes )[i].y ;
87
- cout << " - xmin = " << x << endl;
88
- cout << " - ymin = " << y << endl;
89
- cout << " - xmax = " << (example->bndboxes )[i].width + x << endl;
90
- cout << " - ymax = " << (example->bndboxes )[i].height + y<< endl;
34
+ PD_inriaObj *example = static_cast <PD_inriaObj *>(dataset->getTrain ()[i].get ());
35
+ cout << " \n train object index: " << i << endl;
36
+ cout << " file name: " << example->filename << endl;
37
+
38
+ // image size
39
+ cout << " image size: " << endl;
40
+ cout << " - width: " << example->width << endl;
41
+ cout << " - height: " << example->height << endl;
42
+ cout << " - depth: " << example->depth << endl;
43
+
44
+ Mat img = imread ( example->filename );
45
+
46
+ // bounding boxes
47
+ for ( size_t j = 0 ; j < example->bndboxes .size (); j++ )
48
+ {
49
+ cout << " object " << j << endl;
50
+ int x = example->bndboxes [j].x ;
51
+ int y = example->bndboxes [j].y ;
52
+ cout << " - xmin = " << x << endl;
53
+ cout << " - ymin = " << y << endl;
54
+ cout << " - xmax = " << example->bndboxes [j].width + x << endl;
55
+ cout << " - ymax = " << example->bndboxes [j].height + y << endl;
56
+ rectangle ( img, example->bndboxes [j], Scalar ( 0 , 0 , 255 ), 2 );
57
+ }
58
+
59
+ imshow (" INRIAPerson Dataset Train Images" , img);
60
+
61
+ cout << " \n Press a key to continue or ESC to exit." << endl;
62
+ int key = waitKey ();
63
+ if ( key == 27 ) break ;
91
64
}
92
65
93
66
return 0 ;
0 commit comments