All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends
Public Member Functions | Public Attributes | Static Private Member Functions
face_contour_detector.image_information.xml_image_information.XMLImageInformationDatabase Class Reference

Class to read a database from a xml file and to write a database to a xml file. More...

List of all members.

Public Member Functions

def __init__
 The constructor.
def append
 Append a new entry to the database.
def load
 Load a xml file and add all entries to the images list.
def load_file
 Load the database from an xml file.
def max_reached
 Return true if max_size is reached for this database.
def write_file
 Write a xml file to path.
def write_pretty_xml
 Write the database to the writer object.

Public Attributes

 images
 the list containing the images: images is a list of dictionaries.
 max_size
 the maximum amount of images stores in the images list

Static Private Member Functions

def __create_image_node
 internal method to create an "image" node
def __information_entry_to_node
 internal method to create an "entry" node
def __pretty_write_entry
 internalt method: writes an "entry" node to the writer object (should have a write method)
def __pretty_write_image
 internal method to write an "image" node to writer (should have a write method)

Detailed Description

Class to read a database from a xml file and to write a database to a xml file.

Author:
Fabian Wenzelmann
Date:
2011-02-20

A image database ist a list of dictionaries. Such a dictionary maps property names to tuples where the first component of the tuple is the value of this property and the second component is the type as string. Allowed types are "int", "float" and "string". For example if the only information for one image is the MaxPixelValue the dictionary has the form

{ "MaxPixelValue" : (200, "int") } 

which means that the max pixel value in the image is 200 and the result is of type int. A list of such dictionaries is saved in a field called images.
There is also a max_size parameter to restrict the size of images that can be stored in a database.

Definition at line 23 of file xml_image_information.py.


Constructor & Destructor Documentation

The constructor.

Parameters:
selfthe object pointer
max_sizeIf max_size is not None it is an integer >= 1. The append() method takes care that there are not more than max_size elements in the list. Also the load() method loads only max_size elements, even if there are more in the xml file. If it's None the database has no limit.

Definition at line 27 of file xml_image_information.py.


Member Function Documentation

internal method to create an "image" node

Definition at line 105 of file xml_image_information.py.

internal method to create an "entry" node

Definition at line 85 of file xml_image_information.py.

def face_contour_detector.image_information.xml_image_information.XMLImageInformationDatabase.__pretty_write_entry (   typename,
  name,
  content,
  writer,
  indent,
  addindent,
  newl 
) [static, private]

internalt method: writes an "entry" node to the writer object (should have a write method)

Definition at line 113 of file xml_image_information.py.

def face_contour_detector.image_information.xml_image_information.XMLImageInformationDatabase.__pretty_write_image (   entries,
  writer,
  indent,
  addindent,
  newl 
) [static, private]

internal method to write an "image" node to writer (should have a write method)

Definition at line 140 of file xml_image_information.py.

Append a new entry to the database.

Parameters:
selfthe object pointer
entryThe new entry to add (a dictionary as defined in preface)

Adds a new element to the list. If max_size is reached the new entry will displace the oldest entry in the list. Which is assumed to be the first entry in the list.

Definition at line 205 of file xml_image_information.py.

Load a xml file and add all entries to the images list.

Parameters:
selfthe object pointer
doca xml object as received by xml.dom.minidom.parse

Parses a xml file and adds all images images list. The xml file must follow the XML Schema of imageInformationDatabase as defined in image_information.xsd. This means that the root note is "imageInformationDatabase". This node has subnodes with name "image". A image node has "entry" subnodes where each entry node has two child nodes: "name" (with the name of the property) and "content" (the value of this property). An entry also has an attribute "type" which is "int", "float" or "string".
Also max_size value is checked so if there are more than max_size elements in the file you only have max_size elements in the list (following the order of the document).

Exceptions:
XMLValueErrorif the root node is not "imageInformationDatabase"
XMLValueErrorif the type attribute of entry is not "int", "float" or "string"
ExceptionAn exception may be thrown if there is no attribute "type" in entry or if an entry has no name or no content subnode. We also assume that if entry is if type int the int function of python can translate the content of this entry to an integer (also for float).

Definition at line 48 of file xml_image_information.py.

Load the database from an xml file.

Parameters:
pathpath of the xml file
Exceptions:
Exceptionif file does not exists

Just calls load() method with xml.dom.minidom.parse(path)

Definition at line 190 of file xml_image_information.py.

Return true if max_size is reached for this database.

Parameters:
selfthe object pointer

Definition at line 195 of file xml_image_information.py.

Write a xml file to path.

Parameters:
selfthe object pointer
pathfile path to the xml file
See also:
write_pretty_xml()

Definition at line 181 of file xml_image_information.py.

Write the database to the writer object.

Parameters:
selfthe object pointer
writera object that has e "write" functions (file object interface)
addindenta string that is the incremental idention for subnodes
newla string that is used as newline (after most nodes)

Writes a xml file that satisfies the imageInformationDatabase type as defined in image_information.xsd

Definition at line 157 of file xml_image_information.py.


Member Data Documentation

the list containing the images: images is a list of dictionaries.

Such a dictionary maps property names to tuples where the first component of the tuple is the value of this property and the second component is the type as string. Allowed types are "int", "float" and "string". For example if the only information for one image is the MaxPixelValue the dictionary has the form

{ "MaxPixelValue" : (200, "int") } 

which means that the max pixel value in the image is 200 and the result is of type int. A list of such dictionaries is saved in a field called images.

Definition at line 27 of file xml_image_information.py.

the maximum amount of images stores in the images list

Definition at line 27 of file xml_image_information.py.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends


face_contour_detector
Author(s): Fabian Wenzelmann and Julian Schmid
autogenerated on Wed Dec 26 2012 16:18:18