camera package

Subpackages

Submodules

camera.camera module

Class Camera

class camera.camera.Camera(config_file: str, server_ip: str)

Bases: object

Class Camera, defines the functions of camera device, and stream

get_configuration()

Get the current cameras configuration

Returns:

The current cameras configuration. None if no configuration file was used or configured through the request.

Return type:

CamerasConfiguration or None

set_configuration(config: rrmsutils.models.camera.cameraconfiguration.CamerasConfiguration)

Set the current cameras configuration.

Parameters:
  • config (CamerasConfiguration) – The new configuration to be

  • cameras. (applied to the)

Returns:

True if the configuration is successfully applied and the stream is set, False if the stream could not be set.

Return type:

True or False

set_stream()

Configures and starts the media pipeline.

Returns:

True if the media pipeline is successfully configured and started. False if there is an error starting the pipeline.

Return type:

True or False

camera.logger module

Service Logger

class camera.logger.CustomFormatter(format_str)

Bases: Formatter

Custom formatter for logging

format(record)

Format the specified record as text.

The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.

class camera.logger.Logger

Bases: object

This class contains the methods used to configure the service logger.

LOGGER_NAME = 'camera'
classmethod get_logger()

Get logger with the given name

Returns:

A logger object

Return type:

logging

classmethod init(log_level=20, log_file: str = None)

initialize the service logger

Parameters:
  • log_level (optional) – Logging level as in logging. Defaults to logging.INFO.

  • log_file (str, optional) – Log file path. Defaults to None.

camera.main module

Server entry point

camera.main.main()

Main application

camera.main.parse_args()

Parse arguments

camera.media module

Media Class

class camera.media.Media(description: str, retry: bool = True, retry_delay: int = 5)

Bases: object

Media Class, sets a Gstreamer pipeline, change its status, updates and gets the properties of the element specified

get_caps(element_name)

Gets the value of an element caps property in the pipeline

Parameters:
  • element_name (str) – Pipeline element to get the caps

  • from (property)

Returns:

The value of the element caps property asked for. None if ‘element_name’ doesn’t exist in the pipeline or the property get fails.

Return type:

property (str) or None

get_property(element_name, property_name)

Gets the value of an elements property in the pipeline

Parameters:
  • element_name (str) – Pipeline element to get the property from

  • property_name (str) – Property in the pipeline element to get the value from

Returns:

property; the value of the elements property asked for, None if the element doesn’t exist in the pipeline.

Return type:

property or None

play()

Plays (change the state) of the parsed pipeline :returns: True is stop is successful, False if not :rtype: True or False

set_caps(element_name, caps)

Set the ‘caps’ in the pipeline ‘element_name’

Parameters:
  • element_name (str) – Pipeline element to be changed

  • caps (str) – Caps to be changed in the caps property of pipeline element

Returns:

True if the caps property is successfully set. False if ‘element_name’ is not present in the pipeline or the property set fails.

Return type:

True or False

set_property(element_name, property_name, value)

Set the ‘property_name’ in the pipeline ‘element_name’ to the specified ‘value’

Parameters:
  • element_name (str) – Pipeline element to be changed

  • property_name (str) – Property in the pipeline element to be changed

  • value (str or float) – Value to be set in the property that belongs to the element in the pipeline

Returns:

True if the pipeline element actually is in the pipeline. False if doesn’t.

Return type:

True or False

stop()

Stops (change the state) the pipeline played before :returns: True is stop is successful, False if not :rtype: True or False

camera.server module

Base HTTP server using Flask.

class camera.server.Server(controllers: list, host: str = '127.0.0.1', port: int = 8550)

Bases: object

Flask server

start()

Run the server with given port.

Module contents