Exemple #1
0
	def __init__(self, config, generator, img):
		self.config = config
		self.generator = generator
		#self.count = count
		self.pad = 1.
		self.next_y_pos = float(random.randint(1, 256))
		self.next_x_pos = self.pad
		#line space
		self.line_space = 1.

		#text pad
		self.text_pad = 1
		self.image = None
		self.label_info = []

		self.block_theta = 0.
		self.block_angle = 0.
		self.block_patch = None
		self.block_txt_color = []
		self.block_crop = None
		self.block_back_color = []
		self.block_fonts = []
		self.block_heights = []

		self.color = Color()


		self.patch_info = {'patch_w_half':0., 'patch_off_x':0., 'patch_off_y':0.}

		if img != None :
			self.image = img.copy()
Exemple #2
0
    def __init__(self, width, height):
        self.window_color = Color.black()
        self.draw_color = Color.white()
        self.glCreateWindow(width, height)

        self.camPosition = self.vector(0, 0, 0)
        self.fov = 60
        self.scene = []
        self.pointLights = []
        self.dirLight = None
        self.ambientLight = None
        self.envmap = None
Exemple #3
0
    def __init__(self, width, height):
        self.glCreateWindow(width, height)
        self.window_color = Color.black()
        self.draw_color = Color.white()
        self.glClear()
        self.light = self.vector(0, 0, 1)
        self.active_texture = None
        self.active_texture2 = None
        self.active_shader = None

        self.createViewMatrix()
        self.createProjectionMatrix()
Exemple #4
0
def install_sec_list():
    Color.println('	{?} Where would you like to install the sources? : ')
    location = input('')
    if ask('use this location: %s' % location):
        os.mkdir(location)
        os.system(
            'wget -c https://github.com/danielmiessler/SecLists/archive/master.zip -O {0}/SecList.zip && unzip {0}/SecList.zip -d {0} && rm -f {0}/SecList.zip'
            .format(location))
    else:
        Color.write('\n {!} Cancelling')
        return
    return
Exemple #5
0
    def on_press(self, *args, **kwargs):
        _screen = self._current_screen()
        menu_screen = ValidObject.menu_screen(_screen.manager.get_screen('menu'))
        bikes_screen = ValidObject.bikes_screen(_screen.manager.get_screen('bikes'))
        maps_screen = ValidObject.maps_screen(_screen.manager.get_screen('maps'))
        shop_screen = ValidObject.shop_screen(_screen.manager.get_screen('shop'))
        screens = [menu_screen, bikes_screen, maps_screen, shop_screen]

        if 'BikesScreen' == _screen.__class__.__name__:
            if not app_config('bike', 'title'):
                bike_model = get_bike_by_title(bikes_screen.ids['title'].text)
                rest_rm = calc_rest_rm(bike_model.price)

                if Bike.buy(bike_model):
                    RightPanelBtn.change_rm(screens, rest_rm)
                    RightPanelBtn.change_character_wrap(bikes_screen.ids['character_wrap_price'], bike_model.price)
                    RightPanelBtn.change_character_wrap(bikes_screen.ids['character_wrap_power'], bike_model.power)
                    RightPanelBtn.change_character_wrap(bikes_screen.ids['character_wrap_speed'], bike_model.speed)
                    RightPanelBtn.change_character_wrap(bikes_screen.ids['character_wrap_acceleration'], bike_model.acceleration)
                    RightPanelBtn.change_character_wrap(bikes_screen.ids['character_wrap_agility'], bike_model.agility)
                    RightPanelBtn.cancel_animation_button(screens, 'left_panel_menu_bikes')

                    self.init_item(menu_screen.init_bike)
                    RightPanelBtn.change_bottom_right_btn(menu_screen)
                    bikes_screen.ids['title'].color = UColor.hex(UColor.WHITE)
                else:
                    Clock.schedule_once(self._create_animation_fail, 0)
                    Clock.schedule_once(self._clear_animation, .5)

        elif 'MapsScreen' == _screen.__class__.__name__:
            if not app_config('map', 'title'):
                map_model = get_map_by_title(maps_screen.ids['title'].text)
                rest_rm = calc_rest_rm(map_model.price)

                if BaseLevel.buy(map_model):
                    RightPanelBtn.change_rm(screens, rest_rm)
                    RightPanelBtn.change_character_wrap(maps_screen.ids['character_wrap_price'], map_model.price)
                    RightPanelBtn.change_character_wrap(maps_screen.ids['character_wrap_record'], '/dev/')
                    RightPanelBtn.change_character_wrap(maps_screen.ids['character_wrap_level'], map_model.level)
                    RightPanelBtn.change_character_wrap(maps_screen.ids['character_wrap_map'], map_model.map)
                    RightPanelBtn.change_character_wrap(maps_screen.ids['character_wrap_total_way'], map_model.total_way)
                    RightPanelBtn.cancel_animation_button(screens, 'left_panel_menu_maps')

                    self.init_item(menu_screen.init_map)
                    RightPanelBtn.change_bottom_right_btn(menu_screen)
                    maps_screen.ids['title'].color = UColor.hex(UColor.WHITE)
                else:
                    Clock.schedule_once(self._create_animation_fail, 0)
                    Clock.schedule_once(self._clear_animation, .5)
