Previous topic

Effect Nodes

This Page

Misc. Classes

class libavg.avg.Bitmap

Bases: Boost.Python.instance

Class representing a rectangular set of pixels. Bitmaps can be obtained from any RasterNode. For nodes of type Image, the current bitmap can be set as well.

The layout of the pixels in the bitmap is determined by it’s pixel format. Possible return values are B5G6R5, B8G8R8, B8G8R8A8, B8G8R8X8, A8B8G8R8, X8B8G8R8, R5G6B5, R8G8B8, R8G8B8A8, R8G8B8X8, A8R8G8B8, X8R8G8B8, I8 and YCbCr422.

__init__(size, pixelFormat, name)

Creates an uninitialized bitmap of the given size and pixel format. name is a name to be used in debug output.

__init__(bitmap)

Creates a copy of an already existing bitmap.

__init__(fileName)

Loads an image file from disk and returns it as bitmap object.

getAvg() → float

Returns the average of all bitmap pixels.

getFormat()

Returns the bitmap’s pixel format.

getName() → string
getPixel(pos) -> (r, g, b, a)

Returns one image pixel als a color tuple. This should only be used for single pixels, as it is very slow.

getPixels() → string

Returns the raw pixel data in the bitmap as a python string. This method can be used to interface to the python imaging library PIL (http://www.pythonware.com/products/pil/).

getSize() → Point2D

Returns the size of the image in pixels.

getStdDev() → float

Returns the standard deviation of all bitmap pixels.

save(filename)

Writes the image to a file. File format is determined using the extension. Any file format supported by ImageMagick (http://www.imagemagick.org) can be used.

setPixels(pixels)

Changes the raw pixel data in the bitmap. Doesn’t change dimensions or pixel format. Can be used to interface to the python imaging library PIL (http://www.pythonware.com/products/pil/).

Parameters:
  • pixels (string) – Image data.
subtract(otherbitmap) → bmp

Subtracts two bitmaps and returns the result. Used mainly to compare test images with the intended results (along with getAvg() and getStdDev()).

class libavg.avg.ConradRelais

Bases: Boost.Python.instance

Interface to one or more conrad relais cards connected to a serial port. Per card, up to eight 220V devices can be connected.

Deprecated since version 1.5.

__init__(AVGPlayer, port)

Opens a connection to the relais card(s) connected to a serial port.

Parameters:
  • port – The port the device is connected to. The actual device file opened is /dev/ttyS<port>.
get(card, index) → value

Returns the state of one of the relais.

Parameters:
  • card – Zero-based index of the card to address.
  • index – Zero-based index of the relais on the card.
getNumCards() → int

Returns the number of cards connected to the serial port.

set(card, index, value)

Sets or resets one of the relais.

Parameters:
  • card – Zero-based index of the card to address.
  • index – Zero-based index of the relais on the card.
  • value – Whether to set (True) or reset (False) the relais.
class libavg.avg.Logger

Bases: Boost.Python.instance

Interface to the logger used by the avg player. Enables the setting of different logging categories. Categories can be set either by calling Logger.setCategories or by setting the AVG_LOG_CATEGORIES environment variable. When set through the environment, log categories are separated by colons. In bash syntax:

export AVG_LOG_CATEGORIES=ERROR:WARNING:CONFIG:PROFILE

Log categories are:

NONE
No logging except for errors.
BLTS
Display subsystem logging. Useful for timing/performance measurements.
PROFILE
Outputs performance statistics on player termination.
PROFILE_LATEFRAMES
Outputs performance statistics whenever a frame is displayed late.
PROFILE_VIDEO
Outputs performance statistics for video decoding.
EVENTS
Outputs basic event data.
EVENTS2
Outputs all event data available.
CONFIG
Outputs configuration data.
WARNING
Outputs warning messages.
ERROR
Outputs error messages. Can’t be turned off.
MEMORY
Outputs open/close information whenever a media file is accessed.
APP
Reserved for application-level messages issued by python code.
PLUGIN
Messages generated by loading plugins.
PLAYER
General libavg playback messages.

Default categories are ERROR, WARNING and APP.

Log output is sent to the console (stderr). Each log entry contains the time the message was written, the category of the entry and the message itself.

popCategories()

Pops the current set of categories from the internal stack, restoring the state when the corresponding push was called.

pushCategories()

Pushes the current set of categories on an internal stack. Useful for saving and restoring the logging state so it can be changed for a short amount of time.

setCategories(categories)

Sets the types of messages that should be logged. categories is an or’ed sequence of categories.

trace(category, message)

Logs message to the log if category is active.

Parameters:
  • category – One of the categories listed above. Should in be APP for messages logged from python.
  • message – The log message string.
classmethod get()

This method gives access to the logger. There is only one instance.

class libavg.avg.ParPort

Bases: Boost.Python.instance

Used for low-level control of the parallel port’s data, status and control lines. Linux only.

Deprecated since version 1.5.

__init__(devicename)

Opens a parallel port.

Parameters:
  • devicename – Device filename to use. If devicename is an empty string, /dev/parport0 is used as device name.
clearDataLines(lines)

Clears data lines.

Parameters:
  • lines – The lines to clear. Constants to used for these lines are PARPORTDATA0 - PARPORTDATA7. Several of these constants can be or’ed together to set several lines. The lines not mentioned in the parameter are left unchanged.
Returns:

True if the lines were cleared, False otherwise.

getStatusLine(line)

Returns the value of one of the parallel port status lines.

Parameters:
  • line – Which status line to query. Possible values for line are STATUS_ERROR, STATUS_SELECT, STATUS_PAPEROUT, STATUS_ACK and STATUS_BUSY.
Returns:

True if the line is set.

isAvailable()

Returns True if the parallel port has been opened successfully, False otherwise.

setAllDataLines(lines)

Changes the value of all data lines.

Parameters:
  • lines – The lines to set. Constants to used for these lines are PARPORTDATA0 - PARPORTDATA7. Several of these constants can be or’ed together to set several lines. The lines not mentioned in the parameter are cleared.
Returns:

True if the lines were set, False otherwise.

setControlLine(line, value) → bool

Sets or clears one of the control lines.

Parameters:
  • line – Which control line to modify. Possible values for line are CONTROL_STROBE, CONTROL_AUTOFD, CONTROL_INITu and CONTROL_SELECT.
  • value – Whether to set (True) or clear (False) the line.
Returns:

True if the value was set successfully, False otherwise.

setDataLines(lines)

Sets data lines.

Parameters:
  • lines – The lines to set. Constants to used for these lines are PARPORTDATA0 - PARPORTDATA7. Several of these constants can be or’ed together to set several lines. The lines not mentioned in the parameter are left unchanged.
Returns:

True if the lines were set, False otherwise.

class libavg.avg.Point2D

Bases: Boost.Python.instance

A point in 2D space. Supports most arithmetic operations on vectors. The operators +, -, == and != are defined for two Point2D parameters. Unary - (negation) is defined as well. Point2D objects can also be multiplied and divided by a scalar.

Point2D implicitly converts from and to 2-element float tuples and lists, so in most cases you can use one of these types whenever a point is needed.

__init__()

Creates a point initialized to (0,0).

__init__(x, y)
x
y
getNorm() → float

Returns the euclidian norm of the point, that is sqrt(x*x+y*y).

getNormalized() → Point2D

Returns a normalized version of the point with the same angle but a norm of one. Throws an exception if called on Point2D(0,0).

getRotated(angle) → Point2D

Return the position of point rotated around the origin.

getRotated(angle, pivot) → Point2D

Return the position of point rotated around pivot.

isInf() → bool

Returns True if one of the components is infinite.

isNaN() → bool

Returns True if one of the components is Not a Number.

classmethod fromPolar(angle, radius) → Point2D

Converts polar to cartesian coordinates. angle is in radians with 0 being the positive x axis. Angle is clockwise (assuming that y points downward).

class libavg.avg.TestHelper

Bases: Boost.Python.instance

Miscellaneous routines used by tests. Not intended for normal application usage.

libavg.avg.getMemoryUsage() → int

Returns the amount of memory used by the application in bytes. More precisely, this function returns the resident set size of the process in bytes. This does not include shared libraries or memory paged out to disk.

libavg.avg.pointInPolygon()

Checks if a point is inside a polygon.

Parameters:
  • point (Point2D) – Point to check.
  • poly – List of points which constitute a polygon to check against.
Returns:

True if point is inside, False otherwise.