I gave up GNOME Cheese because it is too complicated. I found Motion good because it is easy, and also it is command line mode only, so I can use Python to call the commands.
But then I think Pygame.camera might be as easy. So I googled the reference and made a summary below.
pygame.camera - pygame module for camera use
http://www.pygame.org/docs/ref/camera.html
...
Pygame currently supports only Linux and v4l2 cameras.
...
pygame.camera.colorspace()
Surface colorspace conversion
colorspace(Surface, format, DestSurface = None) -> Surface
Allows for conversion from “RGB” to a destination colorspace of “HSV” or “YUV”. 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, transform.scale() it even smaller, and then convert the colorspace to YUV or HSV before doing any processing on it.
pygame.camera.list_cameras()
returns a list of available cameras
list_cameras() -> [cameras]
Checks the computer for available cameras and returns a list of strings of camera names, ready to be fed into pygame.camera.Cameraload a camera.
class pygame.camera.Camera
load a camera
Camera(device, (width, height), format) -> Camera
pygame.camera.Camera.start — opens, initializes, and starts capturing
pygame.camera.Camera.stop — stops, uninitializes, and closes the camera
pygame.camera.Camera.get_controls — gets current values of user controls
pygame.camera.Camera.set_controls — changes camera settings if supported by the camera
pygame.camera.Camera.get_size — returns the dimensions of the images being recorded
pygame.camera.Camera.query_image — checks if a frame is ready
pygame.camera.Camera.get_image — captures an image as a Surface
pygame.camera.Camera.get_raw — returns an unmodified image as a string
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 RGB. The following are supported:
start()
opens, initializes, and starts capturing
start() -> None
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.
stop()
stops, uninitializes, and closes the camera
stop() -> None
Stops recording, uninitializes the camera, and closes it. Once a camera is stopped, the below functions cannot be used until it is started again.
get_controls()
gets current values of user controls
get_controls() -> (hflip = bool, vflip = bool, brightness)
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.
set_controls()
changes camera settings if supported by the camera
set_controls(hflip = bool, vflip = bool, brightness) -> (hflip = bool, vflip = bool, brightness)
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.
get_size()
returns the dimensions of the images being recorded
get_size() -> (width, height)
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.
query_image()
checks if a frame is ready
query_image() -> bool
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.
get_image()
captures an image as a Surface
get_image(Surface = None) -> Surface
Pulls an image off of the buffer as an RGB 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.
get_raw()
returns an unmodified image as a string
get_raw() -> string
Gets an image from a camera as a string in the native pixelformat of the camera. Useful for integration with other libraries.
...
.END
No comments:
Post a Comment