Exemple #6
0
    def triangle_bc(self, A, B, C, texcoords, color=None, normals=()):
        minX = int(min(A['x'], B['x'], C['x']))
        minY = int(min(A['y'], B['y'], C['y']))
        maxX = int(max(A['x'], B['x'], C['x']))
        maxY = int(max(A['y'], B['y'], C['y']))

        for x in range(minX, maxX + 1):
            for y in range(minY, maxY + 1):
                if x >= self.width or x < 0 or y >= self.height or y < 0:
                    continue

                u, v, w = glmath.baryCoords(A, B, C, self.vector(x, y))

                if u >= 0 and v >= 0 and w >= 0:

                    z = A['z'] * u + B['z'] * v + C['z'] * w

                    if z > self.zbuffer[y][x]:
                        if self.active_shader:

                            r, g, b = self.active_shader(
                                self,
                                # verts = verts,
                                baryCoords=(u, v, w),
                                texCoords=texcoords,
                                normals=normals,
                                color=color or self.draw_color)
                        else:
                            b, g, r = color or self.draw_color

                        self.glVertex_coords(x, y, Color.color(r, g, b))
                        self.zbuffer[y][x] = z
Exemple #7
0
 def __init__(self,
              direction=(0, -1, 0),
              _color=Color.white(),
              intensity=1):
     self.direction = div(direction, frobeniusNorm(direction))
     self.intensity = intensity
     self.color = _color
Exemple #8
0
    def getColor(self, tx, ty):
        if tx >= 0 and tx <= 1 and ty >= 0 and ty <= 1:
            x = int(tx * self.width)
            y = int(ty * self.height)

            return self.pixels[y][x]
        else:
            return Color.color(0, 0, 0)
Exemple #9
0
def banner():
    Color.log('Printing Banner..')

    print('\n\n\n\n')
    Color.writenolog(
        '                       {C}############################\n')
    Color.writenolog(
        '                     {G}RootSec Toolin\' Up Install Script\n')
    Color.writenolog('                       {C}############################')
    print('\n\n\n')
Exemple #10
0
 def colorfy(string, col):
     if col == Color.RANDOM:
         col = Color.random()
         return Logger.generate_color(string, col)
     elif col == Color.RAINBOW:
         return Logger.generate_rainbow(string)
     elif col in Color.colors:
         return Logger.generate_color(string, col)
     else:
         return string
Exemple #11
0
 def __init__(self,
              diffuse=Color.white(),
              spec=0,
              ior=1,
              texture=None,
              matType=OPAQUE):
     self.ior = ior
     self.spec = spec
     self.diffuse = diffuse
     self.matType = matType
     self.texture = texture
Exemple #12
0
    def glViewPort(self, x, y, width, height):
        self.viewPort_x, self.viewPort_y = x, y
        self.viewPort_width = width if width < self.width else self.width
        self.viewPort_height = height if height < self.height else self.height
        self.viewPort = [[Color.black() for y in range(self.viewPort_height)]
                         for x in range(self.viewPort_width)]
        self.glClear()

        self.viewportMatrix = [[
            self.viewPort_width / 2, 0, 0, x + self.viewPort_width / 2
        ], [0, self.viewPort_height / 2, 0, y + self.viewPort_height / 2],
                               [0, 0, 0.5, 0.5], [0, 0, 0, 1]]
Exemple #13
0
	def __init__(self, api, dork='"DisallowedHost"', limit=None, offset=None, timeout=None) :

		self.shodan = shodan.Shodan(api)
		self.limit = limit
		self.offset = offset
		self.timeout = timeout

		self._urls = []
		self.color = Color()


		try:

			results = self.shodan.search(dork, limit=self.limit, offset=offset)
			matches = results['matches']
			total = results['total']


			print('{} Shodan found {} hosts with debug mode enabled'.format(self.color.status("[+]"), total))
			print("{} Looking for secret keys wait a moment ..\n".format(self.color.yellows("[!]")))

			for match in matches:

				self.ipadress = match['ip_str']
				self.port = match['port']
				self.hostnames = match['hostnames']
				self.org = match['org']
				self.domains = match['domains']
				self.city = match['location']['city']
				self.country = match['location']['country_name']
	
				# Skip hosts with SSL
				if self.port == 443 :
					continue

				self._urls.append(['http://{}:{}'.format(self.ipadress, self.port)])
				
		except shodan.APIError as error:
			print("error: {}".format(error))
			pass
