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

« back to all changes in this revision

Viewing changes to src/camera.doc

  • 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
pygame.camera
 
2
pygame module for camera use
 
3
 
 
4
Pygame currently supports only Linux and v4l2 cameras.
 
5
 
 
6
EXPERIMENTAL!: This api may change or disappear in later 
 
7
pygame releases.  If you use this, your code will very likely
 
8
break with the next pygame release.
 
9
 
 
10
 
 
11
 
 
12
The Bayer to RGB function is based on:
 
13
 Sonix SN9C101 based webcam basic I/F routines
 
14
 Copyright (C) 2004 Takafumi Mizuno <taka-qce@ls-a.jp>
 
15
 
 
16
 Redistribution and use in source and binary forms, with or without
 
17
 modification, are permitted provided that the following conditions
 
18
 are met:
 
19
 1. Redistributions of source code must retain the above copyright
 
20
    notice, this list of conditions and the following disclaimer.
 
21
 2. Redistributions in binary form must reproduce the above copyright
 
22
    notice, this list of conditions and the following disclaimer in the
 
23
    documentation and/or other materials provided with the distribution.
 
24
 
 
25
 THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 
26
 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
27
 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
28
 ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 
29
 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 
30
 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 
31
 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 
32
 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 
33
 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 
34
 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 
35
 SUCH DAMAGE.
 
36
 
 
37
 
 
38
New in pygame 1.9.0.
 
39
<SECTION>
 
40
 
 
41
colorspace
 
42
Surface colorspace conversion
 
43
pygame.camera.colorspace(Surface, format, DestSurface = None): return Surface
 
44
 
 
45
Allows for conversion from "RGB" to a destination colorspace of "HSV" or "YUV".
 
46
The source and destination surfaces must be the same size and pixel depth.
 
47
This is useful for computer vision on devices with limited processing power.
 
48
Capture as small of an image as possible, transform.scale() it even smaller,
 
49
and then convert the colorspace to YUV or HSV before doing any processing on it.
 
50
<END>
 
51
 
 
52
list_cameras
 
53
returns a list of available cameras
 
54
pygame.camera.list_cameras(): return [cameras]
 
55
 
 
56
Checks the computer for available cameras and returns a list of strings of
 
57
camera names, ready to be fed into pygame.camera.Camera.
 
58
<END>
 
59
 
 
60
Camera
 
61
load a camera
 
62
pygame.camera.Camera(device, (width, height), format): return Camera
 
63
 
 
64
Loads a v4l2 camera.  The device is typically something like "/dev/video0".
 
65
Default width and height are 640 by 480.  Format is the desired colorspace of
 
66
the output.  This is useful for computer vision purposes.  The default
 
67
is RGB.  The following are supported:
 
68
 
 
69
* RGB - Red, Green, Blue
 
70
* YUV - Luma, Blue Chrominance, Red Chrominance
 
71
* HSV - Hue, Saturation, Value
 
72
<SECTION>
 
73
 
 
74
 
 
75
start
 
76
opens, initializes, and starts capturing
 
77
Camera.start(): return None
 
78
 
 
79
Opens the camera device, attempts to initialize it, and begins recording
 
80
images to a buffer.  The camera must be started before any of the below
 
81
functions can be used.
 
82
<END>
 
83
 
 
84
 
 
85
stop
 
86
stops, uninitializes, and closes the camera
 
87
Camera.stop(): return None
 
88
 
 
89
Stops recording, uninitializes the camera, and closes it.  Once a camera
 
90
is stopped, the below functions cannot be used until it is started again.
 
91
<END>
 
92
 
 
93
 
 
94
get_controls
 
95
gets current values of user controls
 
96
Camera.get_controls(): return (hflip = bool, vflip = bool, brightness)
 
97
 
 
98
If the camera supports it, get_controls will return the current settings for
 
99
horizontal and vertical image flip as bools and brightness as an int.  If
 
100
unsupported, it will return the default values of (0, 0, 0).
 
101
Note that the return values here may be different than those returned by
 
102
set_controls, though these are more likely to be correct.
 
103
<END>
 
104
 
 
105
set_controls
 
106
changes camera settings if supported by the camera
 
107
Camera.set_controls(hflip = bool, vflip = bool, brightness): return (hflip = bool, vflip = bool, brightness)
 
108
 
 
109
Allows you to change camera settings if the camera supports it.  The return
 
110
values will be the input values if the camera claims it succeeded or the values
 
111
previously in use if not.  Each argument is optional, and the desired one
 
112
can be chosen by supplying the keyword, like hflip.  Note that the actual
 
113
settings being used by the camera may not be the same as those returned by
 
114
set_controls.
 
115
<END>
 
116
 
 
117
 
 
118
get_size
 
119
returns the dimensions of the images being recorded
 
120
Camera.get_size(): return (width, height)
 
121
 
 
122
Returns the current dimensions of the images being captured by the camera.
 
123
This will return the actual size, which may be different than the one
 
124
specified during initialization if the camera did not support that size.
 
125
<END>
 
126
 
 
127
query_image
 
128
checks if a frame is ready
 
129
Camera.query_image(): return bool
 
130
 
 
131
If an image is ready to get, it returns true.  Otherwise it returns false.  Note
 
132
that some webcams will always return False and will only queue a frame when
 
133
called with a blocking function like get_image().  This is useful to
 
134
separate the framerate of the game from that of the camera without having to
 
135
use threading.
 
136
<END>
 
137
 
 
138
 
 
139
get_image
 
140
captures an image as a Surface
 
141
Camera.get_image(Surface = None): return Surface
 
142
 
 
143
Pulls an image off of the buffer as an RGB Surface.  It can optionally reuse an 
 
144
existing Surface to save time.  The bit depth of the surface is either 24bits or
 
145
the same as the optionally supplied Surface.
 
146
<END>
 
147
 
 
148
 
 
149
get_raw
 
150
returns an unmodified image as a string
 
151
Camera.get_raw(): return string
 
152
 
 
153
Gets an image from a camera as a string in the native pixelformat of the camera.
 
154
Useful for integration with other libraries.
 
155
<END>
 
156
<END>