def setup(self): SKIN_PATHS.append('plugins/'+plugin_folder+'/images') palette = make_palette(plugin_name, colors=["#00FF00","#008000"], help_string=_('Deteccion de marcas')) primitive_dictionary['isPresent'] = self._isPresent palette.add_block('isPresent', style='number-style-1arg', label=_('Viendo Señal'), prim_name='isPresent', help_string= _('Devuelve True si la señal esta en el campo visual de la camara')) self._parent.lc.def_prim('isPresent', 1, lambda self, x: primitive_dictionary['isPresent'](x)) primitive_dictionary['stopCam'] = self._stop_cam palette.add_block('stopCam', style='basic-style', label=_('Parar Camara'), prim_name='stopCam', help_string= _('Apaga la camara')) self._parent.lc.def_prim('stopCam', 0, lambda self : primitive_dictionary['stopCam']()) primitive_dictionary['getMarkerTrigDist'] = self._getMarkerTrigDist palette.add_block('getMarkerTrigDist', style='number-style-1arg', label=_('Distancia Señal'), prim_name='getMarkerTrigDist', help_string= _('Devuelve la distancia a la camara en mm')) self._parent.lc.def_prim('getMarkerTrigDist', 1, lambda self, x: primitive_dictionary['getMarkerTrigDist'](x)) #Se agregan los IDs de botones para luego chequear que esten para activar la camara self.block_list.append('isPresent') self.block_list.append('stopCam') self.block_list.append('getMarkerTrigDist') #TODO: Faltaria ver si levnta el objet_data segun el idioma #obtener identificadores del api y cargar botones con imagenes. out = self.detection.arMultiGetIdsMarker() for section_name in out.split(";"): print 'Signal found:', section_name self._add_signal_botton(palette,section_name,section_name) self.block_list.append(section_name) print ' fin setup'
def setup(self): ''' Set up the palettes ''' sensors_palette = make_palette('sensor', colors=["#FF6060", "#A06060"], help_string=_( 'Palette of sensor blocks'), position=6) media_palette = make_palette('media', colors=["#A0FF00", "#80A000"], help_string=_('Palette of media objects'), position=7) # set up camera-specific blocks media_blocks_dictionary['camera'] = self.prim_take_picture0 media_blocks_dictionary['camera1'] = self.prim_take_picture1 SKIN_PATHS.append('plugins/camera_sensor/images') hidden = True second_cam = False if self._status: hidden = False if len(self.devices) > 1: second_cam = True sensors_palette.add_block('luminance', hidden=hidden, style='box-style', label=_('brightness'), help_string=_( 'light level detected by camera'), value_block=True, prim_name='luminance') self._parent.lc.def_prim( 'luminance', 0, Primitive(self.prim_read_camera, return_type=TYPE_NUMBER, kwarg_descs={'luminance_only': ConstantArg(True)}, call_afterwards=self.after_luminance)) media_palette.add_block('camera', hidden=hidden, style='box-style-media', label=' ', default='CAMERA', help_string=_('camera output'), content_block=True) media_palette.add_block('camera1', hidden=not(second_cam), style='box-style-media', label=' ', default='CAMERA', help_string=_('camera output'), content_block=True) # Depreciated block sensors_palette.add_block( 'read_camera', hidden=True, style='box-style', label=_('brightness'), help_string=_('Average RGB color from camera is pushed to the stack'), value_block=True, prim_name='read_camera') self._parent.lc.def_prim( 'read_camera', 0, Primitive(self.prim_read_camera, return_type=TYPE_NUMBER, kwarg_descs={'luminance_only': ConstantArg(False)})) NO_IMPORT.append('camera') BLOCKS_WITH_SKIN.append('camera') NO_IMPORT.append('camera1') BLOCKS_WITH_SKIN.append('camera1') MEDIA_SHAPES.append('camerasmall') MEDIA_SHAPES.append('cameraoff') MEDIA_SHAPES.append('camera1small') MEDIA_SHAPES.append('camera1off')
def setup(self): ''' Set up the palettes ''' sensors_palette = make_palette('sensor', colors=["#FF6060", "#A06060"], help_string=_( 'Palette of sensor blocks'), position=6) media_palette = make_palette('media', colors=["#A0FF00", "#80A000"], help_string=_('Palette of media objects'), position=7) # set up camera-specific blocks primitive_dictionary['read_camera'] = self.prim_read_camera media_blocks_dictionary['camera'] = self.prim_take_picture0 media_blocks_dictionary['camera1'] = self.prim_take_picture1 SKIN_PATHS.append('plugins/camera_sensor/images') if self._status: sensors_palette.add_block('luminance', style='box-style', label=_('brightness'), help_string=_( 'light level detected by camera'), value_block=True, prim_name='luminance') self._parent.lc.def_prim('luminance', 0, lambda self: primitive_dictionary['read_camera']( luminance_only=True)) # Depreciated block sensors_palette.add_block('read_camera', hidden=True, style='box-style', label=_('brightness'), help_string=_( 'Average RGB color from camera \ is pushed to the stack'), value_block=True, prim_name='read_camera') self._parent.lc.def_prim('read_camera', 0, lambda self: primitive_dictionary['read_camera']()) media_palette.add_block('camera', style='box-style-media', label=' ', default='CAMERA', help_string=_('camera output'), content_block=True) if len(self.devices) > 1: media_palette.add_block('camera1', style='box-style-media', label=' ', default='CAMERA', help_string=_('camera output'), content_block=True) else: media_palette.add_block('camera1', hidden=True, style='box-style-media', label=' ', default='CAMERA', help_string=_('camera output'), content_block=True) else: # No camera, so blocks should do nothing sensors_palette.add_block('luminance', hidden=True, style='box-style', label=_('brightness'), help_string=\ _('light level detected by camera'), value_block=True, prim_name='read_camera') self._parent.lc.def_prim('luminance', 0, lambda self: primitive_dictionary['read_camera']( luminance_only=True)) # Depreciated block sensors_palette.add_block('read_camera', hidden=True, style='box-style', label=_('brightness'), help_string=_( 'Average RGB color from camera \ is pushed to the stack'), value_block=True, prim_name='read_camera') self._parent.lc.def_prim('read_camera', 0, lambda self: primitive_dictionary['read_camera']()) media_palette.add_block('camera', hidden=True, style='box-style-media', label=' ', default='CAMERA', help_string=_('camera output'), content_block=True) media_palette.add_block('camera1', hidden=True, style='box-style-media', label=' ', default='CAMERA', help_string=_('camera output'), content_block=True) NO_IMPORT.append('camera') BLOCKS_WITH_SKIN.append('camera') NO_IMPORT.append('camera1') BLOCKS_WITH_SKIN.append('camera1') MEDIA_SHAPES.append('camerasmall') MEDIA_SHAPES.append('cameraoff') MEDIA_SHAPES.append('camera1small') MEDIA_SHAPES.append('camera1off')
def setup(self): ''' Set up the palettes ''' sensors_palette = make_palette( 'sensor', colors=["#FF6060", "#A06060"], help_string=_('Palette of sensor blocks'), position=6) media_palette = make_palette('media', colors=["#A0FF00", "#80A000"], help_string=_('Palette of media objects'), position=7) # set up camera-specific blocks media_blocks_dictionary['camera'] = self.prim_take_picture0 media_blocks_dictionary['camera1'] = self.prim_take_picture1 SKIN_PATHS.append('plugins/camera_sensor/images') hidden = True second_cam = False if self._status: hidden = False if len(self.devices) > 1: second_cam = True sensors_palette.add_block( 'luminance', hidden=hidden, style='box-style', label=_('brightness'), help_string=_('light level detected by camera'), value_block=True, prim_name='luminance') self._parent.lc.def_prim( 'luminance', 0, Primitive(self.prim_read_camera, return_type=TYPE_NUMBER, kwarg_descs={'luminance_only': ConstantArg(True)}, call_afterwards=self.after_luminance)) media_palette.add_block('camera', hidden=hidden, style='box-style-media', label=' ', default='CAMERA', help_string=_('camera output'), content_block=True) media_palette.add_block('camera1', hidden=not (second_cam), style='box-style-media', label=' ', default='CAMERA', help_string=_('camera output'), content_block=True) # Depreciated block sensors_palette.add_block( 'read_camera', hidden=True, style='box-style', label=_('brightness'), help_string=_( 'Average RGB color from camera is pushed to the stack'), value_block=True, prim_name='read_camera') self._parent.lc.def_prim( 'read_camera', 0, Primitive(self.prim_read_camera, return_type=TYPE_NUMBER, kwarg_descs={'luminance_only': ConstantArg(False)})) NO_IMPORT.append('camera') BLOCKS_WITH_SKIN.append('camera') NO_IMPORT.append('camera1') BLOCKS_WITH_SKIN.append('camera1') MEDIA_SHAPES.append('camerasmall') MEDIA_SHAPES.append('cameraoff') MEDIA_SHAPES.append('camera1small') MEDIA_SHAPES.append('camera1off')
def setup(self): SKIN_PATHS.append('plugins/food/images') self._eat_palette() self._food_palette()
def setup(self): ''' Set up the palettes ''' sensors_palette = make_palette( 'sensor', colors=["#FF6060", "#A06060"], help_string=_('Palette of sensor blocks'), position=6) media_palette = make_palette('media', colors=["#A0FF00", "#80A000"], help_string=_('Palette of media objects'), position=7) # set up camera-specific blocks primitive_dictionary['read_camera'] = self.prim_read_camera media_blocks_dictionary['camera'] = self.prim_take_picture0 media_blocks_dictionary['camera1'] = self.prim_take_picture1 SKIN_PATHS.append('plugins/camera_sensor/images') if self._status: sensors_palette.add_block( 'luminance', style='box-style', label=_('brightness'), help_string=_('light level detected by camera'), value_block=True, prim_name='luminance') self._parent.lc.def_prim( 'luminance', 0, lambda self: primitive_dictionary['read_camera'] (luminance_only=True)) # Depreciated block sensors_palette.add_block( 'read_camera', hidden=True, style='box-style', label=_('brightness'), help_string=_('Average RGB color from camera \ is pushed to the stack'), value_block=True, prim_name='read_camera') self._parent.lc.def_prim( 'read_camera', 0, lambda self: primitive_dictionary['read_camera']()) media_palette.add_block('camera', style='box-style-media', label=' ', default='CAMERA', help_string=_('camera output'), content_block=True) if len(self.devices) > 1: media_palette.add_block('camera1', style='box-style-media', label=' ', default='CAMERA', help_string=_('camera output'), content_block=True) else: media_palette.add_block('camera1', hidden=True, style='box-style-media', label=' ', default='CAMERA', help_string=_('camera output'), content_block=True) else: # No camera, so blocks should do nothing sensors_palette.add_block('luminance', hidden=True, style='box-style', label=_('brightness'), help_string=\ _('light level detected by camera'), value_block=True, prim_name='read_camera') self._parent.lc.def_prim( 'luminance', 0, lambda self: primitive_dictionary['read_camera'] (luminance_only=True)) # Depreciated block sensors_palette.add_block( 'read_camera', hidden=True, style='box-style', label=_('brightness'), help_string=_('Average RGB color from camera \ is pushed to the stack'), value_block=True, prim_name='read_camera') self._parent.lc.def_prim( 'read_camera', 0, lambda self: primitive_dictionary['read_camera']()) media_palette.add_block('camera', hidden=True, style='box-style-media', label=' ', default='CAMERA', help_string=_('camera output'), content_block=True) media_palette.add_block('camera1', hidden=True, style='box-style-media', label=' ', default='CAMERA', help_string=_('camera output'), content_block=True) NO_IMPORT.append('camera') BLOCKS_WITH_SKIN.append('camera') NO_IMPORT.append('camera1') BLOCKS_WITH_SKIN.append('camera1') MEDIA_SHAPES.append('camerasmall') MEDIA_SHAPES.append('cameraoff') MEDIA_SHAPES.append('camera1small') MEDIA_SHAPES.append('camera1off')
#!/usr/bin/env python # -*- coding: utf-8 -*- import os.path from plugins.plugin import Plugin from TurtleArt.tapalette import make_palette from TurtleArt.taconstants import CONSTANTS from TurtleArt.taconstants import MEDIA_SHAPES, NO_IMPORT, SKIN_PATHS, EXPAND_SKIN, BLOCKS_WITH_SKIN from TurtleArt.taprimitive import Primitive, ArgSlot, ConstantArg from TurtleArt.tatype import TYPE_INT, TYPE_STRING, TYPE_BOOL SKIN_PATHS.append('plugins/pattern_detection/images') from gettext import gettext as _ from library import patternsAPI class Pattern_detection(Plugin): def __init__(self, parent): Plugin.__init__(self) self.tw = parent self.isInit = False self._path = os.path.dirname(__file__) self.detection = patternsAPI.detection() def setup(self): palette = make_palette('pattern_detection', ["#00FF00","#008000"], _('Pattern detection'), translation=_('pattern_detection')) palette.add_block('isPresent',