Exemple #14
0
    def change_character_wrap(character_wrap, value, color=UColor.hex(UColor.WHITE)):
        if type(value) is int:
            progress_bar = ValidObject.progress_bar(character_wrap.children[0].children[0])
            character_wrap.value = value
            character_wrap.max = progress_bar.max = value

        if character_wrap.has_value:
            character_wrap.title = character_wrap.format_number()
        else:
            character_wrap.title = character_wrap.format_string()

        RightPanelBtn.prop_buttons_show(character_wrap)
        RightPanelBtn.change_color_labels_right_panel(character_wrap, color)
Exemple #15
0
def generate_problem(regions_num, plane_size):
    graph = generate_graph(regions_num, plane_size)

    variables = list(graph.neighbours.keys())
    domains = {}

    for variable in variables:
        domains[variable] = Color.get_list()

    problem = Problem(variables, domains)

    for region in graph.neighbours:
        for n in graph.neighbours[region]:
            problem.add_constraint(NotEqualConstraint(region, n))

    return problem, graph
Exemple #16
0
    def glZBuffer(self, filename='output/zbuffer.bmp'):
        archivo = open(filename, 'wb')

        height, width = self.height, self.width

        # File header 14 bytes
        archivo.write(bytes('B'.encode('ascii')))
        archivo.write(bytes('M'.encode('ascii')))
        archivo.write(MemorySize.dword(14 + 40 + width * height * 3))
        archivo.write(MemorySize.dword(0))
        archivo.write(MemorySize.dword(14 + 40))

        # Image Header 40 bytes
        archivo.write(MemorySize.dword(40))
        archivo.write(MemorySize.dword(width))
        archivo.write(MemorySize.dword(height))
        archivo.write(MemorySize.word(1))
        archivo.write(MemorySize.word(24))
        archivo.write(MemorySize.dword(0))
        archivo.write(MemorySize.dword(width * height * 3))
        archivo.write(MemorySize.dword(0))
        archivo.write(MemorySize.dword(0))
        archivo.write(MemorySize.dword(0))
        archivo.write(MemorySize.dword(0))

        minZ = float('inf')
        maxZ = -float('inf')
        for x in range(height):
            for y in range(width):
                if self.zbuffer[x][y] != -float('inf'):
                    if self.zbuffer[x][y] < minZ:
                        minZ = self.zbuffer[x][y]

                    if self.zbuffer[x][y] > maxZ:
                        maxZ = self.zbuffer[x][y]

        for x in range(height):
            for y in range(width):
                depth = self.zbuffer[x][y]
                if depth == -float('inf'):
                    depth = minZ
                depth = (depth - minZ) / (maxZ - minZ)
                archivo.write(Color.color(depth, depth, depth))

        archivo.close()
Exemple #17
0
    def read(self):
        image = open(self.path, 'rb')
        image.seek(10)
        headerSize = struct.unpack('=l', image.read(4))[0]

        image.seek(14 + 4)
        self.width = struct.unpack('=l', image.read(4))[0]
        self.height = struct.unpack('=l', image.read(4))[0]
        image.seek(headerSize)

        self.pixels = []

        for y in range(self.height):
            self.pixels.append([])
            for x in range(self.width):
                b = ord(image.read(1)) / 255
                g = ord(image.read(1)) / 255
                r = ord(image.read(1)) / 255
                self.pixels[y].append(Color.color(r, g, b))

        image.close()
Exemple #18
0
def main():
    clear()
    Color.println('{?} Loading Script..')

    check_prereq()

    Color.println('{+} Loading Script..Done!')
    banner()

    if ask('install SecLists'):
        install_sec_list()

    Color.printlnnolog(
        '\n		{!} Sources Might Be Required to Install Meta Packages!')
    if ask('install Kali/Parrot Sources'):
        install_sources()

    if ask('install Kali Meta Packages'):
        kali_metas()

    if ask('install extra Tools?'):
        install_git_repo()
    print('\n\n')
