~ubuntu-branches/debian/experimental/pygame/experimental

« back to all changes in this revision

Viewing changes to docs/ref/camera.html

  • Committer: Package Import Robot
  • Author(s): Vincent Cheng
  • Date: 2013-02-21 00:23:03 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20130221002303-08xmo02oym2hxjee
Tags: 1.9.2~pre~r3189-1
* New upstream hg snapshot (rev 3189).
* Avoid potentially overriding a symlink in python3.2-dev. (Closes: #700997)
* Generate correct versioned dependency on python-numpy following ABI change
  using the dh_numpy and dh_numpy3 helpers. (Closes: #698169)
  - Add build-depends on python3-numpy.
* Fix a number of failing tests that rely on pygame being tested with OpenGL
  and a graphical display available, as well as audio/video devices.
* Remove deprecated DMUA flag in debian/control.
* Fix lintian tag vcs-field-not-canonical.
* Update Standards version from 3.9.3 to 3.9.4, no updates required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
 
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
 
 
4
 
<html xmlns="http://www.w3.org/1999/xhtml">
5
 
  <head>
6
 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
7
 
    
8
 
    <title>pygame.camera &mdash; Pygame v1.9.2 documentation</title>
9
 
    <link rel="stylesheet" href="../_static/pygame.css" type="text/css" />
10
 
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
11
 
    <script type="text/javascript">
12
 
      var DOCUMENTATION_OPTIONS = {
13
 
        URL_ROOT:    '../',
14
 
        VERSION:     '1.9.2',
15
 
        COLLAPSE_INDEX: false,
16
 
        FILE_SUFFIX: '.html',
17
 
        HAS_SOURCE:  true
18
 
      };
19
 
    </script>
20
 
    <script type="text/javascript" src="../_static/jquery.js"></script>
21
 
    <script type="text/javascript" src="../_static/underscore.js"></script>
22
 
    <script type="text/javascript" src="../_static/doctools.js"></script>
23
 
    <link rel="shortcut icon" href="../_static/pygame.ico"/>
24
 
    <link rel="top" title="Pygame v1.9.2 documentation" href="../index.html" />
25
 
    <link rel="next" title="pygame.cdrom" href="cdrom.html" />
26
 
    <link rel="prev" title="Pygame Front Page" href="../index.html" /> 
27
 
  </head>
28
 
  <body>  
29
 
 
30
 
    <div class="document">
31
 
 
32
 
  <div class="header">
33
 
    <table>
34
 
      <tr>
35
 
        <td class="logo">
36
 
          <a href="http://www.pygame.org/">
37
 
            <img src="../_static/pygame_tiny.png"/>
38
 
          </a>
39
 
          <h5>pygame documentation</h5>
40
 
        </td>
41
 
        <td class="pagelinks">
42
 
          <p class="top">
43
 
            ||
44
 
            <a href="http://www.pygame.org/">Pygame Home</a> ||
45
 
            <a href="../index.html">Help Contents</a> ||
46
 
            <a href="../genindex.html">Reference Index</a> ||
47
 
          </p>
48
 
          <p class="bottom">
49
 
            <a href="camera.html">camera</a> || 
50
 
            <a href="cdrom.html">cdrom</a> || 
51
 
            <a href="color.html">Color</a> || 
52
 
            <a href="cursors.html">cursors</a> || 
53
 
            <a href="display.html">display</a> || 
54
 
            <a href="draw.html">draw</a> || 
55
 
            <a href="event.html">event</a> || 
56
 
            <a href="examples.html">examples</a> || 
57
 
            <a href="font.html">font</a> || 
58
 
            <a href="freetype.html">freetype</a> || 
59
 
            <a href="gfxdraw.html">gfxdraw</a> || 
60
 
            <a href="image.html">image</a> || 
61
 
            <a href="joystick.html">joystick</a> || 
62
 
            <a href="key.html">key</a> || 
63
 
            <a href="locals.html">locals</a> || 
64
 
            <a href="mask.html">mask</a> || 
65
 
            <a href="math.html">math</a> || 
66
 
            <a href="midi.html">midi</a> || 
67
 
            <a href="mixer.html">mixer</a> || 
68
 
            <a href="mouse.html">mouse</a> || 
69
 
            <a href="movie.html">movie</a> || 
70
 
            <a href="music.html">music</a> || 
71
 
            <a href="overlay.html">Overlay</a> || 
72
 
            <a href="pixelarray.html">PixelArray</a> || 
73
 
            <a href="pixelcopy.html">pixelcopy</a> || 
74
 
            <a href="pygame.html">pygame</a> || 
75
 
            <a href="rect.html">Rect</a> || 
76
 
            <a href="scrap.html">scrap</a> || 
77
 
            <a href="sndarray.html">sndarray</a> || 
78
 
            <a href="sprite.html">sprite</a> || 
79
 
            <a href="surface.html">Surface</a> || 
80
 
            <a href="surfarray.html">surfarray</a> || 
81
 
            <a href="tests.html">tests</a> || 
82
 
            <a href="time.html">time</a> || 
83
 
            <a href="transform.html">transform</a> || 
84
 
            <a href="pygame.html#module-pygame.version">version</a>
85
 
          </p>
86
 
        </td>
87
 
      </tr>
88
 
    </table>
89
 
  </div>
90
 
 
91
 
      <div class="documentwrapper">
92
 
          <div class="body">
93
 
            
94
 
  <div class="sectionwrapper">
95
 
<div class="section" id="module-pygame.camera">
96
 
<span id="pygame-camera"></span><dl class="definition module">
97
 
<dt class="title module">
98
 
<tt class="docutils literal"><span class="pre">pygame.camera</span></tt></dt>
99
 
<dd><div class="line-block">
100
 
<div class="line"><span class="summaryline">pygame module for camera use</span></div>
101
 
</div>
102
 
<table border="1" class="toc docutils">
103
 
<colgroup>
104
 
<col width="38%" />
105
 
<col width="1%" />
106
 
<col width="61%" />
107
 
</colgroup>
108
 
<tbody valign="top">
109
 
<tr><td><a class="toc reference external" href="camera.html#pygame.camera.colorspace">pygame.camera.colorspace</a></td>
110
 
<td>—</td>
111
 
<td>Surface colorspace conversion</td>
112
 
</tr>
113
 
<tr><td><a class="toc reference external" href="camera.html#pygame.camera.list_cameras">pygame.camera.list_cameras</a></td>
114
 
<td>—</td>
115
 
<td>returns a list of available cameras</td>
116
 
</tr>
117
 
<tr><td><a class="toc reference external" href="camera.html#pygame.camera.Camera">pygame.camera.Camera</a></td>
118
 
<td>—</td>
119
 
<td>load a camera</td>
120
 
</tr>
121
 
</tbody>
122
 
</table>
123
 
<p>Pygame currently supports only Linux and v4l2 cameras.</p>
124
 
<p>EXPERIMENTAL!: This api may change or disappear in later pygame releases. If
125
 
you use this, your code will very likely break with the next pygame release.</p>
126
 
<p>The Bayer to <tt class="docutils literal"><span class="pre">RGB</span></tt> function is based on:</p>
127
 
<div class="highlight-python"><pre>Sonix SN9C101 based webcam basic I/F routines
128
 
Copyright (C) 2004 Takafumi Mizuno &lt;taka-qce@ls-a.jp&gt;
129
 
Redistribution and use in source and binary forms, with or without
130
 
modification, are permitted provided that the following conditions
131
 
are met:
132
 
1. Redistributions of source code must retain the above copyright
133
 
   notice, this list of conditions and the following disclaimer.
134
 
2. Redistributions in binary form must reproduce the above copyright
135
 
   notice, this list of conditions and the following disclaimer in the
136
 
   documentation and/or other materials provided with the distribution.
137
 
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
138
 
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
139
 
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
140
 
ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
141
 
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
142
 
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
143
 
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
144
 
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
145
 
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
146
 
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
147
 
SUCH DAMAGE.</pre>
148
 
</div>
149
 
<p>New in pygame 1.9.0.</p>
150
 
<dl class="definition function">
151
 
<dt class="title" id="pygame.camera.colorspace">
152
 
<tt class="descclassname">pygame.camera.</tt><tt class="descname">colorspace</tt><big>(</big><big>)</big><a class="headerlink" href="#pygame.camera.colorspace" title="Permalink to this definition">¶</a></dt>
153
 
<dd><div class="line-block">
154
 
<div class="line"><span class="summaryline">Surface colorspace conversion</span></div>
155
 
<div class="line"><span class="signature">colorspace(Surface, format, DestSurface = None) -&gt; Surface</span></div>
156
 
</div>
157
 
<p>Allows for conversion from &#8220;RGB&#8221; to a destination colorspace of &#8220;HSV&#8221; or
158
 
&#8220;YUV&#8221;. The source and destination surfaces must be the same size and pixel
159
 
depth. This is useful for computer vision on devices with limited processing
160
 
power. Capture as small of an image as possible, <tt class="docutils literal"><span class="pre">transform.scale()</span></tt> it
161
 
even smaller, and then convert the colorspace to <tt class="docutils literal"><span class="pre">YUV</span></tt> or <tt class="docutils literal"><span class="pre">HSV</span></tt> before
162
 
doing any processing on it.</p>
163
 
</dd></dl>
164
 
 
165
 
<dl class="definition function">
166
 
<dt class="title" id="pygame.camera.list_cameras">
167
 
<tt class="descclassname">pygame.camera.</tt><tt class="descname">list_cameras</tt><big>(</big><big>)</big><a class="headerlink" href="#pygame.camera.list_cameras" title="Permalink to this definition">¶</a></dt>
168
 
<dd><div class="line-block">
169
 
<div class="line"><span class="summaryline">returns a list of available cameras</span></div>
170
 
<div class="line"><span class="signature">list_cameras() -&gt; [cameras]</span></div>
171
 
</div>
172
 
<p>Checks the computer for available cameras and returns a list of strings of
173
 
camera names, ready to be fed into <a class="tooltip reference internal" href="#pygame.camera.Camera" title=""><tt class="xref py py-class docutils literal"><span class="pre">pygame.camera.Camera</span></tt><span class="tooltip-content">load a camera</span></a>.</p>
174
 
</dd></dl>
175
 
 
176
 
<dl class="definition class">
177
 
<dt class="title" id="pygame.camera.Camera">
178
 
<em class="property">class </em><tt class="descclassname">pygame.camera.</tt><tt class="descname">Camera</tt><a class="headerlink" href="#pygame.camera.Camera" title="Permalink to this definition">¶</a></dt>
179
 
<dd><div class="line-block">
180
 
<div class="line"><span class="summaryline">load a camera</span></div>
181
 
<div class="line"><span class="signature">Camera(device, (width, height), format) -&gt; Camera</span></div>
182
 
</div>
183
 
<table border="1" class="toc docutils">
184
 
<colgroup>
185
 
<col width="36%" />
186
 
<col width="1%" />
187
 
<col width="63%" />
188
 
</colgroup>
189
 
<tbody valign="top">
190
 
<tr><td><a class="toc reference external" href="camera.html#pygame.camera.Camera.start">pygame.camera.Camera.start</a></td>
191
 
<td>—</td>
192
 
<td>opens, initializes, and starts capturing</td>
193
 
</tr>
194
 
<tr><td><a class="toc reference external" href="camera.html#pygame.camera.Camera.stop">pygame.camera.Camera.stop</a></td>
195
 
<td>—</td>
196
 
<td>stops, uninitializes, and closes the camera</td>
197
 
</tr>
198
 
<tr><td><a class="toc reference external" href="camera.html#pygame.camera.Camera.get_controls">pygame.camera.Camera.get_controls</a></td>
199
 
<td>—</td>
200
 
<td>gets current values of user controls</td>
201
 
</tr>
202
 
<tr><td><a class="toc reference external" href="camera.html#pygame.camera.Camera.set_controls">pygame.camera.Camera.set_controls</a></td>
203
 
<td>—</td>
204
 
<td>changes camera settings if supported by the camera</td>
205
 
</tr>
206
 
<tr><td><a class="toc reference external" href="camera.html#pygame.camera.Camera.get_size">pygame.camera.Camera.get_size</a></td>
207
 
<td>—</td>
208
 
<td>returns the dimensions of the images being recorded</td>
209
 
</tr>
210
 
<tr><td><a class="toc reference external" href="camera.html#pygame.camera.Camera.query_image">pygame.camera.Camera.query_image</a></td>
211
 
<td>—</td>
212
 
<td>checks if a frame is ready</td>
213
 
</tr>
214
 
<tr><td><a class="toc reference external" href="camera.html#pygame.camera.Camera.get_image">pygame.camera.Camera.get_image</a></td>
215
 
<td>—</td>
216
 
<td>captures an image as a Surface</td>
217
 
</tr>
218
 
<tr><td><a class="toc reference external" href="camera.html#pygame.camera.Camera.get_raw">pygame.camera.Camera.get_raw</a></td>
219
 
<td>—</td>
220
 
<td>returns an unmodified image as a string</td>
221
 
</tr>
222
 
</tbody>
223
 
</table>
224
 
<p>Loads a v4l2 camera. The device is typically something like &#8220;/dev/video0&#8221;.
225
 
Default width and height are 640 by 480. Format is the desired colorspace of
226
 
the output. This is useful for computer vision purposes. The default is
227
 
<tt class="docutils literal"><span class="pre">RGB</span></tt>. The following are supported:</p>
228
 
<blockquote>
229
 
<ul class="simple">
230
 
<li><tt class="docutils literal"><span class="pre">RGB</span></tt> - Red, Green, Blue</li>
231
 
<li><tt class="docutils literal"><span class="pre">YUV</span></tt> - Luma, Blue Chrominance, Red Chrominance</li>
232
 
<li><tt class="docutils literal"><span class="pre">HSV</span></tt> - Hue, Saturation, Value</li>
233
 
</ul>
234
 
</blockquote>
235
 
<dl class="definition method">
236
 
<dt class="title" id="pygame.camera.Camera.start">
237
 
<tt class="descname">start</tt><big>(</big><big>)</big><a class="headerlink" href="#pygame.camera.Camera.start" title="Permalink to this definition">¶</a></dt>
238
 
<dd><div class="line-block">
239
 
<div class="line"><span class="summaryline">opens, initializes, and starts capturing</span></div>
240
 
<div class="line"><span class="signature">start() -&gt; None</span></div>
241
 
</div>
242
 
<p>Opens the camera device, attempts to initialize it, and begins recording
243
 
images to a buffer. The camera must be started before any of the below
244
 
functions can be used.</p>
245
 
</dd></dl>
246
 
 
247
 
<dl class="definition method">
248
 
<dt class="title" id="pygame.camera.Camera.stop">
249
 
<tt class="descname">stop</tt><big>(</big><big>)</big><a class="headerlink" href="#pygame.camera.Camera.stop" title="Permalink to this definition">¶</a></dt>
250
 
<dd><div class="line-block">
251
 
<div class="line"><span class="summaryline">stops, uninitializes, and closes the camera</span></div>
252
 
<div class="line"><span class="signature">stop() -&gt; None</span></div>
253
 
</div>
254
 
<p>Stops recording, uninitializes the camera, and closes it. Once a camera
255
 
is stopped, the below functions cannot be used until it is started again.</p>
256
 
</dd></dl>
257
 
 
258
 
<dl class="definition method">
259
 
<dt class="title" id="pygame.camera.Camera.get_controls">
260
 
<tt class="descname">get_controls</tt><big>(</big><big>)</big><a class="headerlink" href="#pygame.camera.Camera.get_controls" title="Permalink to this definition">¶</a></dt>
261
 
<dd><div class="line-block">
262
 
<div class="line"><span class="summaryline">gets current values of user controls</span></div>
263
 
<div class="line"><span class="signature">get_controls() -&gt; (hflip = bool, vflip = bool, brightness)</span></div>
264
 
</div>
265
 
<p>If the camera supports it, get_controls will return the current settings
266
 
for horizontal and vertical image flip as bools and brightness as an int.
267
 
If unsupported, it will return the default values of (0, 0, 0). Note that
268
 
the return values here may be different than those returned by
269
 
set_controls, though these are more likely to be correct.</p>
270
 
</dd></dl>
271
 
 
272
 
<dl class="definition method">
273
 
<dt class="title" id="pygame.camera.Camera.set_controls">
274
 
<tt class="descname">set_controls</tt><big>(</big><big>)</big><a class="headerlink" href="#pygame.camera.Camera.set_controls" title="Permalink to this definition">¶</a></dt>
275
 
<dd><div class="line-block">
276
 
<div class="line"><span class="summaryline">changes camera settings if supported by the camera</span></div>
277
 
<div class="line"><span class="signature">set_controls(hflip = bool, vflip = bool, brightness) -&gt; (hflip = bool, vflip = bool, brightness)</span></div>
278
 
</div>
279
 
<p>Allows you to change camera settings if the camera supports it. The
280
 
return values will be the input values if the camera claims it succeeded
281
 
or the values previously in use if not. Each argument is optional, and
282
 
the desired one can be chosen by supplying the keyword, like hflip. Note
283
 
that the actual settings being used by the camera may not be the same as
284
 
those returned by set_controls.</p>
285
 
</dd></dl>
286
 
 
287
 
<dl class="definition method">
288
 
<dt class="title" id="pygame.camera.Camera.get_size">
289
 
<tt class="descname">get_size</tt><big>(</big><big>)</big><a class="headerlink" href="#pygame.camera.Camera.get_size" title="Permalink to this definition">¶</a></dt>
290
 
<dd><div class="line-block">
291
 
<div class="line"><span class="summaryline">returns the dimensions of the images being recorded</span></div>
292
 
<div class="line"><span class="signature">get_size() -&gt; (width, height)</span></div>
293
 
</div>
294
 
<p>Returns the current dimensions of the images being captured by the
295
 
camera. This will return the actual size, which may be different than the
296
 
one specified during initialization if the camera did not support that
297
 
size.</p>
298
 
</dd></dl>
299
 
 
300
 
<dl class="definition method">
301
 
<dt class="title" id="pygame.camera.Camera.query_image">
302
 
<tt class="descname">query_image</tt><big>(</big><big>)</big><a class="headerlink" href="#pygame.camera.Camera.query_image" title="Permalink to this definition">¶</a></dt>
303
 
<dd><div class="line-block">
304
 
<div class="line"><span class="summaryline">checks if a frame is ready</span></div>
305
 
<div class="line"><span class="signature">query_image() -&gt; bool</span></div>
306
 
</div>
307
 
<p>If an image is ready to get, it returns true. Otherwise it returns false.
308
 
Note that some webcams will always return False and will only queue a
309
 
frame when called with a blocking function like <tt class="docutils literal"><span class="pre">get_image()</span></tt>. This is
310
 
useful to separate the framerate of the game from that of the camera
311
 
without having to use threading.</p>
312
 
</dd></dl>
313
 
 
314
 
<dl class="definition method">
315
 
<dt class="title" id="pygame.camera.Camera.get_image">
316
 
<tt class="descname">get_image</tt><big>(</big><big>)</big><a class="headerlink" href="#pygame.camera.Camera.get_image" title="Permalink to this definition">¶</a></dt>
317
 
<dd><div class="line-block">
318
 
<div class="line"><span class="summaryline">captures an image as a Surface</span></div>
319
 
<div class="line"><span class="signature">get_image(Surface = None) -&gt; Surface</span></div>
320
 
</div>
321
 
<p>Pulls an image off of the buffer as an <tt class="docutils literal"><span class="pre">RGB</span></tt> Surface. It can optionally
322
 
reuse an existing Surface to save time. The bit depth of the surface is
323
 
either 24bits or the same as the optionally supplied Surface.</p>
324
 
</dd></dl>
325
 
 
326
 
<dl class="definition method">
327
 
<dt class="title" id="pygame.camera.Camera.get_raw">
328
 
<tt class="descname">get_raw</tt><big>(</big><big>)</big><a class="headerlink" href="#pygame.camera.Camera.get_raw" title="Permalink to this definition">¶</a></dt>
329
 
<dd><div class="line-block">
330
 
<div class="line"><span class="summaryline">returns an unmodified image as a string</span></div>
331
 
<div class="line"><span class="signature">get_raw() -&gt; string</span></div>
332
 
</div>
333
 
<p>Gets an image from a camera as a string in the native pixelformat of the
334
 
camera. Useful for integration with other libraries.</p>
335
 
</dd></dl>
336
 
 
337
 
</dd></dl>
338
 
 
339
 
</dd></dl>
340
 
 
341
 
</div>
342
 
 
343
 
  </div>
344
 
          </div>
345
 
      </div>
346
 
      <div class="clearer"></div>
347
 
    </div>
348
 
    <div class="related">
349
 
      <h3>Navigation</h3>
350
 
      <ul>
351
 
        <li class="right" style="margin-right: 10px">
352
 
          <a href="../genindex.html" title="General Index"
353
 
             accesskey="I">index</a></li>
354
 
        <li class="right" >
355
 
          <a href="cdrom.html" title="pygame.cdrom"
356
 
             accesskey="N">next</a> |</li>
357
 
        <li class="right" >
358
 
          <a href="../index.html" title="Pygame Front Page"
359
 
             accesskey="P">previous</a> |</li>
360
 
        <li><a href="../index.html">Pygame v1.9.2 documentation</a> &raquo;</li>
361
 
    <script type="text/javascript" src="jquery.plugin.docscomments.js"></script>
362
 
 
363
 
      </ul>
364
 
    </div>
365
 
    <div class="footer">
366
 
        &copy; Copyright 2011, Pygame Developers.
367
 
    </div>
368
 
  </body>
369
 
</html>
 
 
b'\\ No newline at end of file'