<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Xion Luhnis</title>
	<atom:link href="http://news.wox-xion.ch/feed/" rel="self" type="application/rss+xml" />
	<link>http://news.wox-xion.ch</link>
	<description>Parménide avait raison...</description>
	<lastBuildDate>Mon, 07 May 2012 18:21:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Gesture Tracking library</title>
		<link>http://news.wox-xion.ch/2012/05/gesture-tracking-library/</link>
		<comments>http://news.wox-xion.ch/2012/05/gesture-tracking-library/#comments</comments>
		<pubDate>Sat, 05 May 2012 14:12:16 +0000</pubDate>
		<dc:creator>Alexandre Kaspar</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[color tracking]]></category>
		<category><![CDATA[opencv]]></category>
		<category><![CDATA[tracking]]></category>

		<guid isPermaLink="false">http://news.wox-xion.ch/?p=1350</guid>
		<description><![CDATA[<img width="260" height="195" src="http://news.wox-xion.ch/wp-content/uploads/2012/05/full-260x195.png" class="attachment-medium wp-post-image" alt="full" title="full" /><p><img width="260" height="195" src="http://news.wox-xion.ch/wp-content/uploads/2012/05/full-260x195.png" class="attachment-medium wp-post-image" alt="full" title="full" /></p>I haven&#8217;t had time to release the code of the gesture tracking library I developed at the beginning of this year till now. And here it is. Given the tracking library, the ping pong application I made is really simple.&#8230; <a href="http://news.wox-xion.ch/2012/05/gesture-tracking-library/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<img width="260" height="195" src="http://news.wox-xion.ch/wp-content/uploads/2012/05/full-260x195.png" class="attachment-medium wp-post-image" alt="full" title="full" /><p><img width="260" height="195" src="http://news.wox-xion.ch/wp-content/uploads/2012/05/full-260x195.png" class="attachment-medium wp-post-image" alt="full" title="full" /></p><p></p><br /><p>I haven&#8217;t had time to release the code of the gesture tracking library I developed at the beginning of this year till now.</p>
<p>And <a title="Gesture tracking library" href="http://projects.wox-xion.ch/gesture-tracking" target="_blank">here</a> it is.</p>
<p>Given the tracking library, the ping pong application I made is really simple. Here is actually its code :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #ff0000; font-style: italic;">/* 
 * File:   main.cpp
 * Author: Alexandre Kaspar
 *
 * Created on 9. janvier 2012, 14:34
 */</span>
&nbsp;
<span style="color: #339900;">#include &lt;cstdlib&gt;</span>
<span style="color: #339900;">#include &lt;iostream&gt;</span>
<span style="color: #339900;">#include &lt;cmath&gt;</span>
<span style="color: #666666;">// OpenCV</span>
<span style="color: #339900;">#include &lt;opencv2/video/tracking.hpp&gt;</span>
<span style="color: #339900;">#include &lt;opencv2/imgproc/imgproc.hpp&gt;</span>
<span style="color: #339900;">#include &lt;opencv2/highgui/highgui.hpp&gt;</span>
<span style="color: #666666;">//// GL and GLU</span>
<span style="color: #666666;">//#include &lt;GL/gl.h&gt;</span>
<span style="color: #666666;">//#include &lt;GL/glu.h&gt;</span>
<span style="color: #666666;">//#include &lt;GL/freeglut.h&gt;</span>
<span style="color: #666666;">// our library</span>
<span style="color: #339900;">#include &lt;Capture.h&gt;</span>
<span style="color: #339900;">#include &lt;Frame.h&gt;</span>
<span style="color: #339900;">#include &lt;Geometry.h&gt;</span>
<span style="color: #339900;">#include &lt;Marker.h&gt;</span>
<span style="color: #339900;">#include &lt;algorithm&gt;</span>
&nbsp;
<span style="color: #666666;">// namespaces</span>
&nbsp;
<span style="color: #0000ff;">using</span> <span style="color: #0000ff;">namespace</span> cv<span style="color: #008080;">;</span>
<span style="color: #0000ff;">using</span> <span style="color: #0000ff;">namespace</span> std<span style="color: #008080;">;</span>
&nbsp;
<span style="color: #666666;">// global variables</span>
<span style="color: #0000ff;">bool</span> smooth <span style="color: #000080;">=</span> <span style="color: #0000ff;">false</span><span style="color: #008080;">;</span> <span style="color: #666666;">//&lt; whether to smooth the camera image</span>
<span style="color: #0000ff;">bool</span> game <span style="color: #000080;">=</span> <span style="color: #0000ff;">false</span><span style="color: #008080;">;</span> <span style="color: #666666;">//&lt; whether the game is running</span>
<span style="color: #0000ff;">bool</span> paused <span style="color: #000080;">=</span> <span style="color: #0000ff;">false</span><span style="color: #008080;">;</span> <span style="color: #666666;">//&lt; running status</span>
&nbsp;
<span style="color: #0000ff;">int</span> getFilterFlag<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    <span style="color: #0000ff;">int</span> flag <span style="color: #000080;">=</span> Capture<span style="color: #008080;">::</span><span style="color: #007788;">FLIP</span><span style="color: #008080;">;</span>
    <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>smooth<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
        flag <span style="color: #000040;">|</span><span style="color: #000080;">=</span> Capture<span style="color: #008080;">::</span><span style="color: #007788;">GAUSS_SMOOTH</span><span style="color: #008080;">;</span>
    <span style="color: #008000;">&#125;</span>
    <span style="color: #0000ff;">return</span> flag<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #ff0000; font-style: italic;">/**
 * Mouse event handler
 * 
 * @param event the mouse event
 * @param x the new mouse abscissa
 * @param y the new mouse ordinate
 */</span>
<span style="color: #0000ff;">void</span> onMouse<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> event, <span style="color: #0000ff;">int</span> x, <span style="color: #0000ff;">int</span> y, <span style="color: #0000ff;">int</span>, <span style="color: #0000ff;">void</span><span style="color: #000040;">*</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    <span style="color: #666666;">// the mouse event</span>
    <span style="color: #0000ff;">switch</span> <span style="color: #008000;">&#40;</span>event<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
        <span style="color: #0000ff;">case</span> CV_EVENT_LBUTTONUP<span style="color: #008080;">:</span>
            <span style="color: #666666;">// we restart the game</span>
            game <span style="color: #000080;">=</span> <span style="color: #0000ff;">true</span><span style="color: #008080;">;</span>
            <span style="color: #0000ff;">break</span><span style="color: #008080;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #ff0000; font-style: italic;">/**
 * Process a keyboard event
 * 
 * @param histimg the histogram image
 * @return whether to keep running or not (then exit)
 */</span>
<span style="color: #0000ff;">bool</span> pollKeys<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    <span style="color: #0000ff;">char</span> c <span style="color: #000080;">=</span> <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">char</span><span style="color: #008000;">&#41;</span> waitKey<span style="color: #008000;">&#40;</span><span style="color: #0000dd;">10</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>c <span style="color: #000080;">==</span> <span style="color: #0000dd;">27</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
        <span style="color: #666666;">// we're done, let's exit</span>
        <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">false</span><span style="color: #008080;">;</span>
    <span style="color: #008000;">&#125;</span>
    <span style="color: #666666;">// possible key events</span>
    <span style="color: #0000ff;">switch</span> <span style="color: #008000;">&#40;</span>c<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
        <span style="color: #0000ff;">case</span> <span style="color: #FF0000;">'s'</span><span style="color: #008080;">:</span>
        <span style="color: #0000ff;">case</span> <span style="color: #FF0000;">'g'</span><span style="color: #008080;">:</span>
            smooth <span style="color: #000080;">=</span> <span style="color: #000040;">!</span>smooth<span style="color: #008080;">;</span>
            <span style="color: #0000ff;">break</span><span style="color: #008080;">;</span>
        <span style="color: #0000ff;">case</span> <span style="color: #FF0000;">'p'</span><span style="color: #008080;">:</span>
            paused <span style="color: #000080;">=</span> <span style="color: #000040;">!</span>paused<span style="color: #008080;">;</span>
            <span style="color: #0000ff;">break</span><span style="color: #008080;">;</span>
        <span style="color: #0000ff;">default</span><span style="color: #008080;">:</span>
            <span style="color: #008080;">;</span>
    <span style="color: #008000;">&#125;</span>
    <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">true</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">typedef</span> Point2d PVect<span style="color: #008080;">;</span>
&nbsp;
PVect computeSpeed<span style="color: #008000;">&#40;</span>PVect v, <span style="color: #0000ff;">double</span> s<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    <span style="color: #666666;">// v has values in [-1;+1]</span>
    <span style="color: #0000ff;">double</span> angle <span style="color: #000080;">=</span> <span style="color: #0000dd;">atan2</span><span style="color: #008000;">&#40;</span>v.<span style="color: #007788;">y</span>, v.<span style="color: #007788;">x</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    <span style="color: #0000ff;">return</span> PVect<span style="color: #008000;">&#40;</span>s <span style="color: #000040;">*</span> <span style="color: #0000dd;">cos</span><span style="color: #008000;">&#40;</span>angle<span style="color: #008000;">&#41;</span>, s <span style="color: #000040;">*</span> <span style="color: #0000dd;">sin</span><span style="color: #008000;">&#40;</span>angle<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
PVect processSpeed<span style="color: #008000;">&#40;</span>PVect v, <span style="color: #0000ff;">double</span> dy<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    <span style="color: #0000ff;">double</span> Y <span style="color: #000080;">=</span> v.<span style="color: #007788;">y</span> <span style="color: #000040;">+</span> dy<span style="color: #008080;">;</span>
    <span style="color: #0000ff;">double</span> norm <span style="color: #000080;">=</span> <span style="color: #0000dd;">sqrt</span><span style="color: #008000;">&#40;</span>v.<span style="color: #007788;">x</span> <span style="color: #000040;">*</span> v.<span style="color: #007788;">x</span> <span style="color: #000040;">+</span> Y <span style="color: #000040;">*</span> Y<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    <span style="color: #0000ff;">return</span> PVect<span style="color: #008000;">&#40;</span><span style="color: #000040;">-</span>v.<span style="color: #007788;">x</span> <span style="color: #000040;">/</span> norm, Y <span style="color: #000040;">/</span> norm<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// -x for the x-bounce</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">void</span> drawMargin<span style="color: #008000;">&#40;</span>Mat<span style="color: #000040;">&amp;</span> image, <span style="color: #0000ff;">int</span> x<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    line<span style="color: #008000;">&#40;</span>image, Point<span style="color: #008000;">&#40;</span>x, <span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span>, Point<span style="color: #008000;">&#40;</span>x, image.<span style="color: #007788;">rows</span><span style="color: #008000;">&#41;</span>,
            Scalar<span style="color: #008000;">&#40;</span><span style="color: #208080;">0xFF</span>, <span style="color: #208080;">0xFF</span>, <span style="color: #208080;">0xFF</span><span style="color: #008000;">&#41;</span>, <span style="color: #0000dd;">2</span>, CV_AA<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #ff0000; font-style: italic;">/*
 * Boot method
 */</span>
<span style="color: #0000ff;">int</span> main<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> argc, <span style="color: #0000ff;">char</span><span style="color: #000040;">**</span> argv<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
&nbsp;
    <span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;Init [game]...&quot;</span> <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
&nbsp;
    geom<span style="color: #008080;">::</span><span style="color: #007788;">initTimestamp</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
    Capture cap<span style="color: #008080;">;</span>
&nbsp;
    <span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;. init markers&quot;</span> <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
    MarkerRef leftMarker <span style="color: #000080;">=</span> Marker<span style="color: #008080;">::</span><span style="color: #007788;">load</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;markers/y1.m&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    Scalar leftColor<span style="color: #008000;">&#40;</span><span style="color: #208080;">0x00</span>, <span style="color: #208080;">0xFF</span>, <span style="color: #208080;">0x00</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    <span style="color: #0000ff;">int</span> lastLeftPos <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
    MarkerRef rightMarker <span style="color: #000080;">=</span> Marker<span style="color: #008080;">::</span><span style="color: #007788;">load</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;markers/r1.m_patch.png&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    Scalar rightColor<span style="color: #008000;">&#40;</span><span style="color: #208080;">0x00</span>, <span style="color: #208080;">0x00</span>, <span style="color: #208080;">0xFF</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    <span style="color: #0000ff;">int</span> lastRightPos <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
&nbsp;
    <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>leftMarker <span style="color: #000040;">&amp;&amp;</span> rightMarker<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
        <span style="color: #666666;">// we're ok</span>
        <span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;. marker loaded !&quot;</span> <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
    <span style="color: #008000;">&#125;</span> <span style="color: #0000ff;">else</span> <span style="color: #008000;">&#123;</span>
        <span style="color: #0000dd;">cerr</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;Couldn't load the markers...&quot;</span> <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
        <span style="color: #0000ff;">return</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #666666;">// start camera capture</span>
    cap.<span style="color: #007788;">open</span><span style="color: #008000;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
    <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #000040;">!</span>cap.<span style="color: #007788;">isOpened</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
        <span style="color: #0000dd;">cerr</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;***Could not initialize capturing...***<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008080;">;</span>
        <span style="color: #0000ff;">return</span> <span style="color: #000040;">-</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0000ff;">const</span> string window <span style="color: #000080;">=</span> <span style="color: #FF0000;">&quot;Marker Ping PONG !&quot;</span><span style="color: #008080;">;</span>
&nbsp;
    namedWindow<span style="color: #008000;">&#40;</span>window, <span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    setMouseCallback<span style="color: #008000;">&#40;</span>window, onMouse, <span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
    <span style="color: #666666;">// game parameters</span>
    <span style="color: #0000ff;">const</span> <span style="color: #0000ff;">int</span> margin <span style="color: #000080;">=</span> <span style="color: #0000dd;">50</span><span style="color: #008080;">;</span> <span style="color: #666666;">//&lt; pixel x-margin</span>
    <span style="color: #0000ff;">const</span> <span style="color: #0000ff;">int</span> pingsz <span style="color: #000080;">=</span> <span style="color: #0000dd;">100</span><span style="color: #008080;">;</span> <span style="color: #666666;">//&lt; ping pong p</span>
    <span style="color: #0000ff;">const</span> <span style="color: #0000ff;">int</span> rectsz <span style="color: #000080;">=</span> <span style="color: #0000dd;">20</span><span style="color: #008080;">;</span> <span style="color: #666666;">//&lt; ball radius</span>
    <span style="color: #0000ff;">const</span> <span style="color: #0000ff;">int</span> speed <span style="color: #000080;">=</span> <span style="color: #0000dd;">30</span><span style="color: #008080;">;</span> <span style="color: #666666;">//&lt; ball velocity</span>
    PVect recPos<span style="color: #008080;">;</span> <span style="color: #666666;">//&lt; the ball position</span>
    PVect recSpeed<span style="color: #008080;">;</span> <span style="color: #666666;">//&lt; the ball speed</span>
    <span style="color: #0000ff;">int</span> win <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span> <span style="color: #666666;">//&lt; the winner 1=left, 2=right</span>
&nbsp;
    <span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;. starting the loop&quot;</span> <span style="color: #000080;">&lt;&lt;</span> endl <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
    <span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;Click with the mouse to restart the game.&quot;</span> <span style="color: #000080;">&lt;&lt;</span> endl <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
&nbsp;
    <span style="color: #666666;">// the loop</span>
    Frame frame<span style="color: #008080;">;</span>
    Mat image<span style="color: #008080;">;</span>
    <span style="color: #0000ff;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #008080;">;;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
&nbsp;
        <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #000040;">!</span>paused<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
            <span style="color: #666666;">// we update the filter flags</span>
            cap<span style="color: #008000;">&#40;</span>getFilterFlag<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
            <span style="color: #666666;">// we update the frame from the video capture</span>
            cap <span style="color: #000080;">&gt;&gt;</span> frame<span style="color: #008080;">;</span>
            <span style="color: #666666;">// and check that there's something</span>
            <span style="color: #666666;">// otherwise =&gt; we stopped using the camera</span>
            <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>frame.<span style="color: #007788;">empty</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
                <span style="color: #0000ff;">break</span><span style="color: #008080;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #666666;">// stage constants</span>
        <span style="color: #0000ff;">const</span> <span style="color: #0000ff;">int</span> width <span style="color: #000080;">=</span> frame.<span style="color: #007788;">cols</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
        <span style="color: #0000ff;">const</span> <span style="color: #0000ff;">int</span> height <span style="color: #000080;">=</span> frame.<span style="color: #007788;">rows</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
        <span style="color: #666666;">// the image we'll draw onto</span>
        frame<span style="color: #008000;">&#40;</span>Channel<span style="color: #008080;">::</span><span style="color: #007788;">BGR</span><span style="color: #008000;">&#41;</span>.<span style="color: #007788;">copyTo</span><span style="color: #008000;">&#40;</span>image<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
        <span style="color: #666666;">// ### 1 = detect the marker =&gt; update positions</span>
&nbsp;
        <span style="color: #666666;">// the left player</span>
        <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>leftMarker<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>detect<span style="color: #008000;">&#40;</span>frame<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
            point target <span style="color: #000080;">=</span> leftMarker<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>lastPoint<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
            <span style="color: #666666;">// we display the marker location</span>
            rectangle<span style="color: #008000;">&#40;</span>image,
                    Rect<span style="color: #008000;">&#40;</span>target.<span style="color: #007788;">x</span> <span style="color: #000040;">-</span> <span style="color: #0000dd;">10</span>, target.<span style="color: #007788;">y</span> <span style="color: #000040;">-</span> <span style="color: #0000dd;">10</span>, <span style="color: #0000dd;">20</span>, <span style="color: #0000dd;">20</span><span style="color: #008000;">&#41;</span>,
                    leftColor<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
            <span style="color: #666666;">// we set the new pos</span>
            lastLeftPos <span style="color: #000080;">=</span> target.<span style="color: #007788;">y</span><span style="color: #008080;">;</span>
        <span style="color: #008000;">&#125;</span>
        <span style="color: #666666;">// the right player</span>
        <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>rightMarker<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>detect<span style="color: #008000;">&#40;</span>frame<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
            point target <span style="color: #000080;">=</span> rightMarker<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>lastPoint<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
            <span style="color: #666666;">// we display the marker location</span>
            rectangle<span style="color: #008000;">&#40;</span>image,
                    Rect<span style="color: #008000;">&#40;</span>target.<span style="color: #007788;">x</span> <span style="color: #000040;">-</span> <span style="color: #0000dd;">10</span>, target.<span style="color: #007788;">y</span> <span style="color: #000040;">-</span> <span style="color: #0000dd;">10</span>, <span style="color: #0000dd;">20</span>, <span style="color: #0000dd;">20</span><span style="color: #008000;">&#41;</span>,
                    rightColor<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
            <span style="color: #666666;">// we set the new pos</span>
            lastRightPos <span style="color: #000080;">=</span> target.<span style="color: #007788;">y</span><span style="color: #008080;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #666666;">// ### 2 = draw the players</span>
        drawMargin<span style="color: #008000;">&#40;</span>image, margin<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
        <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>leftMarker<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>getHistorySize<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #000080;">&gt;</span> <span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
            <span style="color: #666666;">// the display range</span>
            Rect pad<span style="color: #008000;">&#40;</span><span style="color: #0000dd;">0</span>, std<span style="color: #008080;">::</span><span style="color: #007788;">max</span><span style="color: #008000;">&#40;</span><span style="color: #0000dd;">0</span>, lastLeftPos <span style="color: #000040;">-</span> pingsz<span style="color: #008000;">&#41;</span>, margin, <span style="color: #0000dd;">2</span> <span style="color: #000040;">*</span> pingsz<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
            rectangle<span style="color: #008000;">&#40;</span>image, pad, leftColor, CV_FILLED<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
        <span style="color: #008000;">&#125;</span>
        drawMargin<span style="color: #008000;">&#40;</span>image, width <span style="color: #000040;">-</span> margin<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
        <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>rightMarker<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>getHistorySize<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #000080;">&gt;</span> <span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
            <span style="color: #666666;">// the display range</span>
            Rect pad<span style="color: #008000;">&#40;</span>width <span style="color: #000040;">-</span> margin, std<span style="color: #008080;">::</span><span style="color: #007788;">max</span><span style="color: #008000;">&#40;</span><span style="color: #0000dd;">0</span>, lastRightPos <span style="color: #000040;">-</span> pingsz<span style="color: #008000;">&#41;</span>,
                    margin, <span style="color: #0000dd;">2</span> <span style="color: #000040;">*</span> pingsz<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
            rectangle<span style="color: #008000;">&#40;</span>image, pad, rightColor, CV_FILLED<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #666666;">// ### 3 = game logic</span>
        <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #000040;">!</span>game<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
            <span style="color: #666666;">// we put the ball at the center</span>
            recPos <span style="color: #000080;">=</span> PVect<span style="color: #008000;">&#40;</span>width <span style="color: #000040;">/</span> <span style="color: #0000dd;">2</span>, height <span style="color: #000040;">/</span> <span style="color: #0000dd;">2</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
            string title<span style="color: #008080;">;</span>
            Scalar color<span style="color: #008080;">;</span>
            <span style="color: #0000ff;">switch</span> <span style="color: #008000;">&#40;</span>win<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
                <span style="color: #0000ff;">case</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">:</span>
                    title <span style="color: #000080;">=</span> <span style="color: #FF0000;">&quot;Click to start&quot;</span><span style="color: #008080;">;</span>
                    color <span style="color: #000080;">=</span> Scalar<span style="color: #008000;">&#40;</span><span style="color: #208080;">0x66</span>, <span style="color: #208080;">0x66</span>, <span style="color: #208080;">0x66</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
                    <span style="color: #0000ff;">break</span><span style="color: #008080;">;</span>
                <span style="color: #0000ff;">case</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">:</span> <span style="color: #666666;">// left won</span>
                    title <span style="color: #000080;">=</span> <span style="color: #FF0000;">&quot;Left won !&quot;</span><span style="color: #008080;">;</span>
                    color <span style="color: #000080;">=</span> leftColor<span style="color: #008080;">;</span>
                    <span style="color: #0000ff;">break</span><span style="color: #008080;">;</span>
                <span style="color: #0000ff;">case</span> <span style="color: #0000dd;">2</span><span style="color: #008080;">:</span> <span style="color: #666666;">// right won</span>
                    title <span style="color: #000080;">=</span> <span style="color: #FF0000;">&quot;Right won !&quot;</span><span style="color: #008080;">;</span>
                    color <span style="color: #000080;">=</span> rightColor<span style="color: #008080;">;</span>
                    <span style="color: #0000ff;">break</span><span style="color: #008080;">;</span>
            <span style="color: #008000;">&#125;</span>
            <span style="color: #666666;">// we display the title</span>
            Size textsize <span style="color: #000080;">=</span> getTextSize<span style="color: #008000;">&#40;</span>title, CV_FONT_HERSHEY_COMPLEX, <span style="color: #0000dd;">2</span>, <span style="color: #0000dd;">5</span>, <span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
            Point org<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span>width <span style="color: #000040;">-</span> textsize.<span style="color: #007788;">width</span><span style="color: #008000;">&#41;</span> <span style="color: #000040;">/</span> <span style="color: #0000dd;">2</span>, <span style="color: #0000dd;">3</span> <span style="color: #000040;">*</span> height <span style="color: #000040;">/</span> <span style="color: #0000dd;">4</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
            putText<span style="color: #008000;">&#40;</span>image, title, org, CV_FONT_HERSHEY_COMPLEX, <span style="color: #0000dd;">2</span>, color, <span style="color: #0000dd;">5</span>, CV_AA<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
        <span style="color: #008000;">&#125;</span>
        <span style="color: #666666;">// we draw the ball anyway</span>
        circle<span style="color: #008000;">&#40;</span>image, recPos, rectsz, Scalar<span style="color: #008000;">&#40;</span><span style="color: #0000dd;">0</span>, <span style="color: #0000dd;">0</span>, <span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span>, CV_FILLED, CV_AA<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
        <span style="color: #666666;">// the game in itself is simple</span>
        <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>game<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
            <span style="color: #666666;">// the real thing happens here</span>
            <span style="color: #666666;">// 0=check won or not</span>
            <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>recPos.<span style="color: #007788;">x</span> <span style="color: #000080;">&lt;</span> rectsz<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
                <span style="color: #666666;">// left lost !</span>
                win <span style="color: #000080;">=</span> <span style="color: #0000dd;">2</span><span style="color: #008080;">;</span>
                game <span style="color: #000080;">=</span> <span style="color: #0000ff;">false</span><span style="color: #008080;">;</span>
            <span style="color: #008000;">&#125;</span> <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>width <span style="color: #000040;">-</span> recPos.<span style="color: #007788;">x</span> <span style="color: #000080;">&lt;</span> rectsz<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
                <span style="color: #666666;">// right lost !</span>
                win <span style="color: #000080;">=</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
                game <span style="color: #000080;">=</span> <span style="color: #0000ff;">false</span><span style="color: #008080;">;</span>
            <span style="color: #008000;">&#125;</span> <span style="color: #0000ff;">else</span> <span style="color: #008000;">&#123;</span>
                <span style="color: #666666;">// we compute the ball displacement</span>
                <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>recSpeed.<span style="color: #007788;">x</span> <span style="color: #000080;">==</span> <span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
                    <span style="color: #666666;">// we reset the direction</span>
                    recSpeed <span style="color: #000080;">=</span> PVect<span style="color: #008000;">&#40;</span><span style="color:#800080;">1.0</span>, <span style="color:#800080;">0.0</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
                <span style="color: #008000;">&#125;</span>
&nbsp;
                <span style="color: #666666;">// the new position</span>
                PVect v <span style="color: #000080;">=</span> computeSpeed<span style="color: #008000;">&#40;</span>recSpeed, speed<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
                recPos <span style="color: #000080;">=</span> recPos <span style="color: #000040;">+</span> v<span style="color: #008080;">;</span>
&nbsp;
                <span style="color: #666666;">// computation of the new speed</span>
                PVect nextPos <span style="color: #000080;">=</span> recPos <span style="color: #000040;">+</span> v<span style="color: #008080;">;</span>
                <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>nextPos.<span style="color: #007788;">x</span> <span style="color: #000080;">&lt;</span> margin <span style="color: #000040;">+</span> rectsz<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
                    <span style="color: #666666;">// check for x-bounce on left</span>
                    <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #0000dd;">abs</span><span style="color: #008000;">&#40;</span>lastLeftPos <span style="color: #000040;">-</span> nextPos.<span style="color: #007788;">y</span><span style="color: #008000;">&#41;</span> <span style="color: #000080;">&lt;</span> pingsz <span style="color: #000040;">+</span> <span style="color:#800080;">0.75</span> <span style="color: #000040;">*</span> rectsz<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
                        <span style="color: #666666;">// we bounce !</span>
                        <span style="color: #666666;">// we use the history to check the pad &quot;speed&quot;</span>
                        <span style="color: #666666;">// orientation and put that in the ball new speed</span>
                        point disp <span style="color: #000080;">=</span> leftMarker<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>lastDisplacement<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
                        <span style="color: #0000ff;">double</span> orient <span style="color: #000080;">=</span> disp.<span style="color: #007788;">y</span> <span style="color: #000040;">/</span> <span style="color: #0000ff;">double</span><span style="color: #008000;">&#40;</span>height<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// div by disp.t ?</span>
                        orient <span style="color: #000040;">*</span><span style="color: #000080;">=</span> <span style="color:#800080;">5.0</span><span style="color: #008080;">;</span>
                        <span style="color: #666666;">// =&gt; unit vector of (0,orient) + recSpeed</span>
                        recSpeed <span style="color: #000080;">=</span> processSpeed<span style="color: #008000;">&#40;</span>recSpeed <span style="color: #000040;">+</span> PVect<span style="color: #008000;">&#40;</span><span style="color: #000040;">-</span><span style="color:#800080;">1.0</span>, <span style="color:#800080;">0.0</span><span style="color: #008000;">&#41;</span>, orient<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
                    <span style="color: #008000;">&#125;</span>
                <span style="color: #008000;">&#125;</span> <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>width <span style="color: #000040;">-</span> nextPos.<span style="color: #007788;">x</span> <span style="color: #000080;">&lt;</span> margin <span style="color: #000040;">+</span> rectsz<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
                    <span style="color: #666666;">// check for x-bounce on right</span>
                    <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #0000dd;">abs</span><span style="color: #008000;">&#40;</span>lastRightPos <span style="color: #000040;">-</span> nextPos.<span style="color: #007788;">y</span><span style="color: #008000;">&#41;</span> <span style="color: #000080;">&lt;</span> pingsz <span style="color: #000040;">+</span> <span style="color:#800080;">0.75</span> <span style="color: #000040;">*</span> rectsz<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
                        <span style="color: #666666;">// we bounce !</span>
                        point disp <span style="color: #000080;">=</span> rightMarker<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>lastDisplacement<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
                        <span style="color: #0000ff;">double</span> orient <span style="color: #000080;">=</span> disp.<span style="color: #007788;">y</span> <span style="color: #000040;">/</span> <span style="color: #0000ff;">double</span><span style="color: #008000;">&#40;</span>height<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// div by disp.t ?</span>
                        orient <span style="color: #000040;">*</span><span style="color: #000080;">=</span> <span style="color:#800080;">5.0</span><span style="color: #008080;">;</span>
                        recSpeed <span style="color: #000080;">=</span> processSpeed<span style="color: #008000;">&#40;</span>recSpeed <span style="color: #000040;">+</span> PVect<span style="color: #008000;">&#40;</span><span style="color:#800080;">1.0</span>, <span style="color:#800080;">0.0</span><span style="color: #008000;">&#41;</span>, orient<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
                    <span style="color: #008000;">&#125;</span>
                <span style="color: #008000;">&#125;</span>
                <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>nextPos.<span style="color: #007788;">y</span> <span style="color: #000080;">&lt;</span> <span style="color: #0000dd;">0</span> <span style="color: #000040;">||</span> nextPos.<span style="color: #007788;">y</span> <span style="color: #000080;">&gt;</span> height<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
                    <span style="color: #666666;">// y-bounce</span>
                    recSpeed <span style="color: #000080;">=</span> PVect<span style="color: #008000;">&#40;</span>recSpeed.<span style="color: #007788;">x</span>, <span style="color: #000040;">-</span>recSpeed.<span style="color: #007788;">y</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
                <span style="color: #008000;">&#125;</span>
            <span style="color: #008000;">&#125;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #666666;">// ### END = display</span>
        imshow<span style="color: #008000;">&#40;</span>window, image<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
        setMouseCallback<span style="color: #008000;">&#40;</span>window, onMouse, <span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
        <span style="color: #666666;">// check keyboard events</span>
        <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #000040;">!</span>pollKeys<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
            <span style="color: #0000ff;">break</span><span style="color: #008080;">;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #666666;">// all's done</span>
    <span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;Done capturing.&quot;</span> <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
    <span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;Bye.&quot;</span> <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
    <span style="color: #0000ff;">return</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>While I hope it can be useful to someone. Feel free to dig into it, there&#8217;s nothing really complicated.</p>
<p>It uses :</p>
<ul>
<li><a href="http://opencv.willowgarage.com/wiki/" title="OpenCV library" target="_blank">OpenCV 2.3</a> (see useful <a href="http://opencv.itseez.com/" title="OpenCV Documentation" target="_blank">documentation</a>)</li>
<li><a href="http://www.boost.org/" title="Boost C++ library" target="_blank">Boost</a> (mostly for pointer management)</li>
</ul>
<p>Just tell me back if you achieved something interesting with it. <img src='http://news.wox-xion.ch/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://news.wox-xion.ch/2012/05/gesture-tracking-library/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ixydhrien</title>
		<link>http://news.wox-xion.ch/2012/04/xvoe/</link>
		<comments>http://news.wox-xion.ch/2012/04/xvoe/#comments</comments>
		<pubDate>Mon, 30 Apr 2012 17:29:36 +0000</pubDate>
		<dc:creator>Alexandre Kaspar</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Xvoe]]></category>

		<guid isPermaLink="false">http://news.wox-xion.ch/?post_type=ha_events&#038;p=1333</guid>
		<description><![CDATA[<p><img width="260" height="431" src="http://news.wox-xion.ch/wp-content/uploads/2012/04/World-260x431.jpg" class="attachment-medium wp-post-image" alt="World" title="World" /></p>The world is just what you make of it. <a href="http://news.wox-xion.ch/2012/04/xvoe/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<img width="260" height="431" src="http://news.wox-xion.ch/wp-content/uploads/2012/04/World-260x431.jpg" class="attachment-medium wp-post-image" alt="World" title="World" /><p><img width="260" height="431" src="http://news.wox-xion.ch/wp-content/uploads/2012/04/World-260x431.jpg" class="attachment-medium wp-post-image" alt="World" title="World" /></p><p></p><br /><p>Fork du projet <a title="Informations à propos du projet et du fork xvoe" href="/projets/xyndhra">Xyndhra</a>, il s&#8217;agit d&#8217;un moteur java permettant la création et la mise sur pied de mondes virtuels accessibles à plusieurs joueurs. Il n&#8217;a pas l&#8217;intention d&#8217;être un MMORPG, mais simplement une plateforme d&#8217;expression imaginative et expérimentale.</p>
<h2>Projets connexes</h2>
<p>Xvoe, ce sont trois projets :</p>
<ul>
<li>Le serveur Suhnydr</li>
<li>Le client Xuhnix</li>
<li>L&#8217;éditeur de map Yggdrasil</li>
</ul>
<h3>Suhnydr</h3>
<p>Le projet Suhnydr consiste en un serveur de mondes virtuels configurable au moyens de définitions xml ainsi qu’extensible par ces derniers et au moyen d’interfaces Java.</p>
<p>Le serveur gère la partie sensible des données et est le seul à avoir raison s’il y a conflit avec un client :</p>
<ul>
<li>PathFinding : le serveur gère les déplacements des personnages en définissant les chemins empruntés pour les déplacements optimaux</li>
<li>Scénario et événements : le scénario est défini par des événements (contacts, actions, effets) et des chaînes d’actions. Ainsi des dialogues continus entre le serveur et les clients peuvent avoir lieu. On peut imaginer des joueurs virtuels échangeant des objets avec les joueurs réels, les combattant ou discutant simplement en marchant ou devant une table …</li>
<li>Actions, compétences : les entités peuvent utiliser des compétences, les développer, en apprendre, les oublier …</li>
<li>Objets, équipement et échanges : les entités peuvent posséder des objets, les utiliser, les jeter, les placer dans le monde, les échanger avec d’autres entités, les mettre en vente …</li>
<li>Système d’Intelligence Artifielle : le développement artificiel permet l’existence d’entités virtuels avec lesquels les joueurs peuvent intéragir, lesquels peuvent se déplacer, parler, répondre à des événements, des paroles, peuvent échanger des objets, en utiliser, en placer, en jeter, avoir un cycle spécifique d’actions. De même, les créatures ont des besoins qu’elles assouvissent, suivent des lois plus ou moins naturelles au même titre que les végétaux qui peuvent être cultivés, dupliqués, récoltés et se développent aussi indépendamment de l’action humaine.</li>
</ul>
<p>Pour des informations plus précises, référez-vous à sa <a title="Page de développement du projet Suhnydr" href="http://dev.wox-xion.ch/xvoe/suhnydr">page de développement</a>.</p>
<h3>Xuhnix</h3>
<p>Le projet Xuhnix consiste en un client permettant l&#8217;accès à des mondes virtuels.</p>
<p>Il utilise Java et l&#8217;interfaçage basique de Swing pour l&#8217;affichage. La bibliothèque de composants est par contre développée de manière interne et totalement personnalisable via des fichiers xml.</p>
<p>Pour des informations plus précises, veuillez vous référer à sa <a title="Page de développement du client xuhnix" href="http://dev.wox-xion.ch/xvoe/xuhnix">page de développement</a>.</p>
<h3>Yggdrasil</h3>
<p>Ce projet est à l&#8217;origine l&#8217;éditeur de map de <a title="Projet de MMORPG" href="/projets/xyndhra">Xyndhra</a>.</p>
<p>Il permet la création, sauvegarde et l&#8217;édition de maps 3d isométriques selon un format xml spécifique (fichiers .xwd). Il est développé en Java et gère actuellement :</p>
<ul>
<li>gestion de la sélection à travers une map scrollable</li>
<li>gestion de la heightmap</li>
<li>gestion du background sous forme de morceaux de terrain</li>
<li>gestion de tiles (objets possédant une profondeur)</li>
<li>gestion des tiles de terrains ou pseudo-textures</li>
<li>gestion de l&#8217;accessibilité (en cours)</li>
<li>gestion des marqueurs événementiels</li>
<li>gestion de la luminosité des différents objets graphiques</li>
</ul>
<p>Pourquoi un tel nom ? et bien parce qu&#8217;il s&#8217;agit de l&#8217;<a title="Information sur Yggdrasil dans la mythologie nordique" href="http://fr.wikipedia.org/wiki/Yggdrasil" target="_blank">Arbre du Monde</a> dans la mythologie nordique.</p>
<p>L&#8217;éditeur est téléchargeable publiquement et gratuitement sur sa <a title="Page de développement d'Yggdrasil" href="http://dev.wox-xion.ch/xvoe/yggdrasil">page de développement</a>.</p>
<h2>Projets internes</h2>
<p>Le développement de Xvoe se fait par morceaux étant donné le temps fragmenté que j&#8217;ai à disposition. Pour cela, plusieurs sous-projets ont été développés. Parmi eux, certains sont rattachés à Xga et d&#8217;autres sont indépendants tels que Xio.</p>
<p>Les projets actuels attachés à Xga :</p>
<ul>
<li><a href="http://dev.wox-xion.ch/xga/xv">XV</a> : Xga Viewer &#8211; un visionneur de fichier xga</li>
<li><a href="http://dev.wox-xion.ch/xga/editor">Xga Editor</a> &#8211; un éditeur de fichier xga rudimentaire (permet l&#8217;empaquetage de sources graphiques)</li>
<li><a href="http://dev.wox-xion.ch/xga/ta">Xga TileAnimator</a> &#8211; un éditeur de tileset permettant la conversion d&#8217;une animation au format d&#8217;une image contenant les images séparées de l&#8217;animation, en un personnage animé au format xga</li>
<li><strong>Chae</strong> : Character Editor &#8211; l&#8217;éditeur de personnages sous formes de squelettes</li>
</ul>
<p>Les autres projets internes :</p>
<ul>
<li>Xio : eXtensible Integrated Object &#8211; le format à la &laquo;&nbsp;json&nbsp;&raquo;, extensible et plus léger</li>
<li>Lixl : Library Independant Xml Library &#8211; une implémentation &laquo;&nbsp;implementation free&nbsp;&raquo; de xml permettant de choisir son implémentation</li>
</ul>
<h2>Status</h2>
<p>Le développement du premier prototype [<strong>1</strong>] s&#8217;est arrêté étant donné que l&#8217;optimisation était impossible selon les lignes choisies. Un <a title="Page du second prototype xvoe.2" href="http://dev.wox-xion.ch/xvoe2" target="_blank">second prototype</a> [<strong>2</strong>] a démarré sur une toute autre voie (opengl et 3d), mais sert plus de piste et n&#8217;a pas grand chose à voir avoir le premier; il a même été nommé différemment : <a title="Projet Noyarch" href="/tag/noyarch/"><strong>Noyarch</strong></a>.</p>
<p>A noter que la première version a été récemment reprise et un troisième prototype est désormais plus ou moins fonctionnel. Il abandonne l&#8217;utilisation d&#8217;opengl et creuse de nouvelles voies d&#8217;optimisation récemment découvertes.</p>
<p>Toutes les informations complémentaires sont accessibles sur la <a title="Page de développement" href="http://dev.wox-xion.ch/xvoe" target="_blank">page de développement</a>.</p>
<p><strong>Nouveau</strong> : le <a title="Site du projet iXydhrien" href="http://xvoe.wox-xion.ch" target="_blank">site du projet</a> a ouvert !</p>
]]></content:encoded>
			<wfw:commentRss>http://news.wox-xion.ch/2012/04/xvoe/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Arghk</title>
		<link>http://news.wox-xion.ch/2012/03/arghk/</link>
		<comments>http://news.wox-xion.ch/2012/03/arghk/#comments</comments>
		<pubDate>Sun, 04 Mar 2012 11:57:45 +0000</pubDate>
		<dc:creator>Alexandre Kaspar</dc:creator>
				<category><![CDATA[Drawings]]></category>
		<category><![CDATA[arghk]]></category>
		<category><![CDATA[drawings]]></category>
		<category><![CDATA[watercolour]]></category>

		<guid isPermaLink="false">http://news.wox-xion.ch/?p=1321</guid>
		<description><![CDATA[<img width="260" height="172" src="http://news.wox-xion.ch/wp-content/uploads/2012/03/IMG_8114-small-400x266.jpg" class="attachment-medium wp-post-image" alt="IMG_8114-small" title="IMG_8114-small" /><p><img width="260" height="172" src="http://news.wox-xion.ch/wp-content/uploads/2012/03/IMG_8114-small-400x266.jpg" class="attachment-medium wp-post-image" alt="IMG_8114-small" title="IMG_8114-small" /></p>Je pense que le mot raisonne assez fort dans ma tête. En tout cas, j&#8217;en aurai fait quelque chose, au moins&#8230; En fait, je suis en recherche d&#8217;un stage au Japon pour mon master&#8230; Qui plus est, je suis en&#8230; <a href="http://news.wox-xion.ch/2012/03/arghk/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<img width="260" height="172" src="http://news.wox-xion.ch/wp-content/uploads/2012/03/IMG_8114-small-400x266.jpg" class="attachment-medium wp-post-image" alt="IMG_8114-small" title="IMG_8114-small" /><p><img width="260" height="172" src="http://news.wox-xion.ch/wp-content/uploads/2012/03/IMG_8114-small-400x266.jpg" class="attachment-medium wp-post-image" alt="IMG_8114-small" title="IMG_8114-small" /></p><p></p><br /><p>Je pense que le mot raisonne assez fort dans ma tête.</p>
<p>En tout cas, j&#8217;en aurai fait quelque chose, au moins&#8230;</p>
<p><em>En fait, je suis en recherche d&#8217;un stage au Japon pour mon master&#8230;</em> <img src='http://news.wox-xion.ch/wp-includes/images/smilies/icon_razz.gif' alt=':-P' class='wp-smiley' /> </p>
<p>Qui plus est, je suis en train de lire &laquo;&nbsp;Le mythe de Sisyphe&nbsp;&raquo; de Camus. J&#8217;ai beaucoup apprécié &laquo;&nbsp;L&#8217;envers et l&#8217;endroit&nbsp;&raquo; et me devais d&#8217;aller un peu plus loin&#8230;</p>
<p>L&#8217;absurde, ou pas&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://news.wox-xion.ch/2012/03/arghk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Japan Impact 2012</title>
		<link>http://news.wox-xion.ch/2012/03/japan-impact-2012/</link>
		<comments>http://news.wox-xion.ch/2012/03/japan-impact-2012/#comments</comments>
		<pubDate>Sun, 04 Mar 2012 11:51:54 +0000</pubDate>
		<dc:creator>Alexandre Kaspar</dc:creator>
				<category><![CDATA[Photography]]></category>
		<category><![CDATA[Vie]]></category>
		<category><![CDATA[epfl]]></category>
		<category><![CDATA[japan]]></category>
		<category><![CDATA[photography]]></category>

		<guid isPermaLink="false">http://news.wox-xion.ch/?p=1316</guid>
		<description><![CDATA[<img width="260" height="390" src="http://news.wox-xion.ch/wp-content/uploads/2012/03/IMG_7229-266x400.jpg" class="attachment-medium wp-post-image" alt="IMG_7229" title="IMG_7229" /><p><img width="260" height="390" src="http://news.wox-xion.ch/wp-content/uploads/2012/03/IMG_7229-266x400.jpg" class="attachment-medium wp-post-image" alt="IMG_7229" title="IMG_7229" /></p>Japan Impact a eu lieu le weekend passé (25 et 26 février 2012), et l&#8217;ambiance y était. Qui plus est, une nouvelle gallerie lui est consacré.]]></description>
			<content:encoded><![CDATA[<img width="260" height="390" src="http://news.wox-xion.ch/wp-content/uploads/2012/03/IMG_7229-266x400.jpg" class="attachment-medium wp-post-image" alt="IMG_7229" title="IMG_7229" /><p><img width="260" height="390" src="http://news.wox-xion.ch/wp-content/uploads/2012/03/IMG_7229-266x400.jpg" class="attachment-medium wp-post-image" alt="IMG_7229" title="IMG_7229" /></p><p></p><br /><p><a title="Le site de l'événement" href="http://www.japan-impact.ch" target="_blank">Japan Impact</a> a eu lieu le weekend passé (25 et 26 février 2012), et l&#8217;ambiance y était.</p>
<p>Qui plus est, une <a title="Japan Impact 2012 en images" href="http://gallery.wox-xion.ch/2012/japanimpact/">nouvelle gallerie</a> lui est consacré.</p>
]]></content:encoded>
			<wfw:commentRss>http://news.wox-xion.ch/2012/03/japan-impact-2012/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenCV Ping Pong using color markers</title>
		<link>http://news.wox-xion.ch/2012/02/opencv-ping-pong-using-color-markers/</link>
		<comments>http://news.wox-xion.ch/2012/02/opencv-ping-pong-using-color-markers/#comments</comments>
		<pubDate>Fri, 10 Feb 2012 19:19:47 +0000</pubDate>
		<dc:creator>Alexandre Kaspar</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[color tracking]]></category>
		<category><![CDATA[opencv]]></category>
		<category><![CDATA[ping pong]]></category>
		<category><![CDATA[tracking]]></category>

		<guid isPermaLink="false">http://news.wox-xion.ch/?p=1313</guid>
		<description><![CDATA[<img width="260" height="202" src="http://news.wox-xion.ch/wp-content/uploads/2012/02/MarkerPingPong-400x312.png" class="attachment-medium wp-post-image" alt="MarkerPingPong" title="MarkerPingPong" /><p><img width="260" height="202" src="http://news.wox-xion.ch/wp-content/uploads/2012/02/MarkerPingPong-400x312.png" class="attachment-medium wp-post-image" alt="MarkerPingPong" title="MarkerPingPong" /></p>The library I started after the announce of the public release of Wuw from Sixth Sense on googlecode is now getting somewhat stable (and more importantly, it works). Here is a video : I will put the code on a&#8230; <a href="http://news.wox-xion.ch/2012/02/opencv-ping-pong-using-color-markers/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<img width="260" height="202" src="http://news.wox-xion.ch/wp-content/uploads/2012/02/MarkerPingPong-400x312.png" class="attachment-medium wp-post-image" alt="MarkerPingPong" title="MarkerPingPong" /><p><img width="260" height="202" src="http://news.wox-xion.ch/wp-content/uploads/2012/02/MarkerPingPong-400x312.png" class="attachment-medium wp-post-image" alt="MarkerPingPong" title="MarkerPingPong" /></p><p></p><br /><p>The library I started after the announce of the public release of Wuw from <a href="http://code.google.com/p/sixthsense/" title="Sixth Sense on google code" target="_blank">Sixth Sense on googlecode</a> is now getting somewhat stable (and more importantly, it works).</p>
<p>Here is a video :</p>
<p><iframe width="356" height="200" src="http://www.youtube.com/embed/E6DiZOJV0sc?fs=1&#038;feature=oembed" frameborder="0" allowfullscreen></iframe></p>
<p>I will put the code on a public repository when I&#8217;ll have some time.<br />
See you soon. <img src='http://news.wox-xion.ch/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://news.wox-xion.ch/2012/02/opencv-ping-pong-using-color-markers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pure virtual &amp; constructors</title>
		<link>http://news.wox-xion.ch/2012/02/pure-virtual-function-and-constructors/</link>
		<comments>http://news.wox-xion.ch/2012/02/pure-virtual-function-and-constructors/#comments</comments>
		<pubDate>Thu, 09 Feb 2012 00:42:45 +0000</pubDate>
		<dc:creator>Alexandre Kaspar</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[c++]]></category>

		<guid isPermaLink="false">http://news.wox-xion.ch/?p=1303</guid>
		<description><![CDATA[Never call virtual functions during construction or destruction unless you want bugs. <a href="http://news.wox-xion.ch/2012/02/pure-virtual-function-and-constructors/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p></p><br /><p>So, I made a silly mistake which I didn&#8217;t know about, once again.</p>
<p>What&#8217;s wrong with the following (shortened) C++ class declaration ?</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #ff0000; font-style: italic;">/**
 * Abstract color filter
 */</span>
<span style="color: #0000ff;">class</span> ColorFilter <span style="color: #008000;">&#123;</span>
<span style="color: #0000ff;">public</span><span style="color: #008080;">:</span>
&nbsp;
    <span style="color: #0000ff;">virtual</span> <span style="color: #0000ff;">void</span> reset<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
        adjust<span style="color: #008000;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #ff0000; font-style: italic;">/**
     * Constructor using an initial patch
     * 
     * @param p the initial patch used to create the filter
     */</span>
    <span style="color: #0000ff;">explicit</span> ColorFilter<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">const</span> Mat<span style="color: #000040;">&amp;</span> p<span style="color: #008000;">&#41;</span>
    <span style="color: #008080;">:</span> patch<span style="color: #008000;">&#40;</span>p<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
      reset<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    ColorFilter<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">const</span> ColorFilter<span style="color: #000040;">&amp;</span> orig<span style="color: #008000;">&#41;</span> <span style="color: #008080;">:</span> patch<span style="color: #008000;">&#40;</span>orig.<span style="color: #007788;">patch</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span><span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">protected</span><span style="color: #008080;">:</span>
    <span style="color: #ff0000; font-style: italic;">/**
     * The base patch
     */</span>
    <span style="color: #0000ff;">const</span> Mat<span style="color: #000040;">&amp;</span> patch<span style="color: #008080;">;</span>
&nbsp;
    <span style="color: #ff0000; font-style: italic;">/**
     * Adjust the filter (narrow or broaden 
     * depending on the given factor)
     * 
     * @param d the direction of change
     * @return whether it worked
     */</span>
    <span style="color: #0000ff;">virtual</span> <span style="color: #0000ff;">bool</span> adjust<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> d<span style="color: #008000;">&#41;</span> <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span></pre></div></div>

<p>From Java, you would expect that you can call your abstract function from the constructor. And you&#8217;d be right.</p>
<p>But you&#8217;d be in Java&#8230;</p>
<p>In C++, the instantiation process is a bit different and the result is that when you call the base class, its constructor can only &laquo;&nbsp;see&nbsp;&raquo; what is around in the base class, but nothing from the possible derived-classes.</p>
<p>One of the several reasons you can <a href="http://www.artima.com/cppsource/nevercall.html" title="Never call virtual methods in constructors or destructors" target="_blank">read about</a> on artima is that you have to initialize the elements of your class before doing anything, and of course, the first thing you do from the derived class is call the constructor of the base one.</p>
<p>Thus, when you&#8217;re in this base constructor, there&#8217;s still nothing initialized in the derived-level. And thus you cannot use any variable from there, and especially (more importantly) <strong>no pure virtual method</strong> since these are surely only accessible from the upper levels, and aren&#8217;t available at this moment.</p>
<p>In the example above, I&#8217;m calling a virtual method, but which in turn is calling a <em>pure virtual</em> one, which I cannot do at that moment of the initialization phase.</p>
<p>And now, to go further, we could technically call virtual methods, but notice that they won&#8217;t behave as virtual methods since their upper-version isn&#8217;t reachable yet, so they behave as virtual function which aren&#8217;t overriden yet. Thus the following example (taken from a <a href="http://stackoverflow.com/questions/496440/c-virtual-function-from-constructor" title="Post on SO about the problem" target="_blank">post on stackoverflow</a>) prints <strong>0</strong> and not <em>1</em> :</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #339900;">#include &lt;iostream&gt;</span>
<span style="color: #0000ff;">struct</span> base <span style="color: #008000;">&#123;</span>
   <span style="color: #0000ff;">virtual</span> <span style="color: #0000ff;">const</span> <span style="color: #0000ff;">int</span> value<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #0000ff;">const</span> <span style="color: #008000;">&#123;</span>
      <span style="color: #0000ff;">return</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
   <span style="color: #008000;">&#125;</span>
   base<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
      std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> value<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #000080;">&lt;&lt;</span> std<span style="color: #008080;">::</span><span style="color: #007788;">endl</span><span style="color: #008080;">;</span>
   <span style="color: #008000;">&#125;</span>
   <span style="color: #0000ff;">virtual</span> ~base<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span><span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #0000ff;">struct</span> derived <span style="color: #008080;">:</span> <span style="color: #0000ff;">public</span> base <span style="color: #008000;">&#123;</span>
   <span style="color: #0000ff;">virtual</span> <span style="color: #0000ff;">const</span> <span style="color: #0000ff;">int</span> value<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #0000ff;">const</span> <span style="color: #008000;">&#123;</span>
      <span style="color: #0000ff;">return</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
   <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #0000ff;">int</span> main<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">void</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
   derived example<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>See you soon <img src='http://news.wox-xion.ch/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://news.wox-xion.ch/2012/02/pure-virtual-function-and-constructors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Galleries hivernales</title>
		<link>http://news.wox-xion.ch/2012/02/galleries-hivernales/</link>
		<comments>http://news.wox-xion.ch/2012/02/galleries-hivernales/#comments</comments>
		<pubDate>Sun, 05 Feb 2012 21:06:37 +0000</pubDate>
		<dc:creator>Alexandre Kaspar</dc:creator>
				<category><![CDATA[Photography]]></category>
		<category><![CDATA[Vie]]></category>
		<category><![CDATA[photography]]></category>
		<category><![CDATA[ski]]></category>
		<category><![CDATA[snow]]></category>
		<category><![CDATA[Switzerland]]></category>

		<guid isPermaLink="false">http://news.wox-xion.ch/?p=1298</guid>
		<description><![CDATA[<img width="260" height="172" src="http://news.wox-xion.ch/wp-content/uploads/2012/02/IMG_6939-400x266.jpg" class="attachment-medium wp-post-image" alt="Chalavornaire" title="IMG_6939" /><p><img width="260" height="172" src="http://news.wox-xion.ch/wp-content/uploads/2012/02/IMG_6939-400x266.jpg" class="attachment-medium wp-post-image" alt="Chalavornaire" title="IMG_6939" /></p>Et déjà deux galleries pour cet hiver. A noter qu&#8217;une est la première de la série 2012 : le Fourchon le Grammont Il fait très froid ces temps-ci&#8230; bon ski malgré tout.]]></description>
			<content:encoded><![CDATA[<img width="260" height="172" src="http://news.wox-xion.ch/wp-content/uploads/2012/02/IMG_6939-400x266.jpg" class="attachment-medium wp-post-image" alt="Chalavornaire" title="IMG_6939" /><p><img width="260" height="172" src="http://news.wox-xion.ch/wp-content/uploads/2012/02/IMG_6939-400x266.jpg" class="attachment-medium wp-post-image" alt="Chalavornaire" title="IMG_6939" /></p><p></p><br /><p>Et déjà deux galleries pour cet hiver. A noter qu&#8217;une est la première de la <a title="Galleries 2012" href="http://gallery.wox-xion.ch/2012">série 2012</a> :</p>
<ul>
<li>le <a title="Randonnée au Fourchon" href="http://gallery.wox-xion.ch/2011/fourchon">Fourchon</a></li>
<li>le <a title="Randonnée au Grammont" href="http://gallery.wox-xion.ch/2012/grammont">Grammont</a></li>
</ul>
<p>Il fait très froid ces temps-ci&#8230; bon ski malgré tout. <img src='http://news.wox-xion.ch/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://news.wox-xion.ch/2012/02/galleries-hivernales/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Operator unspecified-bool-type</title>
		<link>http://news.wox-xion.ch/2012/01/operator-unspecified-bool-type/</link>
		<comments>http://news.wox-xion.ch/2012/01/operator-unspecified-bool-type/#comments</comments>
		<pubDate>Tue, 31 Jan 2012 16:38:13 +0000</pubDate>
		<dc:creator>Alexandre Kaspar</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[operator]]></category>

		<guid isPermaLink="false">http://news.wox-xion.ch/?p=1280</guid>
		<description><![CDATA[The unspecified-bool-type C++ operator from shared_ptr in the boost library. <a href="http://news.wox-xion.ch/2012/01/operator-unspecified-bool-type/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p></p><br /><p>I&#8217;ve been coding mostly in C++ these times (and will still given that the STL and boost are really easy to use). But I never stop being surprised by C++.</p>
<p>Recently, I&#8217;ve found yet another new operator I didn&#8217;t know from the <a title="Shared pointer" href="http://www.boost.org/doc/libs/1_48_0/libs/smart_ptr/shared_ptr.htm" target="_blank">shared_ptr</a> documentation of boost. Here is its <a title="Synopsis of shared_ptr" href="http://www.boost.org/doc/libs/1_48_0/libs/smart_ptr/shared_ptr.htm#Synopsis" target="_blank">synopsis</a> :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">namespace</span> boost <span style="color: #008000;">&#123;</span>
&nbsp;
  <span style="color: #0000ff;">class</span> bad_weak_ptr<span style="color: #008080;">:</span> <span style="color: #0000ff;">public</span> std<span style="color: #008080;">::</span><span style="color: #007788;">exception</span><span style="color: #008080;">;</span>
&nbsp;
  <span style="color: #0000ff;">template</span><span style="color: #000080;">&lt;</span><span style="color: #0000ff;">class</span> T<span style="color: #000080;">&gt;</span> <span style="color: #0000ff;">class</span> weak_ptr<span style="color: #008080;">;</span>
&nbsp;
  <span style="color: #0000ff;">template</span><span style="color: #000080;">&lt;</span><span style="color: #0000ff;">class</span> T<span style="color: #000080;">&gt;</span> <span style="color: #0000ff;">class</span> shared_ptr <span style="color: #008000;">&#123;</span>
&nbsp;
    <span style="color: #0000ff;">public</span><span style="color: #008080;">:</span>
&nbsp;
      <span style="color: #0000ff;">typedef</span> T element_type<span style="color: #008080;">;</span>
&nbsp;
      shared_ptr<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// never throws</span>
      <span style="color: #0000ff;">template</span><span style="color: #000080;">&lt;</span><span style="color: #0000ff;">class</span> Y<span style="color: #000080;">&gt;</span> <span style="color: #0000ff;">explicit</span> shared_ptr<span style="color: #008000;">&#40;</span>Y <span style="color: #000040;">*</span> p<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
      <span style="color: #0000ff;">template</span><span style="color: #000080;">&lt;</span><span style="color: #0000ff;">class</span> Y, <span style="color: #0000ff;">class</span> D<span style="color: #000080;">&gt;</span> shared_ptr<span style="color: #008000;">&#40;</span>Y <span style="color: #000040;">*</span> p, D d<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
      <span style="color: #0000ff;">template</span><span style="color: #000080;">&lt;</span><span style="color: #0000ff;">class</span> Y, <span style="color: #0000ff;">class</span> D, <span style="color: #0000ff;">class</span> A<span style="color: #000080;">&gt;</span> shared_ptr<span style="color: #008000;">&#40;</span>Y <span style="color: #000040;">*</span> p, D d, A a<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
      ~shared_ptr<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// never throws</span>
&nbsp;
      shared_ptr<span style="color: #008000;">&#40;</span>shared_ptr <span style="color: #0000ff;">const</span> <span style="color: #000040;">&amp;</span> r<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// never throws</span>
      <span style="color: #0000ff;">template</span><span style="color: #000080;">&lt;</span><span style="color: #0000ff;">class</span> Y<span style="color: #000080;">&gt;</span> shared_ptr<span style="color: #008000;">&#40;</span>shared_ptr<span style="color: #000080;">&lt;</span>Y<span style="color: #000080;">&gt;</span> <span style="color: #0000ff;">const</span> <span style="color: #000040;">&amp;</span> r<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// never throws</span>
      <span style="color: #0000ff;">template</span><span style="color: #000080;">&lt;</span><span style="color: #0000ff;">class</span> Y<span style="color: #000080;">&gt;</span> shared_ptr<span style="color: #008000;">&#40;</span>shared_ptr<span style="color: #000080;">&lt;</span>Y<span style="color: #000080;">&gt;</span> <span style="color: #0000ff;">const</span> <span style="color: #000040;">&amp;</span> r, T <span style="color: #000040;">*</span> p<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// never throws</span>
      <span style="color: #0000ff;">template</span><span style="color: #000080;">&lt;</span><span style="color: #0000ff;">class</span> Y<span style="color: #000080;">&gt;</span> <span style="color: #0000ff;">explicit</span> shared_ptr<span style="color: #008000;">&#40;</span>weak_ptr<span style="color: #000080;">&lt;</span>Y<span style="color: #000080;">&gt;</span> <span style="color: #0000ff;">const</span> <span style="color: #000040;">&amp;</span> r<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
      <span style="color: #0000ff;">template</span><span style="color: #000080;">&lt;</span><span style="color: #0000ff;">class</span> Y<span style="color: #000080;">&gt;</span> <span style="color: #0000ff;">explicit</span> shared_ptr<span style="color: #008000;">&#40;</span>std<span style="color: #008080;">::</span><span style="color: #007788;">auto_ptr</span><span style="color: #000080;">&lt;</span>Y<span style="color: #000080;">&gt;</span> <span style="color: #000040;">&amp;</span> r<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
      shared_ptr <span style="color: #000040;">&amp;</span> operator<span style="color: #000080;">=</span><span style="color: #008000;">&#40;</span>shared_ptr <span style="color: #0000ff;">const</span> <span style="color: #000040;">&amp;</span> r<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// never throws</span>
      <span style="color: #0000ff;">template</span><span style="color: #000080;">&lt;</span><span style="color: #0000ff;">class</span> Y<span style="color: #000080;">&gt;</span> shared_ptr <span style="color: #000040;">&amp;</span> operator<span style="color: #000080;">=</span><span style="color: #008000;">&#40;</span>shared_ptr<span style="color: #000080;">&lt;</span>Y<span style="color: #000080;">&gt;</span> <span style="color: #0000ff;">const</span> <span style="color: #000040;">&amp;</span> r<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// never throws</span>
      <span style="color: #0000ff;">template</span><span style="color: #000080;">&lt;</span><span style="color: #0000ff;">class</span> Y<span style="color: #000080;">&gt;</span> shared_ptr <span style="color: #000040;">&amp;</span> operator<span style="color: #000080;">=</span><span style="color: #008000;">&#40;</span>std<span style="color: #008080;">::</span><span style="color: #007788;">auto_ptr</span><span style="color: #000080;">&lt;</span>Y<span style="color: #000080;">&gt;</span> <span style="color: #000040;">&amp;</span> r<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
      <span style="color: #0000ff;">void</span> reset<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// never throws</span>
      <span style="color: #0000ff;">template</span><span style="color: #000080;">&lt;</span><span style="color: #0000ff;">class</span> Y<span style="color: #000080;">&gt;</span> <span style="color: #0000ff;">void</span> reset<span style="color: #008000;">&#40;</span>Y <span style="color: #000040;">*</span> p<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
      <span style="color: #0000ff;">template</span><span style="color: #000080;">&lt;</span><span style="color: #0000ff;">class</span> Y, <span style="color: #0000ff;">class</span> D<span style="color: #000080;">&gt;</span> <span style="color: #0000ff;">void</span> reset<span style="color: #008000;">&#40;</span>Y <span style="color: #000040;">*</span> p, D d<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
      <span style="color: #0000ff;">template</span><span style="color: #000080;">&lt;</span><span style="color: #0000ff;">class</span> Y, <span style="color: #0000ff;">class</span> D, <span style="color: #0000ff;">class</span> A<span style="color: #000080;">&gt;</span> <span style="color: #0000ff;">void</span> reset<span style="color: #008000;">&#40;</span>Y <span style="color: #000040;">*</span> p, D d, A a<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
      <span style="color: #0000ff;">template</span><span style="color: #000080;">&lt;</span><span style="color: #0000ff;">class</span> Y<span style="color: #000080;">&gt;</span> <span style="color: #0000ff;">void</span> reset<span style="color: #008000;">&#40;</span>shared_ptr<span style="color: #000080;">&lt;</span>Y<span style="color: #000080;">&gt;</span> <span style="color: #0000ff;">const</span> <span style="color: #000040;">&amp;</span> r, T <span style="color: #000040;">*</span> p<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// never throws</span>
&nbsp;
      T <span style="color: #000040;">&amp;</span> operator<span style="color: #000040;">*</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #0000ff;">const</span><span style="color: #008080;">;</span> <span style="color: #666666;">// never throws</span>
      T <span style="color: #000040;">*</span> operator<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #0000ff;">const</span><span style="color: #008080;">;</span> <span style="color: #666666;">// never throws</span>
      T <span style="color: #000040;">*</span> get<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #0000ff;">const</span><span style="color: #008080;">;</span> <span style="color: #666666;">// never throws</span>
&nbsp;
      <span style="color: #0000ff;">bool</span> unique<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #0000ff;">const</span><span style="color: #008080;">;</span> <span style="color: #666666;">// never throws</span>
      <span style="color: #0000ff;">long</span> use_count<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #0000ff;">const</span><span style="color: #008080;">;</span> <span style="color: #666666;">// never throws</span>
&nbsp;
      operator unspecified<span style="color: #000040;">-</span>bool<span style="color: #000040;">-</span>type<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #0000ff;">const</span><span style="color: #008080;">;</span> <span style="color: #666666;">// never throws</span>
&nbsp;
      <span style="color: #0000ff;">void</span> swap<span style="color: #008000;">&#40;</span>shared_ptr <span style="color: #000040;">&amp;</span> b<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// never throws</span>
  <span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
&nbsp;
  <span style="color: #0000ff;">template</span><span style="color: #000080;">&lt;</span><span style="color: #0000ff;">class</span> T, <span style="color: #0000ff;">class</span> U<span style="color: #000080;">&gt;</span>
    <span style="color: #0000ff;">bool</span> operator<span style="color: #000080;">==</span><span style="color: #008000;">&#40;</span>shared_ptr<span style="color: #000080;">&lt;</span>T<span style="color: #000080;">&gt;</span> <span style="color: #0000ff;">const</span> <span style="color: #000040;">&amp;</span> a, shared_ptr<span style="color: #000080;">&lt;</span>U<span style="color: #000080;">&gt;</span> <span style="color: #0000ff;">const</span> <span style="color: #000040;">&amp;</span> b<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// never throws</span>
&nbsp;
  <span style="color: #0000ff;">template</span><span style="color: #000080;">&lt;</span><span style="color: #0000ff;">class</span> T, <span style="color: #0000ff;">class</span> U<span style="color: #000080;">&gt;</span>
    <span style="color: #0000ff;">bool</span> operator<span style="color: #000040;">!</span><span style="color: #000080;">=</span><span style="color: #008000;">&#40;</span>shared_ptr<span style="color: #000080;">&lt;</span>T<span style="color: #000080;">&gt;</span> <span style="color: #0000ff;">const</span> <span style="color: #000040;">&amp;</span> a, shared_ptr<span style="color: #000080;">&lt;</span>U<span style="color: #000080;">&gt;</span> <span style="color: #0000ff;">const</span> <span style="color: #000040;">&amp;</span> b<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// never throws</span>
&nbsp;
  <span style="color: #0000ff;">template</span><span style="color: #000080;">&lt;</span><span style="color: #0000ff;">class</span> T, <span style="color: #0000ff;">class</span> U<span style="color: #000080;">&gt;</span>
    <span style="color: #0000ff;">bool</span> operator<span style="color: #000080;">&lt;</span><span style="color: #008000;">&#40;</span>shared_ptr<span style="color: #000080;">&lt;</span>T<span style="color: #000080;">&gt;</span> <span style="color: #0000ff;">const</span> <span style="color: #000040;">&amp;</span> a, shared_ptr<span style="color: #000080;">&lt;</span>U<span style="color: #000080;">&gt;</span> <span style="color: #0000ff;">const</span> <span style="color: #000040;">&amp;</span> b<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// never throws</span>
&nbsp;
  <span style="color: #0000ff;">template</span><span style="color: #000080;">&lt;</span><span style="color: #0000ff;">class</span> T<span style="color: #000080;">&gt;</span> <span style="color: #0000ff;">void</span> swap<span style="color: #008000;">&#40;</span>shared_ptr<span style="color: #000080;">&lt;</span>T<span style="color: #000080;">&gt;</span> <span style="color: #000040;">&amp;</span> a, shared_ptr<span style="color: #000080;">&lt;</span>T<span style="color: #000080;">&gt;</span> <span style="color: #000040;">&amp;</span> b<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// never throws</span>
&nbsp;
  <span style="color: #0000ff;">template</span><span style="color: #000080;">&lt;</span><span style="color: #0000ff;">class</span> T<span style="color: #000080;">&gt;</span> T <span style="color: #000040;">*</span> get_pointer<span style="color: #008000;">&#40;</span>shared_ptr<span style="color: #000080;">&lt;</span>T<span style="color: #000080;">&gt;</span> <span style="color: #0000ff;">const</span> <span style="color: #000040;">&amp;</span> p<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// never throws</span>
&nbsp;
  <span style="color: #0000ff;">template</span><span style="color: #000080;">&lt;</span><span style="color: #0000ff;">class</span> T, <span style="color: #0000ff;">class</span> U<span style="color: #000080;">&gt;</span>
    shared_ptr<span style="color: #000080;">&lt;</span>T<span style="color: #000080;">&gt;</span> static_pointer_cast<span style="color: #008000;">&#40;</span>shared_ptr<span style="color: #000080;">&lt;</span>U<span style="color: #000080;">&gt;</span> <span style="color: #0000ff;">const</span> <span style="color: #000040;">&amp;</span> r<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// never throws</span>
&nbsp;
  <span style="color: #0000ff;">template</span><span style="color: #000080;">&lt;</span><span style="color: #0000ff;">class</span> T, <span style="color: #0000ff;">class</span> U<span style="color: #000080;">&gt;</span>
    shared_ptr<span style="color: #000080;">&lt;</span>T<span style="color: #000080;">&gt;</span> const_pointer_cast<span style="color: #008000;">&#40;</span>shared_ptr<span style="color: #000080;">&lt;</span>U<span style="color: #000080;">&gt;</span> <span style="color: #0000ff;">const</span> <span style="color: #000040;">&amp;</span> r<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// never throws</span>
&nbsp;
  <span style="color: #0000ff;">template</span><span style="color: #000080;">&lt;</span><span style="color: #0000ff;">class</span> T, <span style="color: #0000ff;">class</span> U<span style="color: #000080;">&gt;</span>
    shared_ptr<span style="color: #000080;">&lt;</span>T<span style="color: #000080;">&gt;</span> dynamic_pointer_cast<span style="color: #008000;">&#40;</span>shared_ptr<span style="color: #000080;">&lt;</span>U<span style="color: #000080;">&gt;</span> <span style="color: #0000ff;">const</span> <span style="color: #000040;">&amp;</span> r<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// never throws</span>
&nbsp;
  <span style="color: #0000ff;">template</span><span style="color: #000080;">&lt;</span><span style="color: #0000ff;">class</span> E, <span style="color: #0000ff;">class</span> T, <span style="color: #0000ff;">class</span> Y<span style="color: #000080;">&gt;</span>
    std<span style="color: #008080;">::</span><span style="color: #007788;">basic_ostream</span><span style="color: #000080;">&lt;</span>E, T<span style="color: #000080;">&gt;</span> <span style="color: #000040;">&amp;</span> operator<span style="color: #000080;">&lt;&lt;</span> <span style="color: #008000;">&#40;</span>std<span style="color: #008080;">::</span><span style="color: #007788;">basic_ostream</span><span style="color: #000080;">&lt;</span>E, T<span style="color: #000080;">&gt;</span> <span style="color: #000040;">&amp;</span> os, shared_ptr<span style="color: #000080;">&lt;</span>Y<span style="color: #000080;">&gt;</span> <span style="color: #0000ff;">const</span> <span style="color: #000040;">&amp;</span> p<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
  <span style="color: #0000ff;">template</span><span style="color: #000080;">&lt;</span><span style="color: #0000ff;">class</span> D, <span style="color: #0000ff;">class</span> T<span style="color: #000080;">&gt;</span>
    D <span style="color: #000040;">*</span> get_deleter<span style="color: #008000;">&#40;</span>shared_ptr<span style="color: #000080;">&lt;</span>T<span style="color: #000080;">&gt;</span> <span style="color: #0000ff;">const</span> <span style="color: #000040;">&amp;</span> p<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>And I started looking at it while thinking of the way <a title="Weak pointer documentation" href="http://www.boost.org/doc/libs/1_48_0/libs/smart_ptr/weak_ptr.htm">weak_ptr</a> uses its <a title="lock method of weak_ptr" href="http://www.boost.org/doc/libs/1_48_0/libs/smart_ptr/weak_ptr.htm#lock">lock()</a> method to generate a shared_ptr instance, which can be bound to a conditional block by creating the instance in an if-block :</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;">shared_ptr<span style="color: #000080;">&lt;</span><span style="color: #0000ff;">int</span><span style="color: #000080;">&gt;</span> p<span style="color: #008000;">&#40;</span><span style="color: #0000dd;">new</span> <span style="color: #0000ff;">int</span><span style="color: #008000;">&#40;</span><span style="color: #0000dd;">5</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
weak_ptr<span style="color: #000080;">&lt;</span><span style="color: #0000ff;">int</span><span style="color: #000080;">&gt;</span> q<span style="color: #008000;">&#40;</span>p<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #666666;">// some time later</span>
&nbsp;
<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>shared_ptr<span style="color: #000080;">&lt;</span><span style="color: #0000ff;">int</span><span style="color: #000080;">&gt;</span> r <span style="color: #000080;">=</span> q.<span style="color: #007788;">lock</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #666666;">// use *r</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>So <strong>unspecified-bool-type</strong> is a <em>specialized bool cast</em> for condition evaluation, i.e. it isn&#8217;t a real cast, and it won&#8217;t be used for bool conversions.<br />
So far, I&#8217;ve also seen another version of it as</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">explicit</span> operator <span style="color: #0000ff;">bool</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #0000ff;">const</span></pre></div></div>

<p>which means it&#8217;s a bool conversion operator, but which cannot be used for implicit conversions.</p>
<p>See <a title="Safe bool idiom article" href="http://www.artima.com/cppsource/safebool.html">this article</a> on <a title="Best practices in enterprise software development" href="http://www.artima.com/" target="_blank">artima</a> about the safe bool idiom. There&#8217;s a lot to learn.</p>
]]></content:encoded>
			<wfw:commentRss>http://news.wox-xion.ch/2012/01/operator-unspecified-bool-type/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS Display</title>
		<link>http://news.wox-xion.ch/2011/12/css-display/</link>
		<comments>http://news.wox-xion.ch/2011/12/css-display/#comments</comments>
		<pubDate>Thu, 29 Dec 2011 16:01:23 +0000</pubDate>
		<dc:creator>Alexandre Kaspar</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[inline]]></category>

		<guid isPermaLink="false">http://news.wox-xion.ch/?p=1272</guid>
		<description><![CDATA[The inline-block CSS display value. <a href="http://news.wox-xion.ch/2011/12/css-display/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p></p><br /><p>I&#8217;m currently working on the new gallery website (mostly <em>JQuery</em>) and was in troubles with floating div&#8217;s. If you want an element of block type to be put into a grid (or any continuous flow layout), you need to either :</p>
<ul>
<li>use a <strong>non-static positioning</strong> such as <em>absolute</em> or <em>fixed</em> (note that relative doesn&#8217;t work here, because blocks get relative to each other, and you&#8217;re stuck);</li>
<li>use <strong>float</strong> to make blocks flow, and then space them correctly.</li>
</ul>
<p>Or well, these were the solutions I knew about.</p>
<p>The absolute/fixed positioning isn&#8217;t a good solution, because it clearly depends on how many elements you have, and if you don&#8217;t know that beforehand, then you&#8217;re screwed. Anyway, that didn&#8217;t work with me.</p>
<p>The float version is looking nice, as long as you don&#8217;t need it into a specific layer. That was my problem, because as soon as you set a <em>float block</em>, it won&#8217;t be in the normal block-size constraints, and thus if your parent container has a specific <strong>size constraint</strong>&#8230; well you&#8217;re screwed again, because the floats won&#8217;t obey it.</p>
<p>What then ? Maybe the float item on a list ?</p>
<p>You would think you can control the positioning of the outer list, but the float is a float, and <em>it doesn&#8217;t obey any size constraint</em>, so that you can encapsulate it as much as you want, it still doesn&#8217;t work.</p>
<p>And finally, I ran into this <a title="CSS Display properties" href="http://www.w3.org/TR/CSS2/visuren.html#propdef-display" target="_blank">page</a> about the possible display values in CSS. There were many more possible values than I thought of :</p>
<blockquote><p>inline | block | list-item | <strong>inline-block</strong> | table | inline-table | table-row-group | table-header-group | table-footer-group | table-row | table-column-group | table-column | table-cell | table-caption | none | inherit</p></blockquote>
<p>And there was my solution, the value <strong>inline-block</strong> which results in <em>blocks which are inlinable</em>. Thus you can apply a size to them as you would with blocks, but still use the inline properties to have a continuous flow of blocks on the page, while keeping correct size constraints.</p>
<p> <img src='http://news.wox-xion.ch/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://news.wox-xion.ch/2011/12/css-display/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lights of EPFL</title>
		<link>http://news.wox-xion.ch/2011/12/lights-of-epfl/</link>
		<comments>http://news.wox-xion.ch/2011/12/lights-of-epfl/#comments</comments>
		<pubDate>Sun, 18 Dec 2011 20:03:50 +0000</pubDate>
		<dc:creator>Alexandre Kaspar</dc:creator>
				<category><![CDATA[Photography]]></category>
		<category><![CDATA[Clouds]]></category>
		<category><![CDATA[epfl]]></category>
		<category><![CDATA[hugin]]></category>
		<category><![CDATA[light]]></category>
		<category><![CDATA[panorama]]></category>
		<category><![CDATA[photography]]></category>
		<category><![CDATA[storm]]></category>

		<guid isPermaLink="false">http://news.wox-xion.ch/?p=1264</guid>
		<description><![CDATA[<img width="260" height="390" src="http://news.wox-xion.ch/wp-content/uploads/2011/12/IMG_6586-266x400.jpg" class="attachment-medium wp-post-image" alt="The Odyssea building of EPFL" title="IMG_6586" /><p><img width="260" height="390" src="http://news.wox-xion.ch/wp-content/uploads/2011/12/IMG_6586-266x400.jpg" class="attachment-medium wp-post-image" alt="The Odyssea building of EPFL" title="IMG_6586" /></p>A new gallery has started about lights, but now in Switzerland, for EPFL. It features some pictures of our great Rolex Learning Center. I have no idea why they&#8217;ve put palm trees near the BM building, it&#8217;s snowing ! Why&#8230; <a href="http://news.wox-xion.ch/2011/12/lights-of-epfl/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<img width="260" height="390" src="http://news.wox-xion.ch/wp-content/uploads/2011/12/IMG_6586-266x400.jpg" class="attachment-medium wp-post-image" alt="The Odyssea building of EPFL" title="IMG_6586" /><p><img width="260" height="390" src="http://news.wox-xion.ch/wp-content/uploads/2011/12/IMG_6586-266x400.jpg" class="attachment-medium wp-post-image" alt="The Odyssea building of EPFL" title="IMG_6586" /></p><p></p><br /><p>A new <a title="EPFL Lights" href="http://gallery.wox-xion.ch/2011/epflights/?rows=5&amp;cols=2">gallery has started about lights</a>, but now in Switzerland, for EPFL. It features some pictures of our great <em>Rolex Learning Center</em>. <img src='http://news.wox-xion.ch/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
I have no idea why they&#8217;ve put <a title="What a tree for these snowy days" href="http://gallery.wox-xion.ch/2011/epflights/images/IMG_6605.JPG" rel="lightbox[1264]">palm trees</a> near the BM building, it&#8217;s snowing ! Why do they put them outside ? <img src='http://news.wox-xion.ch/wp-includes/images/smilies/icon_confused.gif' alt=':?' class='wp-smiley' /> </p>
<p>Also note that I&#8217;ve taken some panoramas I won&#8217;t directly link on the galleries, since they are somewhat heavy.</p>
<p>The first one is a <a title="Geneva Lake panorama" href="http://gallery.wox-xion.ch/2011/panoramas/IMG_6546-IMG_6566.tif" target="_blank">panorama of the Geneva Lake</a> from the EPFL/Unil sport center of Dorigny.</p>
<p>The second one is yet another <a title="Small panorama over Chauderon" href="http://gallery.wox-xion.ch/2011/panoramas/IMG_6517-IMG_6523.JPG" target="_blank" rel="lightbox[1264]">composed picture of Lausanne</a> from Chauderon over Vigie.</p>
]]></content:encoded>
			<wfw:commentRss>http://news.wox-xion.ch/2011/12/lights-of-epfl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