Exemple #19
0
def dr():
    white_snow = Material(diffuse=Color.color(1, 0.98, 0.98), spec=96)
    black = Material(diffuse=Color.color(0, 0, 0), spec=96)
    orange_carrot = Material(diffuse=Color.color(0.92, 0.54, 0.13), spec=96)
    white = Material(diffuse=Color.color(1, 1, 1), spec=96)
    gray = Material(diffuse=Color.color(0.22, 0.22, 0.22), spec=96)
    darkblue = Material(diffuse=Color.color(0.031, 0.255, 0.361), spec=64)

    rayTracer = Raytracer(500, 500)
    rayTracer.pointLight = PointLight(position=Raytracer.vector(0, 0, 0),
                                      intensity=1)
    rayTracer.ambientLight = AmbientLight(strength=0.1)

    # Cuarto
    # Techo
    rayTracer.scene.append(
        Plane(Raytracer.vector(0, 5, 0), Raytracer.vector(0, -1, 0), black))
    # Suelo
    rayTracer.scene.append(
        Plane(Raytracer.vector(0, -5, 0), Raytracer.vector(0, 1, 0), gray))
    # Pared atras
    rayTracer.scene.append(
        Plane(Raytracer.vector(0, 0, -15), Raytracer.vector(0, 0, 1), gray))
    # Pared izquierda
    rayTracer.scene.append(
        Plane(Raytracer.vector(-5, 0, 0), Raytracer.vector(1, 0, 0), gray))
    # Pared derecha
    rayTracer.scene.append(
        Plane(Raytracer.vector(5, 0, 0), Raytracer.vector(-1, 0, 0), gray))

    # Cubos
    rayTracer.scene.append(AABB(Raytracer.vector(-1, -2, -7), 1.5, darkblue))
    rayTracer.scene.append(
        AABB(Raytracer.vector(1, -2, -7), 1.5, orange_carrot))

    rayTracer.rtRender()
    rayTracer.glFinish('output/dr3.bmp')
Exemple #20
0
 def glClear(self, r=0, g=0, b=0):
     self.pixels = [[Color.color(r, g, b) for y in range(self.height)]
                    for x in range(self.width)]
     self.zbuffer = [[-float('inf') for x in range(self.width)]
                     for y in range(self.height)]
Exemple #21
0
 def get_fill_color(self):
     return Color(self.color)
