~ubuntu-branches/ubuntu/maverick/pygame/maverick

« back to all changes in this revision

Viewing changes to docs/ref/camera.html

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2010-01-14 17:02:11 UTC
  • mfrom: (1.3.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100114170211-21eop2ja7mr9vdcr
Tags: 1.9.1release-0ubuntu1
* New upstream version (lp: #433304)
* debian/control:
  - build-depends on libportmidi-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
<html>
 
3
<title>camera - Pygame Documentation</title>
 
4
<body bgcolor=#aaeebb text=#000000 link=#331111 vlink=#331111>
 
5
 
 
6
 
 
7
<table cellpadding=0 cellspacing=0 border=0 style='border: 3px solid black;' width='100%'>
 
8
<tr>
 
9
<td bgcolor='#c2fc20' style='padding: 6px;' align=center valign=center><a href='http://www.pygame.org/'><img src='../pygame_tiny.gif' border=0 width=200 height=60></a><br><b>pygame documentation</b></td>
 
10
<td bgcolor='#6aee28' style='border-left: 3px solid black; padding: 6px;' align=center valign=center>
 
11
        ||&nbsp;
 
12
        <a href=http://www.pygame.org>Pygame Home</a> &nbsp;||&nbsp;
 
13
        <a href=../index.html>Help Contents</a> &nbsp;||
 
14
        <a href=index.html>Reference Index</a> &nbsp;||
 
15
        <br>&nbsp;<br>
 
16
        
 
17
<a href="camera.html">Camera</a>&nbsp;||&nbsp;
 
18
<a href="cdrom.html">Cdrom</a>&nbsp;||&nbsp;
 
19
<a href="color.html">Color</a>&nbsp;||&nbsp;
 
20
<a href="cursors.html">Cursors</a>&nbsp;||&nbsp;
 
21
<a href="display.html">Display</a>&nbsp;||&nbsp;
 
22
<a href="draw.html">Draw</a>&nbsp;||&nbsp;
 
23
<a href="event.html">Event</a>&nbsp;||&nbsp;
 
24
<a href="examples.html">Examples</a>&nbsp;||&nbsp;
 
25
<a href="font.html">Font</a>&nbsp;||&nbsp;
 
26
<a href="gfxdraw.html">Gfxdraw</a>&nbsp;||&nbsp;
 
27
<a href="image.html">Image</a>&nbsp;||&nbsp;
 
28
<a href="joystick.html">Joystick</a>&nbsp;||&nbsp;
 
29
<a href="key.html">Key</a>&nbsp;||&nbsp;
 
30
<a href="locals.html">Locals</a>&nbsp;||&nbsp;
 
31
<a href="mask.html">Mask</a>&nbsp;||&nbsp;
 
32
<a href="midi.html">Midi</a>&nbsp;||&nbsp;
 
33
<a href="mixer.html">Mixer</a>&nbsp;||&nbsp;
 
34
<a href="mouse.html">Mouse</a>&nbsp;||&nbsp;
 
35
<a href="movie.html">Movie</a>&nbsp;||&nbsp;
 
36
<a href="music.html">Music</a>&nbsp;||&nbsp;
 
37
<a href="overlay.html">Overlay</a>&nbsp;||&nbsp;
 
38
<a href="pixelarray.html">Pixelarray</a>&nbsp;||&nbsp;
 
39
<a href="pygame.html">Pygame</a>&nbsp;||&nbsp;
 
40
<a href="rect.html">Rect</a>&nbsp;||&nbsp;
 
41
<a href="scrap.html">Scrap</a>&nbsp;||&nbsp;
 
42
<a href="sndarray.html">Sndarray</a>&nbsp;||&nbsp;
 
43
<a href="sprite.html">Sprite</a>&nbsp;||&nbsp;
 
44
<a href="surface.html">Surface</a>&nbsp;||&nbsp;
 
45
<a href="surfarray.html">Surfarray</a>&nbsp;||&nbsp;
 
46
<a href="tests.html">Tests</a>&nbsp;||&nbsp;
 
47
<a href="time.html">Time</a>&nbsp;||&nbsp;
 
48
<a href="transform.html">Transform</a>
 
49
</td></tr></table>
 
50
<br>
 
51
 
 
52
 
 
53
<a name="pygame.camera">
 
54
<big><b>pygame.camera</big></b><br><ul>
 
55
  <i>pygame module for camera use</i><br>
 
56
<ul><small><table>
 
57
  <tr><td><a href="camera.html#pygame.camera.colorspace">pygame.camera.colorspace</a> - <font size=-1>Surface colorspace conversion</font></td><td>Surface colorspace conversion</td></tr>
 
58
  <tr><td><a href="camera.html#pygame.camera.list_cameras">pygame.camera.list_cameras</a> - <font size=-1>returns a list of available cameras</font></td><td>returns a list of available cameras</td></tr>
 
59
  <tr><td><a href="camera.html#pygame.camera.Camera">pygame.camera.Camera</a> - <font size=-1>load a camera</font></td><td>load a camera</td></tr>
 
60
</table></small></ul>
 
61
<p>Pygame currently supports only Linux and v4l2 cameras. </p>
 
62
<p><tt>EXPERIMENTAL!:</tt> This api may change or disappear in later pygame releases. If you use this, your code will very likely break with the next pygame release. </p>
 
63
<p>The Bayer to <tt>RGB</tt> function is based on: </p>
 
64
<pre> Sonix SN9C101 based webcam basic I/F routines
 
65
 Copyright (C) 2004 Takafumi Mizuno <taka-qce@ls-a.jp>
 
66
 Redistribution and use in source and binary forms, with or without
 
67
 modification, are permitted provided that the following conditions
 
68
 are met:
 
69
 1. Redistributions of source code must retain the above copyright
 
70
    notice, this list of conditions and the following disclaimer.
 
71
 2. Redistributions in binary form must reproduce the above copyright
 
72
    notice, this list of conditions and the following disclaimer in the
 
73
    documentation and/or other materials provided with the distribution.
 
74
 THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 
75
 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
76
 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
77
 ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 
78
 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 
79
 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 
80
 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 
81
 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 
82
 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 
83
 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 
84
 SUCH DAMAGE.
 
85
</pre><p>New in pygame <tt>1.9.0</tt>. </p>
 
86
<!--COMMENTS:pygame.camera--> &nbsp;<br> 
 
87
 
 
88
 
 
89
<a name="pygame.camera.colorspace">
 
90
<big><b>pygame.camera.colorspace</big></b><br><ul>
 
91
  <i>Surface colorspace conversion</i><br>
 
92
  <tt>pygame.camera.colorspace(Surface, format, DestSurface = None): return Surface</tt><br>
 
93
<p>Allows for conversion from <tt>"RGB"</tt> to a destination colorspace of <tt>"HSV"</tt> or <tt>"YUV"</tt>. The source and destination surfaces must be the same size and pixel depth. This is useful for computer vision on devices with limited processing power. Capture as small of an image as possible, <tt>transform.scale()</tt> it even smaller, and then convert the colorspace to <tt>YUV</tt> or <tt>HSV</tt> before doing any processing on it. </p>
 
94
<!--COMMENTS:pygame.camera.colorspace--> &nbsp;<br> 
 
95
<br></ul>
 
96
 
 
97
 
 
98
<a name="pygame.camera.list_cameras">
 
99
<big><b>pygame.camera.list_cameras</big></b><br><ul>
 
100
  <i>returns a list of available cameras</i><br>
 
101
  <tt>pygame.camera.list_cameras(): return [cameras]</tt><br>
 
102
<p>Checks the computer for available cameras and returns a list of strings of camera names, ready to be fed into <tt>pygame.camera.Camera</tt>. </p>
 
103
<!--COMMENTS:pygame.camera.list_cameras--> &nbsp;<br> 
 
104
<br></ul>
 
105
 
 
106
 
 
107
<a name="pygame.camera.Camera">
 
108
<big><b>pygame.camera.Camera</big></b><br><ul>
 
109
  <i>load a camera</i><br>
 
110
  <tt>pygame.camera.Camera(device, (width, height), format): return Camera</tt><br>
 
111
<ul><small><table>
 
112
  <tr><td><a href="camera.html#Camera.start">Camera.start</a> - <font size=-1>opens, initializes, and starts capturing</font></td><td>opens, initializes, and starts capturing</td></tr>
 
113
  <tr><td><a href="camera.html#Camera.stop">Camera.stop</a> - <font size=-1>stops, uninitializes, and closes the camera</font></td><td>stops, uninitializes, and closes the camera</td></tr>
 
114
  <tr><td><a href="camera.html#Camera.get_controls">Camera.get_controls</a> - <font size=-1>gets current values of user controls</font></td><td>gets current values of user controls</td></tr>
 
115
  <tr><td><a href="camera.html#Camera.set_controls">Camera.set_controls</a> - <font size=-1>changes camera settings if supported by the camera</font></td><td>changes camera settings if supported by the camera</td></tr>
 
116
  <tr><td><a href="camera.html#Camera.get_size">Camera.get_size</a> - <font size=-1>returns the dimensions of the images being recorded</font></td><td>returns the dimensions of the images being recorded</td></tr>
 
117
  <tr><td><a href="camera.html#Camera.query_image">Camera.query_image</a> - <font size=-1>checks if a frame is ready</font></td><td>checks if a frame is ready</td></tr>
 
118
  <tr><td><a href="camera.html#Camera.get_image">Camera.get_image</a> - <font size=-1>captures an image as a Surface</font></td><td>captures an image as a Surface</td></tr>
 
119
  <tr><td><a href="camera.html#Camera.get_raw">Camera.get_raw</a> - <font size=-1>returns an unmodified image as a string</font></td><td>returns an unmodified image as a string</td></tr>
 
120
</table></small></ul>
 
121
<p>Loads a v4l2 camera. The device is typically something like "/dev/video0". Default width and height are 640 by 480. Format is the desired colorspace of the output. This is useful for computer vision purposes. The default is <tt>RGB</tt>. The following are supported: </p>
 
122
<ul>
 
123
 <li> RGB - Red, Green, Blue </li>
 
124
 <li> YUV - Luma, Blue Chrominance, Red Chrominance </li>
 
125
 <li> HSV - Hue, Saturation, Value </li>
 
126
</ul>
 
127
<!--COMMENTS:pygame.camera.Camera--> &nbsp;<br> 
 
128
 
 
129
 
 
130
<a name="Camera.start">
 
131
<big><b>Camera.start</big></b><br><ul>
 
132
  <i>opens, initializes, and starts capturing</i><br>
 
133
  <tt>Camera.start(): return None</tt><br>
 
134
<p>Opens the camera device, attempts to initialize it, and begins recording images to a buffer. The camera must be started before any of the below functions can be used. </p>
 
135
<!--COMMENTS:Camera.start--> &nbsp;<br> 
 
136
<br></ul>
 
137
 
 
138
 
 
139
<a name="Camera.stop">
 
140
<big><b>Camera.stop</big></b><br><ul>
 
141
  <i>stops, uninitializes, and closes the camera</i><br>
 
142
  <tt>Camera.stop(): return None</tt><br>
 
143
<p>Stops recording, uninitializes the camera, and closes it. Once a camera is stopped, the below functions cannot be used until it is started again. </p>
 
144
<!--COMMENTS:Camera.stop--> &nbsp;<br> 
 
145
<br></ul>
 
146
 
 
147
 
 
148
<a name="Camera.get_controls">
 
149
<big><b>Camera.get_controls</big></b><br><ul>
 
150
  <i>gets current values of user controls</i><br>
 
151
  <tt>Camera.get_controls(): return (hflip = bool, vflip = bool, brightness)</tt><br>
 
152
<p>If the camera supports it, get_controls will return the current settings for horizontal and vertical image flip as bools and brightness as an int. If unsupported, it will return the default values of (0, 0, 0). Note that the return values here may be different than those returned by set_controls, though these are more likely to be correct. </p>
 
153
<!--COMMENTS:Camera.get_controls--> &nbsp;<br> 
 
154
<br></ul>
 
155
 
 
156
 
 
157
<a name="Camera.set_controls">
 
158
<big><b>Camera.set_controls</big></b><br><ul>
 
159
  <i>changes camera settings if supported by the camera</i><br>
 
160
  <tt>Camera.set_controls(hflip = bool, vflip = bool, brightness): return (hflip = bool, vflip = bool, brightness)</tt><br>
 
161
<p>Allows you to change camera settings if the camera supports it. The return values will be the input values if the camera claims it succeeded or the values previously in use if not. Each argument is optional, and the desired one can be chosen by supplying the keyword, like hflip. Note that the actual settings being used by the camera may not be the same as those returned by set_controls. </p>
 
162
<!--COMMENTS:Camera.set_controls--> &nbsp;<br> 
 
163
<br></ul>
 
164
 
 
165
 
 
166
<a name="Camera.get_size">
 
167
<big><b>Camera.get_size</big></b><br><ul>
 
168
  <i>returns the dimensions of the images being recorded</i><br>
 
169
  <tt>Camera.get_size(): return (width, height)</tt><br>
 
170
<p>Returns the current dimensions of the images being captured by the camera. This will return the actual size, which may be different than the one specified during initialization if the camera did not support that size. </p>
 
171
<!--COMMENTS:Camera.get_size--> &nbsp;<br> 
 
172
<br></ul>
 
173
 
 
174
 
 
175
<a name="Camera.query_image">
 
176
<big><b>Camera.query_image</big></b><br><ul>
 
177
  <i>checks if a frame is ready</i><br>
 
178
  <tt>Camera.query_image(): return bool</tt><br>
 
179
<p>If an image is ready to get, it returns true. Otherwise it returns false. Note that some webcams will always return False and will only queue a frame when called with a blocking function like get_image(). This is useful to separate the framerate of the game from that of the camera without having to use threading. </p>
 
180
<!--COMMENTS:Camera.query_image--> &nbsp;<br> 
 
181
<br></ul>
 
182
 
 
183
 
 
184
<a name="Camera.get_image">
 
185
<big><b>Camera.get_image</big></b><br><ul>
 
186
  <i>captures an image as a Surface</i><br>
 
187
  <tt>Camera.get_image(Surface = None): return Surface</tt><br>
 
188
<p>Pulls an image off of the buffer as an <tt>RGB</tt> Surface. It can optionally reuse an existing Surface to save time. The bit depth of the surface is either 24bits or the same as the optionally supplied Surface. </p>
 
189
<!--COMMENTS:Camera.get_image--> &nbsp;<br> 
 
190
<br></ul>
 
191
 
 
192
 
 
193
<a name="Camera.get_raw">
 
194
<big><b>Camera.get_raw</big></b><br><ul>
 
195
  <i>returns an unmodified image as a string</i><br>
 
196
  <tt>Camera.get_raw(): return string</tt><br>
 
197
<p>Gets an image from a camera as a string in the native pixelformat of the camera. Useful for integration with other libraries. </p>
 
198
<!--COMMENTS:Camera.get_raw--> &nbsp;<br> 
 
199
<br></ul>
 
200
<br></ul>
 
201
<br></ul>
 
202
 
 
203
</body></html>