''' Miscellaneous functions to be better organized. ''' procgraph_info = { 'requires': [('json', ('simplejson', ))] # TODO: add cjson? } from procgraph import import_magic json = import_magic(__name__, 'json') from . import json_misc from . import to_file from . import pickling
''' Blocks using Matplotlib to display data. ''' procgraph_info = {'requires': ['matplotlib', 'matplotlib.pylab']} # Smart dependencies initialization from procgraph import import_magic, import_succesful matplotlib = import_magic(__name__, 'matplotlib') if import_succesful(matplotlib): if matplotlib.get_backend() != 'agg': matplotlib.use('agg') pylab = import_magic(__name__, 'matplotlib.pylab') from .pylab_to_image import pylab2rgb from .plot_anim import PlotAnim from .plot import * from .plot_generic import * # TODO: plot should fail for no inputs from procgraph import pg_add_this_package_models pg_add_this_package_models(__file__, __package__)
# List of python packages 'requires': [ # try to add this # 'unexistent', ('pickle', ('cPickle', 'pickle')), ], # List of external software needed 'requires_executables': ['git'], # The following are more advanced, and used only for generating # rich cross-referenced documentation. 'sphinx_base_url': 'http://andreacensi.github.com/procgraph/', 'scm_base_url': 'https://github.com/AndreaCensi/procgraph/blob/master/', } from procgraph import import_magic # If pickle is installed, it will be a reference to it, otherwise a # shadow object which will throw when you actually try to use it. pickle = import_magic(__name__, 'pickle') # procgraph will let you import unexistent modules # unexistent = import_magic(__name__, 'unexistent') # now, import the modules that defines the blocks from . import example0_simplest_block
''' YAML conversions. ''' procgraph_info = { 'requires': ['yaml'] } from procgraph import import_magic yaml = import_magic(__name__, 'yaml') from .yaml2object import * from .object2yaml import *
''' This is a set of blocks to read and display AER_ data. .. _AER: http://sourceforge.net/apps/trac/jaer/wiki ''' from procgraph import import_succesful, import_magic procgraph_info = { # List of python packages 'requires': ['aer'] } aer = import_magic(__name__, 'aer') if import_succesful(aer): from .aer_raw_stream import * from .aer_events_hist import * # load models from procgraph import pg_add_this_package_models pg_add_this_package_models(__file__, __package__)
''' YAML conversions. ''' procgraph_info = {'requires': ['yaml']} from procgraph import import_magic yaml = import_magic(__name__, 'yaml') from .yaml2object import * from .object2yaml import *
''' This is a set of blocks to read and write logs in ROS_ Bag format. You need the `rospy` package to be installed. .. _pytables: http://pytables.org .. _ROS: http://www.ros.org ''' procgraph_info = { # List of python packages 'requires': ['ros', 'rosbag_utils'] } # Smart dependency importing from procgraph import import_magic, import_succesful rosbag = import_magic(__name__, 'ros', 'rosbag') rosbag_utils = import_magic(__name__, 'rosbag_utils') if import_succesful(rosbag_utils): from .bagread import BagRead from .bagwrite import BagWrite from .conversions import * from procgraph import pg_add_this_package_models pg_add_this_package_models(__file__, __package__)
''' This is a set of blocks to read and write logs in HDF_ format. You need the pytables_ package to be installed. .. _pytables: http://pytables.org .. _HDF: http://en.wikipedia.org/wiki/Hierarchical_Data_Format ''' from procgraph import import_succesful, import_magic procgraph_info = { # List of python packages 'requires': ['tables', 'hdflog'] } tables = import_magic(__name__, 'tables') hdflogs = import_magic(__name__, 'hdflog') if import_succesful(hdflogs): from .hdfwrite import * from .hdfread import * from .hdfread_many import * else: from procgraph import logger # logger.warning('Could not import hdflogs') from procgraph import pg_add_this_package_models pg_add_this_package_models(__file__, __package__)
''' Some functions specific to robotics applications. Requires: http://github.com/AndreaCensi/geometry ''' procgraph_info = { # List of python packages 'requires': ['geometry'] } # Smart dependency resolution from procgraph import import_magic, import_succesful geometry = import_magic(__name__, 'geometry') if import_succesful(geometry): from . import pose2velocity from . import laser_display from . import laser_dot_display from . import organic_scale from . import misc from . import pose2velocity_b
''' Blocks using the OpenCV library. ''' procgraph_info = { # List of python packages 'requires': [('cv2', ('cv2', )), 'numpy'] } from procgraph import import_magic, import_successful cv = import_magic(__name__, 'cv2', 'cv') # if not import_successful(cv): # cv = import_magic(__name__, 'cv2') np = import_magic(__name__, 'numpy') from .opencv_utils import * from .cv_capture import * from .cv_display import * from .detection import * if not import_successful(cv): if False: from procgraph import logger logger.warn('Could not import CV') from procgraph import pg_add_this_package_models pg_add_this_package_models(__file__, __package__)
''' Blocks for image operations based on the PIL library ''' procgraph_info = {'requires': ['PIL']} # Smart dependencies initialization from procgraph import import_magic, import_succesful Image = import_magic(__name__, 'PIL.Image') ImageFont = import_magic(__name__, 'PIL.ImageFont') ImageDraw = import_magic(__name__, 'PIL.ImageDraw') from .pil_operations import * from .pil_conversions import * from .text import * from .imread_imp import * from .imwrite_imp import *
''' Blocks for image operations based on the PIL library ''' procgraph_info = { 'requires': ['PIL'] } # Smart dependencies initialization from procgraph import import_magic, import_succesful Image = import_magic(__name__, 'PIL.Image') ImageFont = import_magic(__name__, 'PIL.ImageFont') ImageDraw = import_magic(__name__, 'PIL.ImageDraw') from .pil_operations import * from .pil_conversions import * from .text import * from .imread_imp import * from .imwrite_imp import *
**Example** Convert a RGB image to grayscale, and back to a RGB image::: |input| -> |rgb2gray| -> |gray2rgb| -> |output| ''' from procgraph import import_magic, import_successful procgraph_info = { 'requires': ['numpy'], } np = import_magic(__name__, 'numpy') from .filters import * from .compose import * from .imggrid import * from .images_from_dir import * from .posterize import * from .border import * from .pad import * from .blend import * from .copied_from_reprep import * from .reshape_smart import * from .solid_imp import * from .crop import *
''' Blocks for common statistical operations. ''' from procgraph import import_magic procgraph_info = { # List of python packages 'requires': ['astatsa', 'numpy'] } np = import_magic(__name__, 'numpy') from . import expectation from . import variance from . import covariance from . import cov2corr from . import minimum from . import covariance2
''' Blocks using the OpenCV library. ''' procgraph_info = { # List of python packages 'requires': [('cv2', ('cv2',)), 'numpy'] } from procgraph import import_magic, import_successful cv = import_magic(__name__, 'cv2', 'cv') # if not import_successful(cv): # cv = import_magic(__name__, 'cv2') np = import_magic(__name__, 'numpy') from .opencv_utils import * from .cv_capture import * from .cv_display import * from .detection import * if not import_successful(cv): if False: from procgraph import logger logger.warn('Could not import CV') from procgraph import pg_add_this_package_models pg_add_this_package_models(__file__, __package__)
""" Blocks using Matplotlib to display data. """ procgraph_info = {"requires": ["matplotlib", "matplotlib.pylab"]} # Smart dependencies initialization from procgraph import import_magic, import_succesful matplotlib = import_magic(__name__, "matplotlib") if import_succesful(matplotlib): if matplotlib.get_backend() != "agg": matplotlib.use("agg") pylab = import_magic(__name__, "matplotlib.pylab") from .pylab_to_image import pylab2rgb from .plot_anim import PlotAnim from .plot import * from .plot_generic import * # TODO: plot should fail for no inputs from procgraph import pg_add_this_package_models pg_add_this_package_models(__file__, __package__)
""" Miscellaneous functions to be better organized. """ procgraph_info = {"requires": [("json", ("simplejson",))]} # TODO: add cjson? from procgraph import import_magic json = import_magic(__name__, "json") from . import json_misc from . import to_file from . import pickling
""" Blocks using the OpenCV library. """ procgraph_info = { # List of python packages "requires": [("cv2", ("cv2",))] } from procgraph import import_magic, import_succesful cv = import_magic(__name__, "cv2", "cv") from .opencv_utils import * from .cv_capture import * from .cv_display import * if not import_succesful(cv): from procgraph import logger logger.warn("Could not import CV") from procgraph import pg_add_this_package_models pg_add_this_package_models(__file__, __package__)
''' Blocks using the OpenCV library. ''' procgraph_info = { # List of python packages 'requires': [('cv2', ('cv2',))] } from procgraph import import_magic, import_succesful cv = import_magic(__name__, 'cv2', 'cv') from .opencv_utils import * from .cv_capture import * from .cv_display import * if not import_succesful(cv): if False: from procgraph import logger logger.warn('Could not import CV') from procgraph import pg_add_this_package_models pg_add_this_package_models(__file__, __package__)
You need the `rospy` package to be installed. .. _pytables: http://pytables.org .. _ROS: http://www.ros.org ''' procgraph_info = { # List of python packages 'requires': ['ros', 'rosbag_utils'] } # Smart dependency importing from procgraph import import_magic, import_succesful, logger rosbag = import_magic(__name__, 'ros', 'rosbag') rosbag_utils = import_magic(__name__, 'rosbag_utils') if import_succesful(rosbag_utils): from .bagread import BagRead from .bagwrite import BagWrite from .conversions import * else: msg = 'Could not import rosbag_utils; install from [email protected]:AndreaCensi/ros_node_utils.git' logger.error(msg) from procgraph import pg_add_this_package_models pg_add_this_package_models(__file__, __package__)