Exemple #22
0
def proyecto():
    wood = Material(texture=Texture('assets/wood.bmp'))
    white_snow = Material(diffuse=Color.color(1, 0.98, 0.98), spec=96)
    grass = Material(diffuse=Color.color(0.26, 0.42, 0.18), spec=96)
    water = Material(diffuse=Color.color(0.031, 0.255, 0.361),
                     spec=50,
                     ior=1.5,
                     matType=REFLECTIVE)
    darkblue = Material(diffuse=Color.color(0.031, 0.255, 0.361), spec=64)
    playera = Material(diffuse=Color.color(0.2, 0.86, 0.85), spec=64)
    piel = Material(diffuse=Color.color(0.85, 0.71, 0.45), spec=64)
    cafe = Material(diffuse=Color.color(0.32, 0.24, 0.08), spec=64)
    window = Material(spec=40, ior=1.5, matType=TRANSPARENT)

    rayTracer = Raytracer(500, 500)
    rayTracer.pointLight = PointLight(position=Raytracer.vector(0, 0, 0),
                                      intensity=1)
    rayTracer.pointLight = PointLight(position=Raytracer.vector(0, 1, 0),
                                      intensity=1)
    rayTracer.ambientLight = AmbientLight(strength=0.1)
    rayTracer.dirLight = DirectionalLight(direction=rayTracer.vector(
        1, -1, -2),
                                          intensity=0.5)
    rayTracer.envmap = Envmap('assets/unnamed.bmp')

    # Suelo
    rayTracer.scene.append(
        Plane(Raytracer.vector(0, -5, 0), Raytracer.vector(0, 1, 0), grass))

    # Agua
    rayTracer.scene.append(
        AABB(Raytracer.vector(-5, -5, -10), Raytracer.vector(7, 0.2, 5),
             water))
    # Suelo
    rayTracer.scene.append(
        AABB(Raytracer.vector(-1, -4, -19), Raytracer.vector(20, 1, 10),
             grass))
    rayTracer.scene.append(
        AABB(Raytracer.vector(3, -3, -21), Raytracer.vector(17, 1, 10), grass))
    rayTracer.scene.append(
        AABB(Raytracer.vector(6, -2, -23), Raytracer.vector(15, 1, 10), grass))
    # Casa
    rayTracer.scene.append(
        AABB(Raytracer.vector(9, 0, -25), Raytracer.vector(10, 10, 10), wood))
    # Ventana
    rayTracer.scene.append(
        AABB(Raytracer.vector(8, 2, -25), Raytracer.vector(5, 3, 11), window))

    # Steve
    # =======================
    # Piernas
    rayTracer.scene.append(
        AABB(Raytracer.vector(2, -4, -10), Raytracer.vector(0.5, 1.5, 0.5),
             darkblue))
    rayTracer.scene.append(
        AABB(Raytracer.vector(2.6, -4, -10), Raytracer.vector(0.5, 1.5, 0.5),
             darkblue))
    # Playera
    rayTracer.scene.append(
        AABB(Raytracer.vector(2.3, -2.5, -10), Raytracer.vector(1.1, 1.5, 0.5),
             playera))
    rayTracer.scene.append(
        AABB(Raytracer.vector(1.5, -2, -10), Raytracer.vector(0.5, 0.5, 0.5),
             playera))
    rayTracer.scene.append(
        AABB(Raytracer.vector(3.1, -2, -10), Raytracer.vector(0.5, 0.5, 0.5),
             playera))
    # Brazos
    rayTracer.scene.append(
        AABB(Raytracer.vector(1.5, -2.75, -10), Raytracer.vector(0.5, 1, 0.5),
             piel))
    rayTracer.scene.append(
        AABB(Raytracer.vector(3.1, -2.75, -10), Raytracer.vector(0.5, 1, 0.5),
             piel))
    # Cabeza
    rayTracer.scene.append(
        AABB(Raytracer.vector(2.3, -1.3, -10), Raytracer.vector(1.1, 0.9, 1),
             piel))
    # Pelo
    rayTracer.scene.append(
        AABB(Raytracer.vector(2.3, -0.75, -10), Raytracer.vector(1.1, 0.2, 1),
             cafe))
    # Ojos
    rayTracer.scene.append(
        AABB(Raytracer.vector(2.1, -1.2, -9.5),
             Raytracer.vector(0.1, 0.1, 0.2), cafe))
    rayTracer.scene.append(
        AABB(Raytracer.vector(2, -1.2, -9.5), Raytracer.vector(0.1, 0.1, 0.2),
             white_snow))
    rayTracer.scene.append(
        AABB(Raytracer.vector(2.5, -1.2, -9.5),
             Raytracer.vector(0.1, 0.1, 0.2), cafe))
    rayTracer.scene.append(
        AABB(Raytracer.vector(2.6, -1.2, -9.5),
             Raytracer.vector(0.1, 0.1, 0.2), white_snow))
    # Boca
    rayTracer.scene.append(
        AABB(Raytracer.vector(2.1, -1.4, -9.5),
             Raytracer.vector(0.1, 0.1, 0.2), cafe))
    rayTracer.scene.append(
        AABB(Raytracer.vector(2.1, -1.5, -9.5),
             Raytracer.vector(0.1, 0.1, 0.2), cafe))
    rayTracer.scene.append(
        AABB(Raytracer.vector(2.5, -1.4, -9.5),
             Raytracer.vector(0.1, 0.1, 0.2), cafe))
    rayTracer.scene.append(
        AABB(Raytracer.vector(2.5, -1.5, -9.5),
             Raytracer.vector(0.1, 0.1, 0.2), cafe))
    rayTracer.scene.append(
        AABB(Raytracer.vector(2.2, -1.5, -9.5),
             Raytracer.vector(0.1, 0.1, 0.2), cafe))
    rayTracer.scene.append(
        AABB(Raytracer.vector(2.3, -1.5, -9.5),
             Raytracer.vector(0.1, 0.1, 0.2), cafe))
    rayTracer.scene.append(
        AABB(Raytracer.vector(2.4, -1.5, -9.5),
             Raytracer.vector(0.1, 0.1, 0.2), cafe))

    rayTracer.rtRender()
    rayTracer.glFinish('output/dr3.bmp')
