-
Notifications
You must be signed in to change notification settings - Fork 0
/
apps_2global2_d_2od_multihog_app_8cpp-example.html
216 lines (216 loc) · 15.1 KB
/
apps_2global2_d_2od_multihog_app_8cpp-example.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
<!-- HTML header for doxygen 1.8.6-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="shortcut icon" type="image/x-icon" href="odlogo_small.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.6"/>
<meta name="keywords" content="object detection, object recognition, detection, recognition, vision, computer vision, image processing, point cloud, opens ource"/>
<meta name="description" content="Open Detection, OD, is a standalone open source project for object detection and recognition in images and 3D point clouds."/>
<meta name="author" content="Kripasindhu Sarkar"/>
<title>Open Detection: apps/global2D/od_multihog_app.cpp</title>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<style>
.carousel-inner > .item > img,
.carousel-inner > .item > a > img {
width: 70%;
margin: auto;
}
</style>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
$(document).ready(initResizable);
$(window).load(resizeHeight);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
$(document).ready(function() {
if ($('.searchresults').length > 0) { searchBox.DOMSearchField().focus(); }
});
</script>
<link rel="search" href="search-opensearch.php?v=opensearch.xml" type="application/opensearchdescription+xml" title="Open Detection"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="customdoxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">Open Detection
 <span id="projectnumber">1.0</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.6 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>OD</span></a></li>
