class Level01(Scene): def __init__(self, background_file, ground_file): Scene.__init__(self, background_file, ground_file) _, screen_h = pygame.display.get_surface().get_size() ground_height = screen_h - self.ground.surface.get_height() self.ground.y = ground_height self.player = SpriteControlled(10, ground_height, 'sprite.png', True, 2) self.cursor = Sprite(0, 0, 'cursor.png', False) self.warp = Warp(680, 0, 'warp.png', False, "level00") self.warp.y = ground_height - self.warp.surface.get_height() / 2 def load(self): pass def inputs(self, events): for event in events: if event.type == pygame.MOUSEBUTTONDOWN: mouse_click = pygame.mouse.get_pos() self.player.move_to(mouse_click[0]) def update(self, change_scene): self.cursor.set_position(pygame.mouse.get_pos()) self.player.update() if self.player.intersects(self.warp): change_scene(self.warp.to_scene) def draw(self, screen): self.background.draw(screen) self.ground.draw(screen) self.warp.draw(screen) self.player.draw(screen) self.cursor.draw(screen)
def runTest(self): self.test = Warp() # validate basic functionality self.assert_console_accepts_markers() self.assert_accepts_end_tempo() self.assert_console_accepts_b2s() self.assert_console_accepts_s2b() self.assert_expected_s2b_and_b2s_if_only_1_marker() # validate basic exceptions self.assert_warp_filters_invalid_markers_properly() self.assert_warp_filters_invalid_b2s_and_s2p_ie_no_end_tempo() self.assert_end_tempo_doesnt_accept_negatives() # validate the s2b and b2s functionalities at edge points self.assert_expected_s2b_inbetween_the_two_markers() self.assert_expected_b2s_inbetween_the_two_markers() self.assert_expected_s2b_and_b2s_before_the_2markers() self.assert_expected_s2b_and_b2s_after_all_2markers() self.assert_expected_s2b_and_b2s_if_call_is_on_marker() self.assert_s2b_b2s_act_properly_after_third_marker_introduced() # validate performance self.check_if_solution_is_optimal()
def assert_that_order_of_marker_vs_end_tempo_setting_doesnt_matter(self): """Verify that the end_tempo can be set before the markers are set""" self.test = Warp() self.assert_accepts_end_tempo() self.assert_console_accepts_markers() self.assert_console_accepts_b2s() self.assert_console_accepts_s2b()
def __init__(self, background_file, ground_file): Scene.__init__(self, background_file, ground_file) _, screen_h = pygame.display.get_surface().get_size() ground_height = screen_h - self.ground.surface.get_height() self.ground.y = ground_height self.player = SpriteControlled(10, ground_height, 'sprite.png', True, 2) self.cursor = Sprite(0, 0, 'cursor.png', False) self.warp = Warp(680, 0, 'warp.png', False, "level00") self.warp.y = ground_height - self.warp.surface.get_height() / 2
def __init__(self, background_file, ground_file): self.background = Sprite(0, 0, background_file, False) self.ground = Sprite(0, 0, ground_file, False) screen_w, screen_h = pygame.display.get_surface().get_size() ground_height = screen_h - self.ground.surface.get_height() self.ground.y = ground_height self.player = SpriteControlled(150, ground_height, 'Sprite.png', True, 2) self.copain = SpriteControlled(500, ground_height, 'copain.png', True, 0) self.cursor = Sprite(0, 0, 'cursor.jpg', False) #self.collision_text = font.render("Oops sorry Mamen", False,(0, 0,0)) self.warp = Warp(700, 0, 'warp.png', False, "level01") self.warp.y = ground_height - self.warp.surface.get_height() / 2
def load(self, filename): file = open(Scene.path + filename) data = file.read().splitlines() ground_height = 0 self.cursor = Sprite(0, 0, 'cursor.png', False) self.sprites = [] self.warps = [] self.ui_top = UiGroup() panel = UiPanel(0, 0, 800, 110) button = UiButton(10, 10, 90, 90, "banana") self.ui_top.add_element(panel) self.ui_top.add_element(button) for line in data: cell = line.split(";") # Ground if (cell[0] == "ground"): self.ground = Sprite(0, 0, cell[1] + ".png", False) _, screen_h = pygame.display.get_surface().get_size() ground_height = screen_h - self.ground.surface.get_height() self.ground.y = ground_height # Background elif (cell[0] == "background"): self.background = Sprite(0, 0, cell[1] + ".png", False) # Player elif (cell[0] == "player"): height = 0 if cell[3] == "ground": height = -1 self.player = SpriteControlled(int(cell[2]), height, cell[1] + ".png", True, int(cell[4])) # Sprites elif (cell[0] == "sprite"): height = 0 if cell[3] == "ground": height = -1 sprite = Sprite(int(cell[2]), height, cell[1] + ".png", True) self.sprites.append(sprite) # Warps elif (cell[0] == "warp"): height = 0 if cell[3] == "ground": height = -1 warp = Warp(int(cell[2]), height, cell[1] + ".png", False, eval(cell[4])) self.warps.append(warp) # Set heights if (self.player.y == -1): self.player.y = ground_height for s in self.sprites: if (s.y == -1): s.y = ground_height for w in self.warps: if (w.y == -1): w.y = ground_height - w.surface.get_height() / 2
def factory(aug_type, **kwargs): """Factory method for data augmentation classes.""" if aug_type is 'box': return BoxOcclusion(**kwargs) if aug_type is 'blur': return Blur(**kwargs) if aug_type is 'flip': return Flip(**kwargs) if aug_type is 'warp': return Warp(**kwargs) if aug_type is 'misalign': return Misalign(**kwargs) if aug_type is 'missing': return MissingSection(**kwargs) if aug_type is 'greyscale': return Greyscale(**kwargs) assert False, "Unknown data augmentation type: [%s]" % aug_type
class Scene: def __init__(self, background_file, ground_file): self.background = Sprite(0, 0, background_file, False) self.ground = Sprite(0, 0, ground_file, False) screen_w, screen_h = pygame.display.get_surface().get_size() ground_height = screen_h - self.ground.surface.get_height() self.ground.y = ground_height self.player = SpriteControlled(150, ground_height, 'Sprite.png', True, 2) self.copain = SpriteControlled(500, ground_height, 'copain.png', True, 0) self.cursor = Sprite(0, 0, 'cursor.jpg', False) #self.collision_text = font.render("Oops sorry Mamen", False,(0, 0,0)) self.warp = Warp(700, 0, 'warp.png', False, "level01") self.warp.y = ground_height - self.warp.surface.get_height() / 2 def load(self): pass def inputs(self, events): for event in events: if event.type == pygame.MOUSEBUTTONDOWN: mouse_click = pygame.mouse.get_pos() self.player.move_to(mouse_click[0]) def update(self, change_scene): self.cursor.set_position(pygame.mouse.get_pos()) self.player.update() if(self.player.intersects(self.warp)): change_scene(self.warp.to_scene) #if(self.player.intersects(self.copain)): #screen.blit(self.collision_text,(self.copain_x, self.copain_y - 100)) def draw(self, screen): self.background.draw(screen) self.ground.draw(screen) self.warp.draw(screen) self.player.draw(screen) self.cursor.draw(screen) self.copain.draw(screen)
def main(): parser = ArgumentParser() parser.add_argument('--image_dir', required=True) parser.add_argument('--feature_dir', required=True) parser.add_argument('--grid_dir', required=True) parser.add_argument('--warp_dir', required=True) args = parser.parse_args() images = os.listdir(args.image_dir) features = os.listdir(args.feature_dir) image_id = [ (int(img.split('.')[0]), os.path.join(args.image_dir, img)) for img in images ] feature_id = [ (int(feat.split('.')[0]), os.path.join(args.feature_dir, feat)) for feat in features ] image_id.sort(key=lambda tup: tup[0]) feature_id.sort(key=lambda tup: tup[0]) data = zip(image_id, feature_id) for image, feat in data: print ('Processing image:', image[1]) warp = Warp(image[1], feat[1], 18, 32, args.grid_dir, args.warp_dir, alpha=20) warp.warp() print ('')
def assert_expected_s2b_and_b2s_if_only_1_marker(self): """ Verifies that the program functions as expected if only one marker exists """ warp_test = Warp() warp_test.set_marker(0, 0) warp_test.set_end_tempo(10) # after marker self.assertEqual(console(warp_test, "s2b 1"), 10) self.assertEqual(console(warp_test, "b2s 10"), 1) # before marker self.assertEqual(console(warp_test, "s2b -1"), -10) self.assertEqual(console(warp_test, "b2s -10"), -1) # on marker self.assertEqual(console(warp_test, "s2b 0"), 0) self.assertEqual(console(warp_test, "b2s 0"), 0)
import cv2 import numpy as np from warp import Warp # getting image from the camera # camera = cv2.VideoCapture(0) # def get_image(): # retval, img = camera.read() # return img # original_image = get_image() original_image = cv2.imread('slantview1.png') # create object and filter image to get contours rectangle = Warp(np.array([10, 255, 255]), np.array([0, 128, 64])) rectangle_filtered = rectangle.filter_bw(original_image) # obtain, sort, and approximate contours to find desired contours rectangle_bounds = rectangle.findsort_contours(rectangle_filtered, -2) epsilon = 0.05 * cv2.arcLength(rectangle_bounds, True) rectangle_approx_contours = cv2.approxPolyDP(rectangle_bounds, epsilon, True) rectangle_ordered_contours, rectangle_desired_contours, max_width, max_height = rectangle.orderdesire_contours( rectangle_approx_contours) # transform the image transformation = cv2.getPerspectiveTransform(rectangle_ordered_contours, rectangle_desired_contours) warped_image = cv2.warpPerspective(original_image, transformation, (max_width, max_height)) # find the center of the car
def check_if_solution_is_optimal(self): """ Verifies that the optimal solutions is employed with complexity O(log(n)). The whole function must run at no less than 1000 standard units; A standard unit is defined as the time it takes for a general sorting function to sort 1,000 times; which, is only possible if the ideal O(log(n)) solution is used in all steps. """ import timeit import math import statistics as stats import time avg_log = [] test_ns = [2**i for i in range(4, 12)] start = time.time() for n in test_ns: test_warp = Warp() avg_exc = 0 avg_exc_ref = 0 for marker in range(1, n): console( test_warp, "marker " + str(float(marker)) + ' ' + str(float(marker))) repeats = 25 for _ in range(repeats): execution = timeit.timeit(lambda: [ console(test_warp, 'b2s ' + str(n - 0.1)), console(test_warp, 's2b ' + str(n // 2 - 0.1)) ], number=400) avg_exc += execution / repeats execution = timeit.timeit( lambda: [ord(x) for x in "aasdfadgasdfwr22"], number=1000) avg_exc_ref += execution / repeats avg_log.append(avg_exc / avg_exc_ref) print("(raw time, for 400 requests, and n-markers = %d)" " mean: %f, theoretical frequency: %f" % (n, avg_exc, 2 * 400 / avg_exc)) # 2 * because s2b and b2s in conjunction time_elapsed = time.time() - start exc_ref = sum( timeit.repeat(lambda: [ord(x) for x in "aasdfadgasdfwr22"], repeat=25, number=1000)) / 25 time_elapsed_normalized = time_elapsed / exc_ref self.assertTrue(time_elapsed < 1000) avg_log = [ math.log2(avg_log[i + 1] / avg_log[i]) for i in range(len(avg_log) - 1) ] print("(logarithm) mean: %f, std: %f, adjusted mean: %f" % (stats.mean(avg_log), stats.stdev(avg_log), stats.mean(avg_log) + 2 * stats.stdev(avg_log))) self.assertTrue(stats.mean(avg_log) < 0.15) # O(log(n))
def load(self, filename): file = open(Scene.path + filename) data = file.read().splitlines() ground_height = 0 self.cursor = Sprite(0, 0, 'cursor.png', False) self.sprites = [] self.state_sprites = [] self.warps = [] self.pickables = [] self.messages = [] self.observers = [] self.ui_top = UiGroup() panel = UiPanel(0, 0, 800, 110) self.ui_top.add_element(panel) for line in data: cell = line.split(";") # Ground if (cell[0] == "ground"): self.ground = Sprite(0, 0, cell[1] + ".png", False) _, screen_h = pygame.display.get_surface().get_size() ground_height = screen_h - self.ground.surface.get_height() self.ground.y = ground_height # Background elif (cell[0] == "background"): self.background = Sprite(0, 0, cell[1] + ".png", False) # Player elif (cell[0] == "player"): height = 0 if cell[3] == "ground": height = -1 self.player = SpriteControlled(int(cell[2]), height, cell[1] + ".png", True, int(cell[4])) # Sprites elif (cell[0] == "sprite"): height = 0 if cell[3] == "ground": height = -1 sprite = Sprite(int(cell[2]), height, cell[1] + ".png", True) self.sprites.append(sprite) # Stateful sprites elif (cell[0] == "stateful"): height = 0 if cell[3] == "ground": height = -1 sprite = SpriteStateful(int(cell[2]), height, eval(cell[1]), True, eval(cell[4]), cell[5]) self.state_sprites.append(sprite) self.observers.append(sprite) # Warps elif (cell[0] == "warp"): height = 0 if cell[3] == "ground": height = -1 warp = Warp(int(cell[2]), height, cell[1] + ".png", False, eval(cell[4])) self.warps.append(warp) # Items elif (cell[0] == "pickable"): height = 0 if cell[3] == "ground": height = -1 item = SpritePickable(int(cell[2]), height, cell[1] + "_ingame.png", False, cell[1]) self.pickables.append(item) # Set heights if (self.player.y == -1): self.player.y = ground_height for s in self.sprites: if (s.y == -1): s.y = ground_height for s in self.state_sprites: if (s.y == -1): s.y = ground_height for w in self.warps: if (w.y == -1): w.y = ground_height - w.surface.get_height() / 2 for p in self.pickables: if (p.y == -1): p.y = ground_height - p.surface.get_height()
class TestWarp(unittest.TestCase): """ A test that validates basic functionality, exception handling, main s2b and b2s functions, and performance. """ def runTest(self): self.test = Warp() # validate basic functionality self.assert_console_accepts_markers() self.assert_accepts_end_tempo() self.assert_console_accepts_b2s() self.assert_console_accepts_s2b() self.assert_expected_s2b_and_b2s_if_only_1_marker() # validate basic exceptions self.assert_warp_filters_invalid_markers_properly() self.assert_warp_filters_invalid_b2s_and_s2p_ie_no_end_tempo() self.assert_end_tempo_doesnt_accept_negatives() # validate the s2b and b2s functionalities at edge points self.assert_expected_s2b_inbetween_the_two_markers() self.assert_expected_b2s_inbetween_the_two_markers() self.assert_expected_s2b_and_b2s_before_the_2markers() self.assert_expected_s2b_and_b2s_after_all_2markers() self.assert_expected_s2b_and_b2s_if_call_is_on_marker() self.assert_s2b_b2s_act_properly_after_third_marker_introduced() # validate performance self.check_if_solution_is_optimal() def assert_console_accepts_b2s(self): """Checks if the console accepts the b2s command""" self.assertFalse( isinstance(type(console(self.test, "b2s 0.5")), type(None))) def assert_console_accepts_s2b(self): """Checks if the console accepts the s2b command""" self.assertFalse( isinstance(type(console(self.test, "s2b 2.5")), type(None))) def assert_console_accepts_markers(self): """Checks if the console accepts the marker command""" self.assertEqual(console(self.test, "marker 0.0 0.0"), None) self.assertEqual(console(self.test, "marker 1.0 5.0"), None) def assert_accepts_end_tempo(self): """Checks if the console accepts end_tempo command""" self.assertEqual(console(self.test, "end_tempo 10.0"), None) self.assertEqual(self.test.end_tempo, 10) def assert_warp_filters_invalid_markers_properly(self): """ Verifies that the object's marker values do not change / update when fed an invalid object. There are two invalid possibilities: 1) the marker is already defined 2) there is an intersection with another marker """ markers = self.test.markers.copy() # already defined points console(self.test, "marker 0.0 1.0") console(self.test, "marker 1.0 0.0") self.assertEqual(markers, self.test.markers) # interceting vertices console(self.test, "marker 0.5 6.0") self.assertEqual(markers, self.test.markers) def assert_warp_filters_invalid_b2s_and_s2p_ie_no_end_tempo(self): """ Verifies that if a end_tempo is not given, the b2s and s2b methods will have no output """ self.test.set_end_tempo(None) self.assertEqual(console(self.test, "b2s 2.0"), None) self.assertEqual(console(self.test, "s2b 6.0"), None) self.test.set_end_tempo(10.0) def assert_end_tempo_doesnt_accept_negatives(self): """ Verifies that if a negative values is provided to end_tempo that nothing changes. """ end_tempo = self.test.end_tempo self.assertEqual(console(self.test, "end_tempo -10"), None) self.assertEqual(end_tempo, self.test.end_tempo) def assert_expected_s2b_and_b2s_if_only_1_marker(self): """ Verifies that the program functions as expected if only one marker exists """ warp_test = Warp() warp_test.set_marker(0, 0) warp_test.set_end_tempo(10) # after marker self.assertEqual(console(warp_test, "s2b 1"), 10) self.assertEqual(console(warp_test, "b2s 10"), 1) # before marker self.assertEqual(console(warp_test, "s2b -1"), -10) self.assertEqual(console(warp_test, "b2s -10"), -1) # on marker self.assertEqual(console(warp_test, "s2b 0"), 0) self.assertEqual(console(warp_test, "b2s 0"), 0) def assert_expected_s2b_inbetween_the_two_markers(self): """Checks if the seconds to beats function works properly inbetween two markers""" self.assertEqual(console(self.test, "s2b 2.5"), 0.5) def assert_expected_b2s_inbetween_the_two_markers(self): """Checks if the beats to second funciton works properly inbetween two markers""" self.assertEqual(console(self.test, "b2s 0.5"), 2.5) def assert_expected_s2b_and_b2s_before_the_2markers(self): """Checks if the b2s and s2b functions work properly before the set of markers""" self.assertEqual(console(self.test, "b2s -0.5"), -2.5) self.assertEqual(console(self.test, "s2b -2.5"), -0.5) def assert_expected_s2b_and_b2s_after_all_2markers(self): """Checks if the s2b and b2s work properly after the markers (i.e. end_tempo)""" self.assertEqual(console(self.test, "s2b 6"), 11) self.assertEqual(console(self.test, "b2s 11"), 6) def assert_expected_s2b_and_b2s_if_call_is_on_marker(self): """verify that if b2s and s2b are called on their respective markers, the result is consistent with their defintions. Notably, (0,0) is easy to cause errors.""" self.assertEqual(console(self.test, "b2s 1.0"), 5.0) self.assertEqual(console(self.test, "s2b 5.0"), 1.0) self.assertEqual(console(self.test, "s2b 0"), 0) self.assertEqual(console(self.test, "b2s 0"), 0) def assert_that_order_of_marker_vs_end_tempo_setting_doesnt_matter(self): """Verify that the end_tempo can be set before the markers are set""" self.test = Warp() self.assert_accepts_end_tempo() self.assert_console_accepts_markers() self.assert_console_accepts_b2s() self.assert_console_accepts_s2b() def assert_s2b_b2s_act_properly_after_third_marker_introduced(self): r""" Checks that if a third marker is introduce inbetween the two prior defined markers that the funciton behvaiors are maintained (NEW / ADDED) v i.e. 0 0.5 1.0 beat line -----*---------*-----------*--------> (before all region) | section \ section \ (after all region) | A \ B \ time line ------*------------*-----------*-----> 0 4 5 """ console(self.test, "marker 0.5 4") # this change will add the marker shown in the docstring. # Pracitcally, this change should alter the value of the tempo # before all markers, add an internal section for the, and not # impact the final section # check section A self.assertEqual(console(self.test, "s2b 2"), 0.25) self.assertEqual(console(self.test, "b2s 0.25"), 2) # check section B self.assertEqual(console(self.test, "s2b 4.5"), 0.75) self.assertEqual(console(self.test, "b2s 0.75"), 4.5) # check before all region self.assertEqual(console(self.test, "s2b -2"), -0.25) self.assertEqual(console(self.test, "b2s -0.25"), -2) # check final region self.assertEqual(console(self.test, "s2b 6"), 11) self.assertEqual(console(self.test, "b2s 11"), 6) # check if call is on marker functionality self.assertEqual(console(self.test, "b2s 0.5"), 4) self.assertEqual(console(self.test, "s2b 4"), 0.5) def check_if_solution_is_optimal(self): """ Verifies that the optimal solutions is employed with complexity O(log(n)). The whole function must run at no less than 1000 standard units; A standard unit is defined as the time it takes for a general sorting function to sort 1,000 times; which, is only possible if the ideal O(log(n)) solution is used in all steps. """ import timeit import math import statistics as stats import time avg_log = [] test_ns = [2**i for i in range(4, 12)] start = time.time() for n in test_ns: test_warp = Warp() avg_exc = 0 avg_exc_ref = 0 for marker in range(1, n): console( test_warp, "marker " + str(float(marker)) + ' ' + str(float(marker))) repeats = 25 for _ in range(repeats): execution = timeit.timeit(lambda: [ console(test_warp, 'b2s ' + str(n - 0.1)), console(test_warp, 's2b ' + str(n // 2 - 0.1)) ], number=400) avg_exc += execution / repeats execution = timeit.timeit( lambda: [ord(x) for x in "aasdfadgasdfwr22"], number=1000) avg_exc_ref += execution / repeats avg_log.append(avg_exc / avg_exc_ref) print("(raw time, for 400 requests, and n-markers = %d)" " mean: %f, theoretical frequency: %f" % (n, avg_exc, 2 * 400 / avg_exc)) # 2 * because s2b and b2s in conjunction time_elapsed = time.time() - start exc_ref = sum( timeit.repeat(lambda: [ord(x) for x in "aasdfadgasdfwr22"], repeat=25, number=1000)) / 25 time_elapsed_normalized = time_elapsed / exc_ref self.assertTrue(time_elapsed < 1000) avg_log = [ math.log2(avg_log[i + 1] / avg_log[i]) for i in range(len(avg_log) - 1) ] print("(logarithm) mean: %f, std: %f, adjusted mean: %f" % (stats.mean(avg_log), stats.stdev(avg_log), stats.mean(avg_log) + 2 * stats.stdev(avg_log))) self.assertTrue(stats.mean(avg_log) < 0.15) # O(log(n))
def __init__(self, name, source, title, borders, world): self.name = name self.source = os.path.basename(source) self.title = title self.world = world self.borders = borders # Logic to load zone file self.data = pytmx.TiledMap('server_data/zones/' + source) self.client_data = '' with open('server_data/zones/' + source, 'r') as zonefile: self.client_data = zonefile.read() self.width = self.data.width self.height = self.data.height self.blocked = self.data.layers.index( self.data.get_layer_by_name('blocked')) self.graph = GridWithWeights(self.width, self.height) self.graph.walls = [ (x, self.height - y - 1) for x, y, gid in self.data.layers[self.blocked].tiles() ] for o in self.data.objects: if o.type == 'monster_spawn': x = int(o.x / 32) y = self.height - int(o.y / 32) - 1 w = int(o.width / 32) h = int(o.height / 32) max_spawn = int(o.properties['max_spawn']) spawn_delay = float(o.properties['spawn_delay']) monster_name = o.name # Create monster spawn MonsterSpawn(monster_name, x, y, w, h, self.name, max_spawn, spawn_delay, self.world) if o.type == 'npc_spawn': x = int(o.x / 32) y = self.height - int(o.y / 32) - 1 w = int(o.width / 32) h = int(o.height / 32) max_spawn = int(o.properties['max_spawn']) spawn_delay = float(o.properties['spawn_delay']) npc_name = o.name # Create npc spawn NpcSpawn(npc_name, x, y, w, h, self.name, max_spawn, spawn_delay, self.world) if o.type == 'warp': x = int(o.x / 32) y = self.height - int(o.y / 32) - 1 #w = int(o.width/32) #h = int(o.height/32) end_zone = o.properties['end_zone'] end_x = int(o.properties['end_x']) end_y = int(o.properties['end_y']) self.world.warps.append( Warp(self.name, x, y, end_zone, end_x, end_y)) print "Loaded ZONE", self.name
''' @author: Wizzard ''' from warp import Warp # Relevant information about the warps within each level Levels = { # 0 - Main Area # 1 - Mumbo's Skull # 2 - Ticker's Tower # 3 - Top Of Ticker's Tower "Mumbo's Mountain": { # Coming outside from Mumbo's Skull Warp("Mumbo's Skull - Outside", 0x16, 0, 1, 0, 0, Warp.Termite): [ "1579098CF47532060016000000000000", "159D098DF49232060016000000000662", "15C1098CF4AE32060016000000000663", "15E0098EF4CB32060016000000000000", ], # Coming inside to Mumbo's Skull Warp("Mumbo's Skull - Inside", 0x17, 1, 0): [ "0000005103A94B0600170000000063A9", ], # Coming outside from the lower part of Ticker's Tower Warp("Ticker's Tower - Lower/Outside", 0x18, 0, 2): [ "03DC0663FC384E06001800000001071A", ], # Coming inside to the lower part of Ticker's Tower Warp("Ticker's Tower - Lower/Inside", 0x19, 2, 0): [ "008E003CFCB83206001900000006118B",
num_faces = 150 num_lights = 1 base_model = Geometry(vertices=np.random.randn(num_vertices, 3), faces=np.random.randint(0, num_vertices, size=[num_faces, 3])) lights = Lights(positions=np.random.randn(num_lights, 3), intensities=np.random.randn(num_lights, 3)) camera = Camera(eye=np.random.randn(1, 3), center=np.random.randn(1, 3), world_up=np.random.randn(1, 3)) trans = Transform(batch_size=BATCH_SIZE) warp_params = Input(shape=[NUM_WARPS, 1]) warped_vertices = Warp(num_warps=NUM_WARPS)( [K.identity(base_model.vertices), warp_params]) world_coords = trans(warped_vertices) colors = K.constant(np.random.randn(BATCH_SIZE, num_vertices, 3)) rendered = Render(512, 512)([world_coords, base_model.faces], base_model.calculate_normals(world_coords), colors, [camera.eye, camera.center, camera.world_up], [lights.positions, lights.intensities]) #model = Model(inputs=[warp_params], outputs=[renderer]) sess = K.get_session() sess.run(tf.global_variables_initializer()) sess.run([rendered], feed_dict={warp_params: np.random.randn(BATCH_SIZE, NUM_WARPS, 1)})
def onStairwellEnter(): global stairwellEnter stairwellEnter = True stairwell = Room([], [player], sprites.rooms[10], canvas, inventory, onStairwellEnter) cseRoom = Room([], [player], sprites.rooms[11], canvas, inventory) outside = Room([], [player], sprites.rooms[12], canvas, inventory) darkRoom = Room([], [], sprites.rooms[13], canvas, inventory, player=player) # Walls nexusWalls = [ Warp(348, -48, 668, -48, nexus, juniorNexus), Wall(668, -48, 668, 444), Wall(668, 444, 876, 444), Wall(876, 444, 876, 592), Wall(876, 592, 748, 592), Wall(748, 592, 748, 896), Wall(748, 896, 904, 896), Wall(904, 896, 904, 1008), Wall(904, 1008, 348, 1008), Wall(348, 1008, 348, 868), Wall(348, 868, 0, 868), Warp(0, 868, 0, 500, nexus, freshmanHallway), Wall(0, 500, 348, 500), Wall(348, 500, 348, -48) ] for wall in nexusWalls:
from segmentation import Segmentation from mosaic import Mosaic from sampling import Sampling from image_fusion import Fusion path1 = "/Users/liumeiyu/Downloads/IMG_7575.JPG" path2 = "/Users/liumeiyu/Downloads/test1.jpg" path3 = "/Users/liumeiyu/Downloads/test2.jpg" A = Histogram(path1) B = Smooth(path1) C = Change(path1) D = Base(path1) E = Binary(path1) F = D_E(path1) G = Warp(path1) H = Cvt(path1) K = Edge_detection(path1) L = Segmentation(path1) M = Mosaic(path3) N = Sampling(path1) P = Fusion(path1) # A.img_histogram_trans() # A.img_histogram() # B.linear_smooth_np() # B.linear_smooth() # B.box_smooth() # B.gaussian_smooth() # B.median_smooth()