Exemple #23
0
def main(argv):

    ## Create and load client configuration
    cfg_ = Configuration()
    cfg_.load(CONFIG_FILE)
    print cfg_

    ## Create UnrealCV client and connect
    ucv_client_ = ucv.connect_client(cfg_.m_unrealengine_host,
                                     cfg_.m_unrealengine_port)

    ## Load sequence configuration file and properties and save description
    seq_ = Sequence()
    seq_.load(cfg_.m_sequence_filename)
    print seq_
    seq_.save("../data/" + seq_.m_name + "/sequence.json")

    ## Generate camera description
    cam_ = Camera()
    cam_.m_fx = cfg_.m_camera_fx
    cam_.m_fy = cfg_.m_camera_fy
    cam_.m_cx = cfg_.m_camera_cx
    cam_.m_cy = cfg_.m_camera_cy
    cam_.m_fov = cfg_.m_camera_fov
    cam_.m_depthmin = cfg_.m_camera_depthmin
    cam_.m_depthmax = cfg_.m_camera_depthmax
    print cam_
    cam_.save("../data/" + seq_.m_name + "/camera.json")

    ## Generate objects description
    object_list_ = ucv_client_.request("vget /objects").split(' ')

    objects_ = {}
    objects_["total_number"] = len(object_list_)
    objects_["objects"] = {}

    print("There are " + str(objects_["total_number"]) +
          " objects in this scene...")

    ### Load object instance to object class mapping
    instance_class_ = {}
    with open("../config/instance_class.json") as f:
        instance_class_ = json.load(f)

    ### Load class information
    classes_ = {}
    with open("../config/classes.json") as f:
        classes_json_ = json.load(f)

        for i_classid in classes_json_.keys():
            obj_class_ = ObjectClass()
            obj_class_.parse_json(classes_json_[i_classid])
            classes_[i_classid] = obj_class_

    ### Describe each object
    for i_objname in object_list_:

        object_ = SceneObject()

        object_.m_instance_name = i_objname
        print("Getting color for {0}".format(i_objname))
        object_color_ = Color(
            ucv_client_.request("vget /object/{0}/color".format(i_objname)))
        print("Object {0} has color {1}".format(i_objname, object_color_))
        object_.m_instance_color = object_color_

        if i_objname in instance_class_:
            object_.m_class = classes_[instance_class_[i_objname]]
        else:
            object_.m_class = classes_["none"]

        objects_["objects"][i_objname] = object_.to_json()

    with open("../data/" + seq_.m_name + "/objects.json", 'w') as f:
        json.dump(objects_, f, indent=2)

    ## Get frames
    for i in range(seq_.m_total_frames):

        print("Getting frame {0} out of {1}...".format(i, seq_.m_total_frames))

        if i < FRAME_START:
            print("Skipping frame " + str(i))
            continue

        frame_ = seq_.m_frames[i]

        frame_id_ = frame_["id"]
        frame_timestamp_ = frame_["timestamp"]
        frame_camera_ = frame_["camera"]
        frame_objects_ = frame_["objects"]

        print frame_timestamp_
        res_camera_ = ucv.place_camera(ucv_client_, frame_camera_)
        while (res_camera_ is None):
            print("ERROR: Trying to place camera again...")
            ucv_client_.disconnect()
            ucv_client_ = ucv.connect_client(cfg_.m_unrealengine_host,
                                             cfg_.m_unrealengine_port)
            res_camera_ = ucv.place_camera(ucv_client_, frame_camera_)

        ucv.place_objects(ucv_client_, frame_objects_)

        frame_rgb_ = cli_rgb.get_rgb(ucv_client_)
        while (frame_rgb_ is None):
            print("ERROR: Trying to get RGB frame again...")
            ucv_client_.disconnect()
            ucv_client_ = ucv.connect_client(cfg_.m_unrealengine_host,
                                             cfg_.m_unrealengine_port)
            frame_rgb_ = cli_rgb.get_rgb(ucv_client_)

        frame_rgb_im_ = Image.fromarray(frame_rgb_)
        frame_rgb_im_.save("../data/" + seq_.m_name + "/rgb/" + frame_id_ +
                           ".png")

        frame_mask_ = cli_sgm.get_object_mask(ucv_client_)
        while (frame_mask_ is None):
            print("ERROR: Trying to get mask frame again...")
            ucv_client_.disconnect()
            ucv_client_ = ucv.connect_client(cfg_.m_unrealengine_host,
                                             cfg_.m_unrealengine_port)
            frame_mask_ = cli_sgm.get_object_mask(ucv_client_)

        frame_mask_im_ = Image.fromarray(frame_mask_)
        frame_mask_im_.save("../data/" + seq_.m_name + "/mask/" + frame_id_ +
                            ".png")

        frame_depth_ = cli_dpt.get_depth(ucv_client_)
        while (frame_depth_ is None):
            print("ERROR: Trying to get depth frame again...")
            ucv_client_.disconnect()
            ucv_client_ = ucv.connect_client(cfg_.m_unrealengine_host,
                                             cfg_.m_unrealengine_port)
            frame_depth_ = cli_dpt.get_depth(ucv_client_)

        frame_depth_im_ = Image.fromarray(frame_depth_)
        cli_utils.save_16bit_png(
            frame_depth_,
            "../data/" + seq_.m_name + "/depth/" + frame_id_ + ".png",
            cam_.m_depthmin, cam_.m_depthmax)
    def __set_volume(self, volume):
        color = Color(self.__low_color, self.__high_color, volume)

        for led in self._leds:
            led.set_color(color)