<li><a href="tutorial_root.html"><span>User Guide</span></a></li>
<li><a href="usergroup0.html"><span>API Documentation</span></a></li>
<li><a href="idea_list_gsoc2017.html"><span>GSoC 2017 Ideas</span></a></li>
<li><a href="usergroup1.html"><span>GSoC16</span></a></li>
<li><a href="installation_instruction.html"><span>Downloads</span></a></li>
<li>
<div id="MSearchBox" class="MSearchBoxInactive">
<div class="left">
<form id="FSearchBox" action="search.php" method="get">
<img id="MSearchSelect" src="search/mag.png" alt=""/>
<input type="text" id="MSearchField" name="query" value="Search" size="20" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"/>
</form>
</div><div class="right"></div>
</div>
</li>
</ul>
</div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('apps_2global2_d_2od_multihog_app_8cpp-example.html','');});
</script>
<div id="doc-content">
<div class="header">
<div class="headertitle">
<div class="title">apps/global2D/od_multihog_app.cpp</div> </div>
</div><!--header-->
<div class="contents">
<p>This is an example of how to use the ODHOGDetector class.More details about this example.</p>
<div class="fragment"><div class="line"><span class="comment">/*</span></div>
<div class="line"><span class="comment">Copyright (c) 2015, Kripasindhu Sarkar</span></div>
<div class="line"><span class="comment">All rights reserved.</span></div>
<div class="line"><span class="comment"></span></div>
<div class="line"><span class="comment">Redistribution and use in source and binary forms, with or without</span></div>
<div class="line"><span class="comment">modification, are permitted provided that the following conditions are met:</span></div>
<div class="line"><span class="comment"> * Redistributions of source code must retain the above copyright</span></div>
<div class="line"><span class="comment"> notice, this list of conditions and the following disclaimer.</span></div>
<div class="line"><span class="comment"> * Redistributions in binary form must reproduce the above copyright</span></div>
<div class="line"><span class="comment"> notice, this list of conditions and the following disclaimer in the</span></div>
<div class="line"><span class="comment"> documentation and/or other materials provided with the distribution.</span></div>
<div class="line"><span class="comment"> * Neither the name of the copyright holder(s) nor the</span></div>
<div class="line"><span class="comment"> names of its contributors may be used to endorse or promote products</span></div>
<div class="line"><span class="comment"> derived from this software without specific prior written permission.</span></div>
<div class="line"><span class="comment"></span></div>
<div class="line"><span class="comment">THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND</span></div>
<div class="line"><span class="comment">ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED</span></div>
<div class="line"><span class="comment">WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE</span></div>
<div class="line"><span class="comment">DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER BE LIABLE FOR ANY</span></div>
<div class="line"><span class="comment">DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES</span></div>
<div class="line"><span class="comment">(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;</span></div>
<div class="line"><span class="comment">LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND</span></div>
<div class="line"><span class="comment">ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT</span></div>
<div class="line"><span class="comment">(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS</span></div>
<div class="line"><span class="comment">SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span></div>
<div class="line"><span class="comment">*/</span><span class="comment"></span></div>
<div class="line"><span class="comment">/** \brief Example of the usage of HOG detector</span></div>
<div class="line"><span class="comment"> *</span></div>
<div class="line"><span class="comment"> * \author Kripasindhu Sarkar</span></div>
<div class="line"><span class="comment"> *</span></div>
<div class="line"><span class="comment"> */</span></div>
<div class="line"></div>
<div class="line"><span class="preprocessor">#include "detectors/global2D/detection/ODHOGDetector.h"</span></div>
<div class="line"><span class="preprocessor">#include "common/utils/ODFrameGenerator.h"</span></div>
<div class="line"></div>
<div class="line"><span class="preprocessor">#include "common/pipeline/ObjectDetector.h"</span></div>
<div class="line"><span class="preprocessor">#include "common/pipeline/ODDetection.h"</span></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"><span class="keyword">using namespace </span>od;</div>
<div class="line"><span class="keyword">using namespace </span>std;</div>
<div class="line"></div>
<div class="line">cv::Size sizesingle(640, 480);</div>
<div class="line"></div>
<div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])</div>
<div class="line">{</div>
<div class="line"> std::string trained_data_dir(argv[1]), input_video(argv[2]), output_video = <span class="stringliteral">"output.avi"</span>;</div>
<div class="line"> <span class="keywordflow">if</span> (argc > 3) output_video = argv[3];</div>
<div class="line"></div>
<div class="line"></div>
<div class="line"> <span class="comment">//get 3 detectors of different types</span></div>
<div class="line"> vector<string> messages; messages.push_back(<span class="stringliteral">"Original"</span>);</div>
<div class="line"> vector<g2d::ODHOGDetector*> detectors;</div>
<div class="line"> <a name="_a0"></a><a class="code" href="classod_1_1g2d_1_1_o_d_h_o_g_detector.html">g2d::ODHOGDetector</a> *detector1 = <span class="keyword">new</span> <a class="code" href="classod_1_1g2d_1_1_o_d_h_o_g_detector.html">g2d::ODHOGDetector</a>; <span class="comment">//</span></div>
<div class="line"> messages.push_back(<span class="stringliteral">"OpenCV Default People"</span>); detectors.push_back(detector1);</div>
<div class="line"></div>
<div class="line"> <a class="code" href="classod_1_1g2d_1_1_o_d_h_o_g_detector.html">g2d::ODHOGDetector</a> *detector2 = <span class="keyword">new</span> <a class="code" href="classod_1_1g2d_1_1_o_d_h_o_g_detector.html">g2d::ODHOGDetector</a>; detector2-><a name="a1"></a><a class="code" href="classod_1_1g2d_1_1_o_d_h_o_g_detector.html#a47c57b507c965c09dfd8371121239979">setSvmtype</a>(g2d::ODHOGDetector::OD_DAIMLER_PEOPLE);</div>
<div class="line"> messages.push_back(<span class="stringliteral">"OpenCV Daimler People"</span>); detectors.push_back(detector2);</div>
<div class="line"></div>
<div class="line"> <a class="code" href="classod_1_1g2d_1_1_o_d_h_o_g_detector.html">g2d::ODHOGDetector</a> *detector3 = <span class="keyword">new</span> <a class="code" href="classod_1_1g2d_1_1_o_d_h_o_g_detector.html">g2d::ODHOGDetector</a>(trained_data_dir);</div>
<div class="line"> messages.push_back(<span class="stringliteral">"Custom HOG from trained data"</span>); detectors.push_back(detector3);</div>
<div class="line"></div>
<div class="line"> <span class="comment">//init all detectors</span></div>
<div class="line"> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < detectors.size(); i++) detectors[i]->init();</div>
<div class="line"></div>
<div class="line"> <span class="comment">//get scenes</span></div>
<div class="line"> od::ODFrameGenerator<od::ODSceneImage, od::GENERATOR_TYPE_DEVICE> frameGenerator(input_video);</div>
<div class="line"> <span class="comment">//od::ODFrameGenerator<od::ODSceneImage, od::GENERATOR_TYPE_FILE_LIST> frameGenerator(input_video);</span></div>
<div class="line"> cv::VideoWriter videoWriter(output_video, CV_FOURCC(<span class="charliteral">'M'</span>,<span class="charliteral">'J'</span>,<span class="charliteral">'P'</span>,<span class="charliteral">'G'</span>), 25, sizesingle * 2, <span class="keyword">true</span>);</div>
<div class="line"></div>
<div class="line"></div>
<div class="line"> <span class="comment">//GUI</span></div>
<div class="line"> cv::namedWindow(<span class="stringliteral">"Overlay"</span>, cv::WINDOW_NORMAL);</div>
<div class="line"> <span class="keywordflow">while</span>(frameGenerator.isValid() && cv::waitKey(33) != 27)</div>
<div class="line"> {</div>
<div class="line"> <a name="_a2"></a><a class="code" href="classod_1_1_o_d_scene_image.html">od::ODSceneImage</a> * scene = frameGenerator.getNextFrame();</div>
<div class="line"></div>
<div class="line"> vector<cv::Mat> images_to_show;</div>
<div class="line"> images_to_show.push_back(scene-><a name="a3"></a><a class="code" href="classod_1_1_o_d_scene_image.html#aa612c7d253de19c5e168b5f4c64e71b8">getCVImage</a>()); <span class="comment">//push the first image</span></div>
<div class="line"></div>
<div class="line"> <span class="comment">//detect 3 times</span></div>
<div class="line"> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < detectors.size(); i++)</div>
<div class="line"> {</div>
<div class="line"> <a name="_a4"></a><a class="code" href="classod_1_1_o_d_detections2_d.html">ODDetections2D</a> *detections = detectors[i]->detectOmni(scene);</div>
<div class="line"> <span class="keywordflow">if</span>(detections-><a name="a5"></a><a class="code" href="classod_1_1_o_d_detections.html#acecd430dee656213a2a19832dd7a47d6">size</a>() > 0)</div>
<div class="line"> images_to_show.<a name="a6"></a><a class="code" href="classod_1_1_o_d_detections.html#a076cbfeb953d1e8c0fef206b076e9a41">push_back</a>(detections-><a name="a7"></a><a class="code" href="classod_1_1_o_d_detections2_d.html#a3297fb185a951414197e1db893a4cdaf">renderMetainfo</a>(*scene).<a class="code" href="classod_1_1_o_d_scene_image.html#aa612c7d253de19c5e168b5f4c64e71b8">getCVImage</a>());</div>
<div class="line"> <span class="keywordflow">else</span> images_to_show.push_back(scene-><a class="code" href="classod_1_1_o_d_scene_image.html#aa612c7d253de19c5e168b5f4c64e71b8">getCVImage</a>());</div>
<div class="line"> }</div>
<div class="line"></div>
<div class="line"> cv::Mat multiimage = <a name="a8"></a><a class="code" href="namespaceod.html#a055d1749c9212f40b840643989d3e3ab">makeCanvasMultiImages</a>(images_to_show, sizesingle, messages);</div>
<div class="line"> cv::imshow(<span class="stringliteral">"Overlay"</span>, multiimage);</div>
<div class="line"> videoWriter << multiimage;</div>
<div class="line"></div>
<div class="line"> <span class="keyword">delete</span> scene;</div>
<div class="line"> }</div>
<div class="line"></div>
<div class="line"> <span class="keywordflow">return</span> 0;</div>
<div class="line">}</div>
</div><!-- fragment --> </div><!-- contents -->
</div><!-- doc-content -->
<!-- HTML footer for doxygen 1.8.6-->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="footer">Send your queries <a href="mailto:kripasindhu.sarkar@dfki.de?Subject=OpenDetection" target="_top">here</a>.</li>
</ul>
</div>
</body>
</html>