Exemple #25
0
def install_git_repo():
    candidates = getCandidates('GitHub', 'candidates.txt', True)

    for name in candidates.keys():
        currentName = candidates.get(name)
        Color.writetoline('\n{+} Installing %s.. ' % currentName)

        proc = subprocess.Popen(['git', 'clone', currentName, '/opt/' + name],
                                stdout=subprocess.PIPE,
                                stderr=subprocess.STDOUT)
        stdout, stderr = proc.communicate()
        stdout = str(stdout)
        stderr = str(stderr)

        if stdout.startswith('b\"fatal:' or 'b\"error:') or stderr.startswith(
                'b\"fatal:' or 'b\"error:'):
            Color.writetoline('{-} Installing %s...' % currentName)
            Color.write(
                '\n           {-} An Error Occured While Installing %s, The error persists below:'
                % name)
            Color.write('			{-} %s {W}' % stdout[2:-3])
            print('\n\n')

            if ask('continue'):
                print('\n\n')
                continue
            else:
                print('\n\n')
                sys.exit()

        Color.println('\n	{?} Checking if %s needs any extra attention..' %
                      name)
        for files in os.listdir('/opt/%s' % name):
            files = str(files).lower()
            if files == ('requirements.txt' or 'make' or 'makefile'
                         or 'setup.py'):
                Color.writetoline(
                    '	{+} %s requires additional setting up, doing that now.' %
                    name)
                Color.write(
                    '\n		{+} Found %s file to install.. Doing that now.\n' %
                    files)

                if files == 'requirements.txt':
                    os.system(
                        'python3 -m pip install -r /opt/%s/requirements.txt' %
                        name)
                    os.system(
                        'python2 -m pip install -r /opt/%s/requirements.txt' %
                        name)
                elif files == 'setup.py':
                    os.system('python /opt/%s/setup.py build install' % name)
                elif files == 'make' or 'makefile':
                    os.system('./opt/%s/configure')
                    os.system('/opt/%s/make')
                    os.system('/opt/%s/make install')
                break
        print('\n')
        Color.write('		{+} Successfully installed %s into /opt/%s \n' %
                    (name, name))
Exemple #26
0
 def define_color(self, section):
     return UColor.hex(UColor.WHITE) if app_config(section, 'title') == self.current_slide.item['title']\
         else UColor.hex(UColor.GRAY)
Exemple #27
0
 def glColor(self, r=0, g=0, b=0):
     self.draw_color = Color.color(r, g, b)
Exemple #28
0
class RecogniseSample():
	def __init__(self, config, generator):
		self.config = config
		self.generator = generator
		self.color = Color()

	def getSample(self):
		#get text from label set
		text = ""
		label = []
		blank_count = random.randint(0,5)
		
		if random.choice([True, False]):
			text = self.generator.traverseWordList(True, self.config.recognise_label_len - blank_count)
			self.generator.clearDict()
			self.generator.clearPrePos()
			label = self.generator.traverse_labels
		else:
			text = self.generator.getRandomTxt(True, self.config.recognise_label_len - blank_count)
			label = self.generator.rand_labels

		for i in range(blank_count):
			l_pos = random.randint(0, len(label) - 1)
			t_pos = random.randint(0, len(label) - 1)

			label.insert(l_pos, 0)
			t = text.decode("utf-8")
			t = t[0:t_pos] + ' ' +  t[t_pos:]
			text = t.encode("utf-8")

		#get font
		font = FontObj(self.config)

		t_w, t_h = font.font.getsize(text.decode('utf-8'))
		text_color = self.color.textColor()
		back_color = self.color.distanceRandomColor(text_color, self.config.color_distance)

		img = Image.new("RGB", (t_w, t_h), back_color)

		draw = ImageDraw.Draw(img)
		draw.text((0, 0), text.decode('utf-8'), font = font.font, fill=text_color)

		alpha = random.uniform(0, math.pi/16.)
		sign = math.pow(-1, random.randint(1,2))

		w = int(t_w + t_h*math.tan(alpha))
		h = t_h
		t = t_h*math.tan(alpha) if sign < 0 else 0

		M = np.array([[1, sign*math.tan(alpha), t],
					[0, 1, 0]], np.float32)

		img = np.asarray(img)

		img = cv2.warpAffine(img,M,(w,h), flags=cv2.INTER_LINEAR, borderMode=cv2.BORDER_CONSTANT, borderValue=back_color)

		img = cv2.resize(img, (self.config.recognise_img_width, self.config.recognise_img_height), interpolation=cv2.INTER_LINEAR)

		kernel = np.ones((2,2), np.uint8)

		if random.choice([True, False]):
			img = cv2.erode(img, kernel, 1)
		
		if random.choice([True, False]):
			img = cv2.dilate(img, kernel, 1)

		if random.choice([True, False]):
			img = cv2.GaussianBlur(img, (3,3), 1)

		if self.config.recognise_gray:
			img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

		#im_ = Image.fromarray(img)
		#im_.show()
		#im_.save(self.config.image_path + "img_" +  str(random.randint(0,100)) + ".png")

		img = img.astype('float32')
		img /= 255

		if self.config.recognise_gray:
			return (img,np.array(label, dtype=np.float32))
		else:
			return (img.transpose((2,0,1)),np.array(label, dtype=np.float32))
Exemple #29
0
	def __init__(self, config, generator):
		self.config = config
		self.generator = generator
		self.color = Color()
Exemple #30
0
class ImageSample():
	def __init__(self, config, generator, img):
		self.config = config
		self.generator = generator
		#self.count = count
		self.pad = 1.
		self.next_y_pos = float(random.randint(1, 256))
		self.next_x_pos = self.pad
		#line space
		self.line_space = 1.

		#text pad
		self.text_pad = 1
		self.image = None
		self.label_info = []

		self.block_theta = 0.
		self.block_angle = 0.
		self.block_patch = None
		self.block_txt_color = []
		self.block_crop = None
		self.block_back_color = []
		self.block_fonts = []
		self.block_heights = []

		self.color = Color()


		self.patch_info = {'patch_w_half':0., 'patch_off_x':0., 'patch_off_y':0.}

		if img != None :
			self.image = img.copy()
		
	def __genetrateAImage(self):
		self.image_type = 1 if self.image == None else 2
		
		if self.image_type == 1:
			self.block_back_color = self.color.randomColor()
			self.image = Image.new("RGB", (512, 512), self.block_back_color)

		return self.image

	def __getColor(self):
			idx = random.randint(0,2)
			c1 = random.randint(1, 10)
			c2 = random.randint(1, 10)
			c3 = random.randint(1, 10)

			if idx == 0:
				return (0 + c1,0 + c2,0 + c3)
			elif idx == 1:
				return (255-c1,255-c2,255-c3)
			else:
				return self.color.randomColor()

	def __equalColor(self, c1, c2):
		if (c1[0] == c2[0]) and (c1[1] == c2[1]) and (c1[2] == c2[2]):
			return True
		else:
			return False

	def __ColourDistance(self, rgb_1, rgb_2):
		   R_1,G_1,B_1 = rgb_1
		   R_2,G_2,B_2 = rgb_2
		   rmean = (R_1 +R_2 ) / 2.
		   R = R_1 - R_2
		   G = G_1 -G_2
		   B = B_1 - B_2
		   return math.sqrt((2+rmean/256.)*(R**2)+4*(G**2)+(2+(255-rmean)/256.)*(B**2))

	def __get_std(self, size):
			if size < 32 :
				return self.config.std_min
			else:
				std = self.config.std_min + (self.config.std_max - self.config.std_min)/(self.config.font_size_max - self.config.font_size_min) * (size - self.config.font_size_min)
				return std

	def __getChordLengthX(self, y):
		#default circle center is (512,512) , radius is (512./2.)
		r = 512./2.
		difference = math.pow(r, 2) - math.pow(y-r, 2)
		if difference <0:
			print y
			print difference
		chordLength = math.pow(math.pow(r, 2) - math.pow(y-r, 2), 0.5)
		return  (r - chordLength, 2 * chordLength)


	def __getRealFontSize(self, font, item):
		k = item[0]
		v = item[1]

		w = 0.
		h = 0.
		offset = 0.

		#python 3
		#cwh = font.font.getsize(v)
		(tmp_w, tmp_h) = font.font.getsize(v.decode('utf-8'))
		if k == 1 or k == 2:
			w = 0.5*tmp_w
			h = tmp_h
			offset = 0.
		elif k == 4 or k == 5 or k == 6 or k == 7 or k == 34 or k == 49 or k == 50 or k == 64 or k == 65 or k == 91 or k == 92 or k == 154:
			w = 0.5*tmp_w
			h = tmp_h
			offset = (float(tmp_w) - w)/2.
		elif k == 8 or k == 11 or k == 39 or k == 40 or k == 43 or k == 72 or k == 73 or k == 75:
			w = 0.7*tmp_w
			h = tmp_h
			offset = (float(tmp_w) - w)/2.
		elif k >= 286 and k <= 322:
			w = 0.7*tmp_w
			h = tmp_h
			offset = (float(tmp_w) - w)/2.
		elif k >= 13 and k <= 30 and k%2 == 1:
			w = 0.5*tmp_w
			h = tmp_h
			offset = 0.5*tmp_w
		elif k >= 13 and k <= 30 and k%2 == 0:
			w = 0.5*tmp_w
			h = tmp_h
			offset = 0.
		elif k == 66 or k == 67 or k == 68:
			w = 0.5*tmp_w
			h = tmp_h
			offset = 0.
		else:
			w = float(tmp_w)
			h = float(tmp_h)
			offset = 0.

		return (w, h, offset)

	def __getPatchInfo(self, (block_w, block_h)):
		half_w = block_w/2.
		half_h = block_h/2.

		patch_w_half = math.sqrt(half_w*half_w + half_h*half_h)

		patch_off_x = patch_w_half - half_w
		patch_off_y = patch_w_half - half_h
		
		self.patch_info = {'patch_w_half':patch_w_half, 'patch_off_x':patch_off_x, 'patch_off_y':patch_off_y}

		return (patch_w_half,patch_off_x,patch_off_y)